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

📄 ans_os.c

📁 linux intel 网卡驱动,利用他可以让inel的pro 100 网卡进行网络配置和实用
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************    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_os.h                                              **                                                                     ** Abstract: iANS routines specific to linux                           **                                                                     ** Environment:  This file is intended to be specific to the Linux     **               operating system.                                     **                                                                     ***********************************************************************/#include "ans_driver.h"#include "ans_os.h"#include <asm/unaligned.h>void (*ans_notify)(device_t *dev, int ind_type);BD_ANS_STATUS bd_ans_os_SetCallback(BOARD_PRIVATE_STRUCT *bps,    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_os_Ioctl()****  This function will pull the IANS structures out of the ifr and pass**  them to the generic ANS module for processing.****  Arguments:  struct device *dev - pointer to the adapters device structure**              struct ifreq *ifr - the request structure passed down from**                                  upper layers.**              int cmd - the number of the IOC to process.  This function**                        will only process the IANS_BASE_SIOC command.****  Returns:    int - 0 if successful, non-zero otherwise.*/intbd_ans_os_Ioctl(device_t *dev, struct ifreq *ifr, int cmd){    /* get the private data structure from the dev struct */    BOARD_PRIVATE_STRUCT *bps = dev->priv;        IANS_BD_PARAM_HEADER *header =  (IANS_BD_PARAM_HEADER *)ifr->ifr_data;    iANSsupport_t *iANSdata;    BD_ANS_STATUS status;        /* get a pointer to the ANS data struct from the ifr */    iANSdata = ANS_PRIVATE_DATA_FIELD(bps);    //DEBUGLOG("bd_ans_os_Ioctl: enter\n");    /* switch on the command */    switch(cmd) {    case IANS_BASE_SIOC:        status = bd_ans_ProcessRequest(bps, iANSdata, header);        if (status == BD_ANS_SUCCESS)            return 0;        /* some problem occured, return error value */        return -EAGAIN;    default:        return -EOPNOTSUPP;    }    return 0;}    /* bd_ans_os_Transmit()****  This function will get the required structures from the skb and**  pass them to the generic bd_ans_Transmit routine for processing.****  Arguments:  BOARD_PRIVATE_STRUCT *bps - pointer to the boards **                                          private data structure**              HW_TX_DESCRIPTOR *txd - pointer to the hardware **                                      specific tx descriptor**              struct sk_buff *skb - pointer to the skb which**                                    describes this packet.****  Returns:    int - 0 if successful, non-zero otherwise.*/int bd_ans_os_Transmit( BOARD_PRIVATE_STRUCT *bps,     HW_TX_DESCRIPTOR *txd,    struct sk_buff **skb ){    UINT16 vlan_id;     /* don't know if I really need this */    IANS_ATTR_HEADER *attr_head = iANSGetTransmitAttributeHeader(*skb);    iANSsupport_t *iANSdata = ANS_PRIVATE_DATA_FIELD(bps);        /* nothing special to do unless we are in attributed mode */        /* call the bd_ans_Transmit routine to setup our frame for transmit */    if (iANSdata->attributed_mode) {        /* Check to identify misrouted frames */        /* An explicit check would not have been backward compatible */        if ((char *)(attr_head->pFirstTLV) != ( (char *)attr_head + sizeof(IANS_ATTR_HEADER) )) {            //printk("%s warning frame does not contain TLV data",(*skb)->dev->name);            return 1; // This is not an iANS attributed packet!        }        if (bd_ans_Transmit(bps,            iANSdata,            attr_head->pFirstTLV,            txd,            skb,            &vlan_id) == BD_ANS_FAILURE)            return 1;                                                            }            return 0;}        /* bd_ans_os_Receive()****  This function will determine if the adapter is configured**  for attributed mode, and call the generic ans routine**  to add any needed tlvs if we are configured to do so.**  It will also check the routing_mode flag to determine**  if we need to check to see if we should route frames**  to ANS.****  Arguments:  BOARD_PRIVATE_STRUCT *bps - pointer to private data struct**              HW_RX_DESCRIPTOR *rxd - pointer to hw specific frame descriptr**              struct sk_buff *skb - the OS descriptor for this frame****  Returns:    int - 0 if successful, non-zero otherwise*/intbd_ans_os_Receive(BOARD_PRIVATE_STRUCT *bps,    HW_RX_DESCRIPTOR *rxd,    struct sk_buff *skb ){    UINT32 length;    iANSsupport_t *iANSdata = ANS_PRIVATE_DATA_FIELD(bps);    IANS_ATTR_HEADER *attr_head = iANSGetReceiveAttributeHeader(skb);    struct sk_buff *dummy_tlv_ptr;    device_t *dev = DRIVER_DEV_FIELD(bps);    DEBUGLOG("bd_ans_os_Receive: enter\n");    /* if we are in attributed mode, we need to fill out tlv structures */    if (iANSdata->attributed_mode) {        DEBUGLOG("bd_ans_os_Receive: in attributed mode\n");        /* setup the TLV pointer first */        put_unaligned((Per_Frame_Attribute_Header *)                      (((UCHAR *)attr_head) + sizeof(IANS_ATTR_HEADER)),                      &(attr_head->pFirstTLV));                if (bd_ans_Receive(bps,            iANSdata,            rxd,            skb->data,            skb,            &dummy_tlv_ptr, /* this isn't used by Linux */            &length) == BD_ANS_FAILURE) {            DEBUGLOG("bd_ans_os_Receive: Failed bd_ans_Receive\n");            return 1;           }    } else {        put_unaligned(NULL, &(attr_head->pFirstTLV));    }        /* need to check to see if we are routing rx packets to ANS. If this     * has been setup, then we need to replace the existing protocol     * with the ANS protocol and store the original at the head of     * the skb     */    if (iANSdata->routing_mode == IANS_ROUTING_ON) {        DEBUGLOG("bd_ans_os_Receive: In routing mode\n");        /* set the protocol here. the eth_type_trans routine         * changes the data pointer and so we want to do that after         * we have done any stripping of the packet          */        put_unaligned(eth_type_trans(skb, dev),                      &(attr_head->OriginalProtocol));        skb->protocol = IANS_FRAME_TYPE;    } else {        skb->protocol = eth_type_trans(skb, dev);    }    return 0;}    /* bd_ans_os_Watchdog()****  This function will check on the status fields of the ANS**  support structure and see if the status has changed since**  the last time that it was checked.  If it has changed,**  then we need to alert the ANS protocol somehow.(TBD)****  Arguments:  struct device *dev - pointer to the device structure**              BOARD_PRIVATE_STRUCT *bps - the driver's private data struct****  Returns: void*/voidbd_ans_os_Watchdog(device_t *dev, BOARD_PRIVATE_STRUCT *bps){    IANS_BD_PARAM_STATUS current_status;            iANSsupport_t *piANSdata = ANS_PRIVATE_DATA_FIELD(bps);    /* check ans communication protocol.  If we are not up, there is     * nothing to do.     */    if ((piANSdata->iANS_status == IANS_COMMUNICATION_DOWN)        || (piANSdata->reporting_mode == IANS_STATUS_REPORTING_OFF))        return;        /* update the driver's status */    bd_ans_drv_UpdateStatus(bps);        /* fill out the current status */    bd_ans_FillStatus(bps, ANS_PRIVATE_DATA_FIELD(bps), &current_status);        /* compare the status to the last status update.  If they are different,     * we need to send an indication.     */    /* Compare current status against previous one: if equal, just return */    if (BD_ANS_BCMP((UCHAR *)&piANSdata->prev_status, (UCHAR *)&current_status,                    sizeof(IANS_BD_PARAM_STATUS)) == BD_ANS_TRUE) {        return;    }        /* if we are here, we need to send a status change notification */        /* as far as I can tell, since it hasn't been defined yet,     * the thing to do here is to call netdev_state_change(dev).     * this is a synchronous call to a registered chain of who knows

⌨️ 快捷键说明

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