📄 ans.c
字号:
/***************************************************************************** ***************************************************************************** Copyright (c) 1999-2000, Intel Corporation All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *********************************************************************************************************************************************************//*********************************************************************** ** INTEL CORPORATION ** ** This software is supplied under the terms of the license included ** above. All use of this driver must be in accordance with the terms ** of that license. ** ** Module Name: ans.c ** ** Abstract: ** ** Environment: This file is intended to be specific to the Linux ** operating system. ** ***********************************************************************/#include "ans_driver.h"void (*ans_notify)(struct device *dev, int ind_type);BD_ANS_BOOLEAN BD_ANS_BCMP(UCHAR *s1, UCHAR *s2, UINT32 length){ while (length) { if (*s1 != *s2) return BD_ANS_FALSE; length--; s1++; s2++; } return BD_ANS_TRUE;} VOID BD_ANS_BCOPY(UCHAR *destination, UCHAR *source, UINT32 length) { while (length--) { *destination++ = *source++; }} VOID BD_ANS_BZERO(UCHAR *s, UINT32 length){ while (length--) *s = 0;} /* bd_ans_ProcessRequest()**** This routine is called if iANS has issued a command to the driver through** the driver's private ioctl routine. It will parse the header for the ** opcode of the command to execute, and call the appropriate functions.**** Arguments: BOARD_PRIVATE_STRUCT *bps - a pointer to the adapters hw ** specific data structure.** iANSsupport_t *iANSdata - pointer to the iANS required** support structure** IANS_BD_PARAM_HEADER *header - a pointer to the start of the** ans command.** **** Returns: BD_ANS_STATUS - SUCCESS if command is recognized and was ** processed successfully, FAILURE otherwise.*/ BD_ANS_STATUS bd_ans_ProcessRequest(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ //DEBUGLOG("bd_ans_ProcessRequest: enter\n"); /* Only allow IANS_OP_BD_IDENTIFY if iANS comm is down */ if((iANSdata->iANS_status == IANS_COMMUNICATION_DOWN) && (header->Opcode!=IANS_OP_BD_IDENTIFY)){ DEBUGLOG("bd_ans_ProcessRequest: ANS communication not up\n"); return BD_ANS_FAILURE; } switch (header->Opcode) { case IANS_OP_BD_IDENTIFY: DEBUGLOG("bd_ans_ProcessRequest: Identify request\n"); return (bd_ans_Identify(bps, iANSdata, header)); case IANS_OP_BD_DISCONNECT: DEBUGLOG("bd_ans_ProcessRequest: Disconnect request\n"); return (bd_ans_Disconnect(bps, iANSdata, header)); case IANS_OP_EXT_GET_CAPABILITY: DEBUGLOG("bd_ans_ProcessRequeest: Ext Get Capabilities request\n"); return (bd_ans_ExtendedGetCapability(bps, iANSdata, header)); case IANS_OP_EXT_SET_MODE: DEBUGLOG("bd_ans_ProcessRequest: Ext Set mode request\n"); return (bd_ans_ExtendedSetMode(bps, iANSdata, header)); case IANS_OP_EXT_GET_STATUS: DEBUGLOG("bd_ans_ProcessRequest: Ext Get Status request\n"); return (bd_ans_ExtendedGetStatus(bps, iANSdata, header));#ifdef UNIXWARE case IANS_OP_EXT_STOP_PROMISC: return (bd_ans_ExtendedStopPromiscuousMode(bps, iANSdata));#endif #ifdef IANS_BASE_VLAN_TAGGING case IANS_OP_ITAG_GET_CAPABILITY: DEBUGLOG("bd_ans_ProcessRequest: get itag capability request\n"); return (bd_ans_TagGetCapability(bps, iANSdata, header)); case IANS_OP_ITAG_SET_MODE: DEBUGLOG("bd_ans_ProcessRequest: itag set mode request\n"); return (bd_ans_TagSetMode(bps, iANSdata, header));#endif#ifdef IANS_BASE_VLAN_ID case IANS_OP_IVLAN_ID_GET_CAPABILITY: DEBUGLOG("bd_ans_ProcessRequest: get vlan capability request\n"); return (bd_ans_VlanGetCapability(bps, iANSdata, header)); case IANS_OP_IVLAN_ID_SET_MODE: DEBUGLOG("bd_ans_ProcessRequest: vlan set mode request\n"); return (bd_ans_VlanSetMode(bps, iANSdata, header)); case IANS_OP_IVLAN_ID_SET_TABLE: DEBUGLOG("bd_ans_ProcessRequest: vlan set table request\n"); return (bd_ans_VlanSetTable(bps, iANSdata, header));#endif case IANS_OP_ANS_SET_CB: DEBUGLOG("bd_ans_ProcessRequest: ans set callbacks\n"); return (bd_ans_SetCallback(bps, iANSdata, header)); default: DEBUGLOG("bd_ans_ProcessRequest: unknown op code\n"); return (BD_ANS_FAILURE); } } BD_ANS_STATUS bd_ans_SetCallback(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ IANS_BD_ANS_SET_CB *acb = (IANS_BD_ANS_SET_CB *) header; ans_notify = acb->notify; return BD_ANS_SUCCESS;}/* bd_ans_Identify()**** This routine will identify the base driver to the ANS module by filling out** the required structure.**** Arguments: BOARD_PRIVATE_STRUCT *bps - a pointer to the adapters hw ** specific data structure.** iANSsupport_t *iANSdata - pointer to the iANS required** support structure** IANS_BD_PARAM_HEADER *header - a pointer to the start of the** ans command.**** Returns: BD_ANS_STATUS - SUCCESS if command was processed ** successfully, FAILURE otherwise.*/BD_ANS_STATUS bd_ans_Identify(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ IANS_BD_PARAM_IDENTIFY *iANSidentify; UINT32 BDCommVersion; /* base driver communication version */ /* Get our comm version from the #defines */ BDCommVersion = (IANS_BD_COMM_VERSION_MAJOR << 16) + IANS_BD_COMM_VERSION_MINOR; iANSidentify = (IANS_BD_PARAM_IDENTIFY *)header; /* if copyright string doesnt match or iANS comm version is older return error */ if ((iANSidentify->iANSCommVersion < BDCommVersion)|| (BD_ANS_BCMP(iANSidentify->iANSSignature, IntelCopyrightString, IANS_SIGNATURE_LENGTH)) != BD_ANS_TRUE) { return BD_ANS_FAILURE; } /* else set communication to iANS as up */ iANSdata->iANS_status = IANS_COMMUNICATION_UP; iANSidentify->BDCommVersion = BDCommVersion; BD_ANS_BCOPY(iANSidentify->BDSignature, IntelCopyrightString, IANS_SIGNATURE_LENGTH); /* initialize the iANSsupport_t strucutre */ /* at this point, this is the only place where we initialize the * support flags for the driver. In may be that we should do this * someplace else as well - for example, if we ever support hot-add * then the capabilities may change dynamically, in which case * we will need to call GetAllCapabilities again */ return (bd_ans_GetAllCapabilities(bps, iANSdata)); } /* bd_ans_Init()**** This function initializes the communication flags. It should be called** at init time by the driver to initialize this part of the iANSsupport_t ** structure.**** Arguments: iANSsupport_t *iANSdata - the ans related data**** Returns: void*/VOIDbd_ans_Init(iANSsupport_t *iANSdata){ /* set all the communication flags to initial values */ iANSdata->iANS_status = IANS_COMMUNICATION_DOWN;#ifdef IANS_BASE_VLAN_TAGGING iANSdata->vlan_mode = IANS_VLAN_MODE_OFF; iANSdata->vlan_filtering_mode = IANS_VLAN_FILTERING_OFF; iANSdata->num_vlan_filter = 0; iANSdata->tag_mode = IANS_BD_TAGGING_NONE;#endif iANSdata->reporting_mode = IANS_STATUS_REPORTING_OFF; iANSdata->timer_id = 0; iANSdata->attributed_mode = BD_ANS_FALSE; iANSdata->routing_mode = IANS_ROUTING_OFF;}/* bd_ans_Disconnect()**** This request is sent by ANS when the ANS module is unloading or will** no longer be bound to this particular board. **** Arguments: BOARD_PRIVATE_STRUCT *bps - a pointer to the adapters hw ** specific data structure.** iANSsupport_t *iANSdata - pointer to the iANS required** support structure** IANS_BD_PARAM_HEADER *header - a pointer to the start of the** ans command.**** Returns: BD_ANS_STATUS - SUCCESS if command was processed ** successfully, FAILURE otherwise.*/BD_ANS_STATUS bd_ans_Disconnect(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ if (iANSdata->reporting_mode == IANS_STATUS_REPORTING_ON) bd_ans_DeActivateFastPolling(bps, iANSdata); return (bd_ans_ResetAllModes(bps, iANSdata));} /* bd_ans_ExtendedGetCapability()**** This function will fill out the structure required for the extended** capabilities query. **** Arguments: BOARD_PRIVATE_STRUCT *bps - a pointer to the adapters hw ** specific data structure.** iANSsupport_t *iANSdata - pointer to the iANS required** support structure** IANS_BD_PARAM_HEADER *header - a pointer to the start of the** ans command.**** Returns: BD_ANS_STATUS - SUCCESS if command was processed ** successfully, FAILURE otherwise.*/BD_ANS_STATUS bd_ans_ExtendedGetCapability(BOARD_PRIVATE_STRUCT *bps, iANSsupport_t *iANSdata, IANS_BD_PARAM_HEADER *header){ ((IANS_BD_PARAM_EXT_CAP *)header)->BDAllAvailableRouting = IANS_ROUTING_NOT_SUPPORTED; /* get routing capabilities */ if (BD_ANS_OS_CAN_ROUTE_RX(bps) == BD_ANS_TRUE) { ((IANS_BD_PARAM_EXT_CAP *)header)->BDAllAvailableRouting |= IANS_ROUTING_RX_PROTOCOL; } /* Report that base driver supports setting of MAC address */ ((IANS_BD_PARAM_EXT_CAP *)header)->BDCanSetMacAddress = ANS_BD_SUPPORTS(iANSdata->can_set_mac_addr); /* Report supported version of the status reporting structure */ ((IANS_BD_PARAM_EXT_CAP *)header)->BDIansStatusVersion = IANS_STATUS_VERSION; ((IANS_BD_PARAM_EXT_CAP *)header)->BDAllAvailableSpeeds = iANSdata->available_speeds; ((IANS_BD_PARAM_EXT_CAP *)header)->BDFlags = iANSdata->bd_flags; return BD_ANS_SUCCESS; }/* bd_ans_ExtendedSetMode()**** This request is sent by ANS to enable either tx/rx of tlv's with** packet data, or to enable routing of all rx packets to ANS. **
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -