⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ans.c

📁 linux intel 网卡驱动,利用他可以让inel的pro 100 网卡进行网络配置和实用
💻 C
📖 第 1 页 / 共 4 页
字号:
/*******************************************************************************    Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved.    This program is free software; you can redistribute it and/or modify it   under the terms of the GNU General Public License as published by the Free   Software Foundation; either version 2 of the License, or (at your option)   any later version.    This program is distributed in the hope that it will be useful, but WITHOUT   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   more details.    You should have received a copy of the GNU General Public License along with  this program; if not, write to the Free Software Foundation, Inc., 59   Temple Place - Suite 330, Boston, MA  02111-1307, USA.    The full GNU General Public License is included in this distribution in the  file called LICENSE.    Contact Information:  Linux NICS <linux.nics@intel.com>  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497*******************************************************************************//***********************************************************************                                                                     ** 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 shared among Linux and    **               Unixware operating systems.                           **                                                                     ***********************************************************************///#define _IANS_MAIN_MODULE_C_#include "ans_driver.h"/* I meant to make these inline, but don't have time to figure out** compiler problems right now...*/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 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           default:        return (bd_ans_os_ProcessRequest(bps, iANSdata, header));    } }                                    /* 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,                     (UCHAR *)IntelCopyrightString,                     IANS_SIGNATURE_LENGTH)) != BD_ANS_TRUE) {        return BD_ANS_FAILURE;    }       BD_ANS_DRV_LOCK;            /* else set communication to iANS as up */    iANSdata->iANS_status = IANS_COMMUNICATION_UP;    iANSidentify->BDCommVersion = BDCommVersion;    BD_ANS_BCOPY(iANSidentify->BDSignature,                 (UCHAR *)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);    BD_ANS_DRV_UNLOCK;    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){       bd_ans_os_ExtendedGetCapability(bps, iANSdata, header);    /* 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;        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.  ****  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_ExtendedSetMode(BOARD_PRIVATE_STRUCT *bps,                                     iANSsupport_t *iANSdata,                                     IANS_BD_PARAM_HEADER *header){    BD_ANS_STATUS status;    IANS_BD_PARAM_EXT_SET_MODE *request = (IANS_BD_PARAM_EXT_SET_MODE *)header;        /* this function call will enable/disable fast polling mode

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -