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

📄 ans_os.c

📁 COPE the first practical network coding scheme which is developped on click
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** ***************************************************************************** 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_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"/* 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(struct device *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 = iANSGetAttributeHeader(*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) {        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 = iANSGetAttributeHeader(skb);    struct sk_buff *dummy_tlv_ptr;    struct device *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 */        attr_head->pFirstTLV = (Per_Frame_Attribute_Header *)	    (((UCHAR *)iANSGetAddrOfPtrToFirstAttribute(skb)) 		+ sizeof(IANS_ATTR_HEADER));        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 {        attr_head->pFirstTLV = NULL;    }        /* 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 	 */	attr_head->OriginalProtocol = eth_type_trans(skb, dev);        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.****  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(struct device *dev, BOARD_PRIVATE_STRUCT *bps){    IANS_BD_PARAM_STATUS current_status;	    iANSsupport_t *piANSdata = ANS_PRIVATE_DATA_FIELD(bps);

⌨️ 快捷键说明

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