aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/bcm
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2010-09-08 14:46:36 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2010-09-08 21:15:06 -0700
commitf8942e07a3db9d82e8fb11d3d494876b8bae9ff9 (patch)
tree2406636a4f9a4ac6b0bfc90e07aefa8b1b18b8ff /drivers/staging/bcm
parent2d2f03b022186e6d7520a758abdea9c04a2969fe (diff)
staging: Beeceem USB Wimax driver
The Sprint 4G network uses a Wimax dongle with Beecem chipset. The driver is typical of out of tree drivers, but maybe useful for people, and the hardware is readily available. Here is a staging ready version (i.e warts and all) 0. Started with Rel_5.2.7.3P1_USB from Sprint4GDeveloperPack-1.1 1. Consolidated files in staging 2. Remove Dos cr/lf 3. Remove unnecessary ioctl from usbbcm_fops Applied patches that were in the developer pack, surprising there were ones for 2.6.35 already. This is compile tested only, see TODO for what still needs to be done. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/bcm')
-rw-r--r--drivers/staging/bcm/Adapter.h714
-rw-r--r--drivers/staging/bcm/Arp.c94
-rw-r--r--drivers/staging/bcm/Bcmchar.c2420
-rw-r--r--drivers/staging/bcm/Bcmnet.c266
-rw-r--r--drivers/staging/bcm/CmHost.c2443
-rw-r--r--drivers/staging/bcm/CmHost.h166
-rw-r--r--drivers/staging/bcm/DDRInit.c1302
-rw-r--r--drivers/staging/bcm/DDRInit.h9
-rw-r--r--drivers/staging/bcm/Debug.c40
-rw-r--r--drivers/staging/bcm/Debug.h297
-rw-r--r--drivers/staging/bcm/HandleControlPacket.c247
-rw-r--r--drivers/staging/bcm/HostMIBSInterface.h230
-rw-r--r--drivers/staging/bcm/HostMibs.h7
-rw-r--r--drivers/staging/bcm/IPv6Protocol.c400
-rw-r--r--drivers/staging/bcm/IPv6ProtocolHdr.h119
-rw-r--r--drivers/staging/bcm/InterfaceAdapter.h97
-rw-r--r--drivers/staging/bcm/InterfaceDld.c509
-rw-r--r--drivers/staging/bcm/InterfaceIdleMode.c318
-rw-r--r--drivers/staging/bcm/InterfaceIdleMode.h16
-rw-r--r--drivers/staging/bcm/InterfaceInit.c868
-rw-r--r--drivers/staging/bcm/InterfaceInit.h51
-rw-r--r--drivers/staging/bcm/InterfaceIsr.c203
-rw-r--r--drivers/staging/bcm/InterfaceIsr.h15
-rw-r--r--drivers/staging/bcm/InterfaceMacros.h18
-rw-r--r--drivers/staging/bcm/InterfaceMisc.c290
-rw-r--r--drivers/staging/bcm/InterfaceMisc.h45
-rw-r--r--drivers/staging/bcm/InterfaceRx.c256
-rw-r--r--drivers/staging/bcm/InterfaceRx.h7
-rw-r--r--drivers/staging/bcm/InterfaceTx.c259
-rw-r--r--drivers/staging/bcm/InterfaceTx.h13
-rw-r--r--drivers/staging/bcm/Interfacemain.h10
-rw-r--r--drivers/staging/bcm/Ioctl.h360
-rw-r--r--drivers/staging/bcm/Kconfig7
-rw-r--r--drivers/staging/bcm/LeakyBucket.c399
-rw-r--r--drivers/staging/bcm/Macros.h399
-rw-r--r--drivers/staging/bcm/Makefile12
-rw-r--r--drivers/staging/bcm/Misc.c2239
-rw-r--r--drivers/staging/bcm/Osal_Misc.c27
-rw-r--r--drivers/staging/bcm/PHSDefines.h125
-rw-r--r--drivers/staging/bcm/PHSModule.c1641
-rw-r--r--drivers/staging/bcm/PHSModule.h95
-rw-r--r--drivers/staging/bcm/Protocol.h151
-rw-r--r--drivers/staging/bcm/Prototypes.h323
-rw-r--r--drivers/staging/bcm/Qos.c893
-rw-r--r--drivers/staging/bcm/Queue.h31
-rw-r--r--drivers/staging/bcm/TODO15
-rw-r--r--drivers/staging/bcm/Transmit.c553
-rw-r--r--drivers/staging/bcm/Typedefs.h47
-rw-r--r--drivers/staging/bcm/Version.h35
-rw-r--r--drivers/staging/bcm/cntrl_SignalingInterface.h677
-rw-r--r--drivers/staging/bcm/headers.h109
-rw-r--r--drivers/staging/bcm/hostmibs.c164
-rw-r--r--drivers/staging/bcm/led_control.c1006
-rw-r--r--drivers/staging/bcm/led_control.h106
-rw-r--r--drivers/staging/bcm/nvm.c5614
-rw-r--r--drivers/staging/bcm/nvm.h489
-rw-r--r--drivers/staging/bcm/osal_misc.h49
-rw-r--r--drivers/staging/bcm/sort.c63
-rw-r--r--drivers/staging/bcm/target_params.h81
-rw-r--r--drivers/staging/bcm/vendorspecificextn.c146
-rw-r--r--drivers/staging/bcm/vendorspecificextn.h18
61 files changed, 27603 insertions, 0 deletions
diff --git a/drivers/staging/bcm/Adapter.h b/drivers/staging/bcm/Adapter.h
new file mode 100644
index 00000000000..a7c0ce9e7fa
--- /dev/null
+++ b/drivers/staging/bcm/Adapter.h
@@ -0,0 +1,714 @@
+/***********************************
+* Adapter.h
+************************************/
+#ifndef __ADAPTER_H__
+#define __ADAPTER_H__
+
+#define MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES 256
+#include "Debug.h"
+
+typedef struct _LIST_ENTRY{
+ struct _LIST_ENTRY *next;
+ struct _LIST_ENTRY *prev;
+} LIST_ENTRY, *PLIST_ENTRY;
+
+typedef struct _BCM_LIST_ENTRY {
+
+ LIST_ENTRY Link;
+
+} BCM_LIST_ENTRY, *PBCM_LIST_ENTRY;
+
+typedef enum _RCB_STATUS
+{
+ DRIVER_PROCESSED=1,
+ APPLICATION_PROCESSED
+} RCB_STATUS, *PRCB_STATUS;
+
+#define fFILLED 1
+#define fEMPTY 0
+
+struct _BCM_CB
+{
+ // The network packet that this RCB is receiving
+ PVOID pv_packet;
+ // Describes the length of the packet .
+ UINT ui_packet_length;
+ // Pointer to the first buffer in the packet (only one buffer for Rx)
+ PUCHAR buffer;
+ atomic_t status;
+ UINT filled;
+} __attribute__((packed));
+typedef struct _BCM_CB BCM_CB,*PBCM_CB;
+
+typedef BCM_CB BCM_RCB, *PBCM_RCB;
+typedef BCM_CB BCM_TCB, *PBCM_TCB;
+
+/* This is to be stored in the "pvOsDepData" of ADAPTER */
+typedef struct LINUX_DEP_DATA
+{
+ struct net_device *virtualdev; /* Our Interface (veth0) */
+ struct net_device *actualdev; /* True Interface (eth0) */
+ struct net_device_stats netstats; /* Net statistics */
+ struct fasync_struct *async_queue; /* For asynchronus notification */
+
+} LINUX_DEP_DATA, *PLINUX_DEP_DATA;
+
+
+struct _LEADER
+{
+ USHORT Vcid;
+ USHORT PLength;
+ UCHAR Status;
+ UCHAR Unused[3];
+}__attribute__((packed));
+typedef struct _LEADER LEADER,*PLEADER;
+
+struct _PACKETTOSEND
+{
+ LEADER Leader;
+ UCHAR ucPayload;
+}__attribute__((packed));
+typedef struct _PACKETTOSEND PACKETTOSEND, *PPACKETTOSEND;
+
+
+struct _CONTROL_PACKET
+{
+ PVOID ControlBuff;
+ UINT ControlBuffLen;
+ struct _CONTROL_PACKET* next;
+}__attribute__((packed));
+typedef struct _CONTROL_PACKET CONTROL_PACKET,*PCONTROL_PACKET;
+
+
+struct link_request
+{
+ LEADER Leader;
+ UCHAR szData[4];
+}__attribute__((packed));
+typedef struct link_request LINK_REQUEST, *PLINK_REQUEST;
+
+
+//classification extension is added
+typedef struct _ADD_CONNECTION
+{
+ ULONG SrcIpAddressCount;
+ ULONG SrcIpAddress[MAX_CONNECTIONS];
+ ULONG SrcIpMask[MAX_CONNECTIONS];
+
+ ULONG DestIpAddressCount;
+ ULONG DestIpAddress[MAX_CONNECTIONS];
+ ULONG DestIpMask[MAX_CONNECTIONS];
+
+ USHORT SrcPortBegin;
+ USHORT SrcPortEnd;
+
+ USHORT DestPortBegin;
+ USHORT DestPortEnd;
+
+ UCHAR SrcTOS;
+ UCHAR SrcProtocol;
+} ADD_CONNECTION,*PADD_CONNECTION;
+
+
+typedef struct _CLASSIFICATION_RULE
+{
+ UCHAR ucIPSrcAddrLen;
+ UCHAR ucIPSrcAddr[32];
+ UCHAR ucIPDestAddrLen;
+ UCHAR ucIPDestAddr[32];
+ UCHAR ucSrcPortRangeLen;
+ UCHAR ucSrcPortRange[4];
+ UCHAR ucDestPortRangeLen;
+ UCHAR ucDestPortRange[4];
+ USHORT usVcid;
+} CLASSIFICATION_RULE,*PCLASSIFICATION_RULE;
+
+typedef struct _CLASSIFICATION_ONLY
+{
+ USHORT usVcid;
+ ULONG DestIpAddress;
+ ULONG DestIpMask;
+ USHORT usPortLo;
+ USHORT usPortHi;
+ BOOLEAN bIpVersion;
+ UCHAR ucDestinationAddress[16];
+} CLASSIFICATION_ONLY, *PCLASSIFICATION_ONLY;
+
+
+#define MAX_IP_RANGE_LENGTH 4
+#define MAX_PORT_RANGE 4
+#define MAX_PROTOCOL_LENGTH 32
+#define IPV6_ADDRESS_SIZEINBYTES 0x10
+
+typedef union _U_IP_ADDRESS
+{
+ struct
+ {
+ ULONG ulIpv4Addr[MAX_IP_RANGE_LENGTH];//Source Ip Address Range
+ ULONG ulIpv4Mask[MAX_IP_RANGE_LENGTH];//Source Ip Mask Address Range
+ };
+ struct
+ {
+ ULONG ulIpv6Addr[MAX_IP_RANGE_LENGTH * 4];//Source Ip Address Range
+ ULONG ulIpv6Mask[MAX_IP_RANGE_LENGTH * 4];//Source Ip Mask Address Range
+
+ };
+ struct
+ {
+ UCHAR ucIpv4Address[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
+ UCHAR ucIpv4Mask[MAX_IP_RANGE_LENGTH * IP_LENGTH_OF_ADDRESS];
+ };
+ struct
+ {
+ UCHAR ucIpv6Address[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
+ UCHAR ucIpv6Mask[MAX_IP_RANGE_LENGTH * IPV6_ADDRESS_SIZEINBYTES];
+ };
+}U_IP_ADDRESS;
+struct _packet_info;
+
+typedef struct _S_HDR_SUPRESSION_CONTEXTINFO
+{
+
+ UCHAR ucaHdrSupressionInBuf[MAX_PHS_LENGTHS]; //Intermediate buffer to accumulate pkt Header for PHS
+ UCHAR ucaHdrSupressionOutBuf[MAX_PHS_LENGTHS + PHSI_LEN]; //Intermediate buffer containing pkt Header after PHS
+
+}S_HDR_SUPRESSION_CONTEXTINFO;
+
+
+typedef struct _S_CLASSIFIER_RULE
+{
+ ULONG ulSFID;
+ UCHAR ucReserved[2];
+ B_UINT16 uiClassifierRuleIndex;
+ BOOLEAN bUsed;
+ USHORT usVCID_Value;
+ B_UINT8 u8ClassifierRulePriority; //This field detemines the Classifier Priority
+ U_IP_ADDRESS stSrcIpAddress;
+ UCHAR ucIPSourceAddressLength;//Ip Source Address Length
+
+ U_IP_ADDRESS stDestIpAddress;
+ UCHAR ucIPDestinationAddressLength;//Ip Destination Address Length
+ UCHAR ucIPTypeOfServiceLength;//Type of service Length
+ UCHAR ucTosLow;//Tos Low
+ UCHAR ucTosHigh;//Tos High
+ UCHAR ucTosMask;//Tos Mask
+
+ UCHAR ucProtocolLength;//protocol Length
+ UCHAR ucProtocol[MAX_PROTOCOL_LENGTH];//protocol Length
+ USHORT usSrcPortRangeLo[MAX_PORT_RANGE];
+ USHORT usSrcPortRangeHi[MAX_PORT_RANGE];
+ UCHAR ucSrcPortRangeLength;
+
+ USHORT usDestPortRangeLo[MAX_PORT_RANGE];
+ USHORT usDestPortRangeHi[MAX_PORT_RANGE];
+ UCHAR ucDestPortRangeLength;
+
+ BOOLEAN bProtocolValid;
+ BOOLEAN bTOSValid;
+ BOOLEAN bDestIpValid;
+ BOOLEAN bSrcIpValid;
+
+ //For IPv6 Addressing
+ UCHAR ucDirection;
+ BOOLEAN bIpv6Protocol;
+ UINT32 u32PHSRuleID;
+ S_PHS_RULE sPhsRule;
+ UCHAR u8AssociatedPHSI;
+
+ //Classification fields for ETH CS
+ UCHAR ucEthCSSrcMACLen;
+ UCHAR au8EThCSSrcMAC[MAC_ADDRESS_SIZE];
+ UCHAR au8EThCSSrcMACMask[MAC_ADDRESS_SIZE];
+ UCHAR ucEthCSDestMACLen;
+ UCHAR au8EThCSDestMAC[MAC_ADDRESS_SIZE];
+ UCHAR au8EThCSDestMACMask[MAC_ADDRESS_SIZE];
+ UCHAR ucEtherTypeLen;
+ UCHAR au8EthCSEtherType[NUM_ETHERTYPE_BYTES];
+ UCHAR usUserPriority[2];
+ USHORT usVLANID;
+ USHORT usValidityBitMap;
+}S_CLASSIFIER_RULE;
+//typedef struct _S_CLASSIFIER_RULE S_CLASSIFIER_RULE;
+
+typedef struct _S_FRAGMENTED_PACKET_INFO
+{
+ BOOLEAN bUsed;
+ ULONG ulSrcIpAddress;
+ USHORT usIpIdentification;
+ S_CLASSIFIER_RULE *pstMatchedClassifierEntry;
+ BOOLEAN bOutOfOrderFragment;
+}S_FRAGMENTED_PACKET_INFO,*PS_FRAGMENTED_PACKET_INFO;
+
+struct _packet_info
+{
+ //classification extension Rule
+ ULONG ulSFID;
+ USHORT usVCID_Value;
+ UINT uiThreshold;
+ // This field determines the priority of the SF Queues
+ B_UINT8 u8TrafficPriority;
+
+ BOOLEAN bValid;
+ BOOLEAN bActive;
+ BOOLEAN bActivateRequestSent;
+
+ B_UINT8 u8QueueType;//BE or rtPS
+
+ UINT uiMaxBucketSize;//maximum size of the bucket for the queue
+ UINT uiCurrentQueueDepthOnTarget;
+ UINT uiCurrentBytesOnHost;
+ UINT uiCurrentPacketsOnHost;
+ UINT uiDroppedCountBytes;
+ UINT uiDroppedCountPackets;
+ UINT uiSentBytes;
+ UINT uiSentPackets;
+ UINT uiCurrentDrainRate;
+ UINT uiThisPeriodSentBytes;
+ LARGE_INTEGER liDrainCalculated;
+ UINT uiCurrentTokenCount;
+ LARGE_INTEGER liLastUpdateTokenAt;
+ UINT uiMaxAllowedRate;
+ UINT NumOfPacketsSent;
+ UCHAR ucDirection;
+ USHORT usCID;
+ S_MIBS_EXTSERVICEFLOW_PARAMETERS stMibsExtServiceFlowTable;
+ UINT uiCurrentRxRate;
+ UINT uiThisPeriodRxBytes;
+ UINT uiTotalRxBytes;
+ UINT uiTotalTxBytes;
+ UINT uiPendedLast;
+ UCHAR ucIpVersion;
+
+ union
+ {
+ struct
+ {
+ struct sk_buff* FirstTxQueue;
+ struct sk_buff* LastTxQueue;
+ };
+ struct
+ {
+ struct sk_buff* ControlHead;
+ struct sk_buff* ControlTail;
+ };
+ };
+ BOOLEAN bProtocolValid;
+ BOOLEAN bTOSValid;
+ BOOLEAN bDestIpValid;
+ BOOLEAN bSrcIpValid;
+
+ BOOLEAN bActiveSet;
+ BOOLEAN bAdmittedSet;
+ BOOLEAN bAuthorizedSet;
+ BOOLEAN bClassifierPriority;
+ UCHAR ucServiceClassName[MAX_CLASS_NAME_LENGTH];
+ BOOLEAN bHeaderSuppressionEnabled;
+ spinlock_t SFQueueLock;
+ void *pstSFIndication;
+ struct timeval stLastUpdateTokenAt;
+ atomic_t uiPerSFTxResourceCount;
+ UINT uiMaxLatency;
+ UCHAR bIPCSSupport;
+ UCHAR bEthCSSupport;
+};
+typedef struct _packet_info PacketInfo;
+
+
+typedef struct _PER_TARANG_DATA
+{
+ struct _PER_TARANG_DATA * next;
+ struct _MINI_ADAPTER * Adapter;
+ struct sk_buff* RxAppControlHead;
+ struct sk_buff* RxAppControlTail;
+ volatile INT AppCtrlQueueLen;
+ BOOLEAN MacTracingEnabled;
+ BOOLEAN bApplicationToExit;
+ S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs;
+ ULONG RxCntrlMsgBitMask;
+} PER_TARANG_DATA, *PPER_TARANG_DATA;
+
+
+#ifdef REL_4_1
+typedef struct _TARGET_PARAMS
+{
+ B_UINT32 m_u32CfgVersion;
+
+ // Scanning Related Params
+ B_UINT32 m_u32CenterFrequency;
+ B_UINT32 m_u32BandAScan;
+ B_UINT32 m_u32BandBScan;
+ B_UINT32 m_u32BandCScan;
+
+ // QoS Params
+ B_UINT32 m_u32minGrantsize; // size of minimum grant is 0 or 6
+ B_UINT32 m_u32PHSEnable;
+
+ // HO Params
+ B_UINT32 m_u32HoEnable;
+ B_UINT32 m_u32HoReserved1;
+ B_UINT32 m_u32HoReserved2;
+
+ // Power Control Params
+ B_UINT32 m_u32MimoEnable;
+ B_UINT32 m_u32SecurityEnable;
+ /*
+ * bit 1: 1 Idlemode enable;
+ * bit 2: 1 Sleepmode Enable
+ */
+ B_UINT32 m_u32PowerSavingModesEnable;
+ /* PowerSaving Mode Options:
+ bit 0 = 1: CPE mode - to keep pcmcia if alive;
+ bit 1 = 1: CINR reporing in Idlemode Msg
+ bit 2 = 1: Default PSC Enable in sleepmode*/
+ B_UINT32 m_u32PowerSavingModeOptions;
+
+ B_UINT32 m_u32ArqEnable;
+
+ // From Version #3, the HARQ section renamed as general
+ B_UINT32 m_u32HarqEnable;
+ // EEPROM Param Location
+ B_UINT32 m_u32EEPROMFlag;
+ /* BINARY TYPE - 4th MSByte:
+ * Interface Type - 3rd MSByte:
+ * Vendor Type - 2nd MSByte
+ */
+ // Unused - LSByte
+ B_UINT32 m_u32Customize;
+ B_UINT32 m_u32ConfigBW; /* In Hz */
+ B_UINT32 m_u32ShutDownTimer;
+
+
+ B_UINT32 m_u32RadioParameter;
+ B_UINT32 m_u32PhyParameter1;
+ B_UINT32 m_u32PhyParameter2;
+ B_UINT32 m_u32PhyParameter3;
+
+ /* in eval mode only;
+ * lower 16bits = basic cid for testing;
+ * then bit 16 is test cqich,
+ * bit 17 test init rang;
+ * bit 18 test periodic rang
+ * bit 19 is test harq ack/nack
+ */
+ B_UINT32 m_u32TestOptions;
+
+ B_UINT32 m_u32MaxMACDataperDLFrame;
+ B_UINT32 m_u32MaxMACDataperULFrame;
+
+ B_UINT32 m_u32Corr2MacFlags;
+
+ //adding driver params.
+ B_UINT32 HostDrvrConfig1;
+ B_UINT32 HostDrvrConfig2;
+ B_UINT32 HostDrvrConfig3;
+ B_UINT32 HostDrvrConfig4;
+ B_UINT32 HostDrvrConfig5;
+ B_UINT32 HostDrvrConfig6;
+ B_UINT32 m_u32SegmentedPUSCenable;
+
+ // BAMC enable - but 4.x does not support this feature
+ // This is added just to sync 4.x and 5.x CFGs
+ B_UINT32 m_u32BandAMCEnable;
+} STARGETPARAMS, *PSTARGETPARAMS;
+#endif
+
+typedef struct _STTARGETDSXBUFFER
+{
+ ULONG ulTargetDsxBuffer;
+ B_UINT16 tid;
+ BOOLEAN valid;
+}STTARGETDSXBUFFER, *PSTTARGETDSXBUFFER;
+
+typedef INT (*FP_FLASH_WRITE)(struct _MINI_ADAPTER*,UINT,PVOID);
+
+typedef INT (*FP_FLASH_WRITE_STATUS)(struct _MINI_ADAPTER*,UINT,PVOID);
+
+/**
+Driver adapter data structure
+*/
+struct _MINI_ADAPTER
+{
+ struct _MINI_ADAPTER *next;
+ PVOID pvOsDepData;
+ CHAR *caDsxReqResp;
+ atomic_t ApplicationRunning;
+ volatile INT CtrlQueueLen;
+ atomic_t AppCtrlQueueLen;
+ BOOLEAN AppCtrlQueueOverFlow;
+ atomic_t CurrentApplicationCount;
+ atomic_t RegisteredApplicationCount;
+ BOOLEAN TimerActive;
+ ULONG StatisticsPointer;
+ struct sk_buff *RxControlHead;
+ struct sk_buff *RxControlTail;
+// spinlock_t RxControlQueuelock;
+ struct semaphore RxAppControlQueuelock;
+ struct semaphore fw_download_sema;
+
+ PPER_TARANG_DATA pTarangs;
+ spinlock_t control_queue_lock;
+ wait_queue_head_t process_read_wait_queue;
+ ULONG bcm_jiffies; /* Store Jiffies value */
+
+ // the pointer to the first packet we have queued in send
+ // deserialized miniport support variables
+ atomic_t TotalPacketCount;
+ atomic_t TxPktAvail;
+
+ // this to keep track of the Tx and Rx MailBox Registers.
+ atomic_t CurrNumFreeTxDesc;
+ // to keep track the no of byte recieved
+ atomic_t RxRollOverCount;
+ USHORT PrevNumRecvDescs;
+ USHORT CurrNumRecvDescs;
+ atomic_t GoodRxByteCount;
+ atomic_t GoodRxPktCount;
+ atomic_t BadRxByteCount;
+ atomic_t RxPacketDroppedCount;
+ atomic_t GoodTxByteCount;
+ atomic_t TxTotalPacketCount;
+ atomic_t TxDroppedPacketCount;
+ ULONG LinkUpStatus;
+ BOOLEAN TransferMode;
+ UINT u32TotalDSD;
+ PacketInfo PackInfo[NO_OF_QUEUES];
+ S_CLASSIFIER_RULE astClassifierTable[MAX_CLASSIFIERS];
+
+ /*************** qos ******************/
+ UINT bETHCSEnabled;
+
+ ULONG BEBucketSize;
+ ULONG rtPSBucketSize;
+ UCHAR LinkStatus;
+ BOOLEAN AutoLinkUp;
+ BOOLEAN AutoSyncup;
+
+ struct net_device *dev;
+ UINT major;
+ UINT minor;
+ wait_queue_head_t tx_packet_wait_queue;
+ wait_queue_head_t process_rx_cntrlpkt;
+ atomic_t process_waiting;
+ BOOLEAN fw_download_done;
+
+ unsigned int ctrlpkt_present;
+ BOOLEAN packets_given_to_all;
+ char *txctlpacket[MAX_CNTRL_PKTS];
+ atomic_t cntrlpktCnt ;
+ atomic_t index_app_read_cntrlpkt;
+ atomic_t index_wr_txcntrlpkt;
+ atomic_t index_rd_txcntrlpkt;
+ UINT index_datpkt;
+ struct semaphore rdmwrmsync;
+
+ STTARGETDSXBUFFER astTargetDsxBuffer[MAX_TARGET_DSX_BUFFERS];
+ ULONG ulFreeTargetBufferCnt;
+ ULONG ulCurrentTargetBuffer;
+ ULONG ulTotalTargetBuffersAvailable;
+ unsigned int timeout;
+ int irq;
+ unsigned long chip_id;
+ unsigned int bFlashBoot;
+ unsigned int if_up;
+// spinlock_t sleeper_lock;
+ atomic_t rdm_wrm_access;
+ atomic_t tx_rx_access;
+ wait_queue_head_t lowpower_mode_wait_queue;
+ atomic_t bAbortedByHost;
+ BOOLEAN bBinDownloaded;
+ BOOLEAN bCfgDownloaded;
+ USHORT usBestEffortQueueIndex;
+ BOOLEAN bSyncUpRequestSent;
+// struct semaphore data_packet_queue_lock;
+ wait_queue_head_t ioctl_fw_dnld_wait_queue;
+ BOOLEAN waiting_to_fw_download_done;
+ pid_t fw_download_process_pid;
+ PSTARGETPARAMS pstargetparams;
+ BOOLEAN device_removed;
+ BOOLEAN DeviceAccess;
+ INT DDRSetting;
+ BOOLEAN bDDRInitDone;
+ ULONG ulPowerSaveMode;
+ BOOLEAN bIsAutoCorrectEnabled;
+ spinlock_t txtransmitlock;
+ B_UINT8 txtransmit_running;
+ /* Thread for control packet handling */
+ struct task_struct *control_packet_handler;
+ /* thread for transmitting packets. */
+ struct task_struct *transmit_packet_thread;
+
+ /* LED Related Structures */
+ LED_INFO_STRUCT LEDInfo;
+
+ /* Driver State for LED Blinking */
+ LedEventInfo_t DriverState;
+ /* Interface Specific */
+ PVOID pvInterfaceAdapter;
+ int (*bcm_file_download)( PVOID,
+ struct file *,
+ unsigned int);
+ int (*bcm_file_readback_from_chip)( PVOID,
+ struct file *,
+ unsigned int);
+ INT (*interface_rdm)(PVOID,
+ UINT ,
+ PVOID ,
+ INT);
+ INT (*interface_wrm)(PVOID,
+ UINT ,
+ PVOID ,
+ INT);
+ int (*interface_transmit)(PVOID, PVOID , UINT);
+ BOOLEAN IdleMode;
+ BOOLEAN bDregRequestSentInIdleMode;
+ BOOLEAN bTriedToWakeUpFromlowPowerMode;
+ BOOLEAN bShutStatus;
+ BOOLEAN bWakeUpDevice;
+ unsigned int usIdleModePattern;
+ //BOOLEAN bTriedToWakeUpFromShutdown;
+ BOOLEAN bLinkDownRequested;
+ unsigned int check_for_hang;
+ int downloadDDR;
+ PHS_DEVICE_EXTENSION stBCMPhsContext;
+ S_HDR_SUPRESSION_CONTEXTINFO stPhsTxContextInfo;
+ uint8_t ucaPHSPktRestoreBuf[2048];
+ uint8_t bPHSEnabled;
+ int AutoFirmDld;
+ BOOLEAN bMipsConfig;
+ BOOLEAN bDPLLConfig;
+ UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
+ UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
+ S_FRAGMENTED_PACKET_INFO astFragmentedPktClassifierTable[MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES];
+ atomic_t uiMBupdate;
+ UINT32 PmuMode;
+ NVM_TYPE eNVMType;
+ UINT uiSectorSize;
+ UINT uiSectorSizeInCFG;
+ BOOLEAN bSectorSizeOverride;
+ BOOLEAN bStatusWrite;
+ UINT uiNVMDSDSize;
+ UINT uiVendorExtnFlag;
+ //it will always represent choosed DSD at any point of time.
+ // Generally it is Active DSD but in case of NVM RD/WR it might be different.
+ UINT ulFlashCalStart;
+ ULONG ulFlashControlSectionStart;
+ ULONG ulFlashWriteSize;
+ ULONG ulFlashID;
+ FP_FLASH_WRITE fpFlashWrite;
+ FP_FLASH_WRITE_STATUS fpFlashWriteWithStatusCheck;
+
+
+ struct semaphore NVMRdmWrmLock;
+ BOOLEAN bNetworkInterfaceRegistered;
+ BOOLEAN bNetdeviceNotifierRegistered;
+ struct device *pstCreatedClassDevice;
+ BOOLEAN bUsbClassDriverRegistered;
+// BOOLEAN InterfaceUpStatus;
+ PFLASH2X_CS_INFO psFlash2xCSInfo;
+ PFLASH_CS_INFO psFlashCSInfo ;
+ PFLASH2X_VENDORSPECIFIC_INFO psFlash2xVendorInfo;
+ UINT uiFlashBaseAdd; //Flash start address
+ UINT uiActiveISOOffset; //Active ISO offset choosen before f/w download
+ FLASH2X_SECTION_VAL eActiveISO; //Active ISO section val
+ FLASH2X_SECTION_VAL eActiveDSD; //Active DSD val choosen before f/w download
+ UINT uiActiveDSDOffsetAtFwDld; //For accessing Active DSD choosen before f/w download
+ UINT uiFlashLayoutMajorVersion ;
+ UINT uiFlashLayoutMinorVersion;
+ BOOLEAN bAllDSDWriteAllow ;
+ BOOLEAN bSigCorrupted ;
+ //this should be set who so ever want to change the Headers. after Wrtie it should be reset immediately.
+ BOOLEAN bHeaderChangeAllowed ;
+ INT SelectedChip ;
+ BOOLEAN bEndPointHalted;
+ //while bFlashRawRead will be true, Driver ignore map lay out and consider flash as of without any map.
+ BOOLEAN bFlashRawRead;
+ BOOLEAN bPreparingForLowPowerMode ;
+ BOOLEAN bDoSuspend ;
+ UINT syscfgBefFwDld ;
+ BOOLEAN StopAllXaction ;
+ UINT32 liTimeSinceLastNetEntry; //Used to Support extended CAPI requirements from
+ struct semaphore LowPowerModeSync;
+ ULONG liDrainCalculated;
+ UINT gpioBitMap;
+ S_BCM_DEBUG_STATE stDebugState;
+
+};
+typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER;
+
+
+typedef struct _DEVICE_EXTENSION
+{
+ PMINI_ADAPTER pAdapt;
+}DEVICE_EXTENSION,*PDEVICE_EXTENSION;
+
+
+struct _ETH_HEADER_STRUC {
+ UCHAR au8DestinationAddress[6];
+ UCHAR au8SourceAddress[6];
+ USHORT u16Etype;
+}__attribute__((packed));
+typedef struct _ETH_HEADER_STRUC ETH_HEADER_STRUC, *PETH_HEADER_STRUC;
+
+
+typedef struct FirmwareInfo
+{
+ PVOID pvMappedFirmwareAddress;
+ ULONG u32FirmwareLength;
+ ULONG u32StartingAddress;
+}__attribute__((packed)) FIRMWARE_INFO, *PFIRMWARE_INFO;
+
+// holds the value of net_device structure..
+extern struct net_device *gblpnetdev;
+typedef struct _cntl_pkt{
+ PMINI_ADAPTER Adapter;
+ PLEADER PLeader;
+}cntl_pkt;
+typedef LINK_REQUEST CONTROL_MESSAGE;
+
+typedef struct _DDR_SETTING
+{
+ ULONG ulRegAddress;
+ ULONG ulRegValue;
+}DDR_SETTING, *PDDR_SETTING;
+typedef DDR_SETTING DDR_SET_NODE, *PDDR_SET_NODE;
+INT
+InitAdapter(PMINI_ADAPTER psAdapter);
+
+// =====================================================================
+// Beceem vendor request codes for EP0
+// =====================================================================
+
+#define BCM_REQUEST_READ 0x2
+#define BCM_REQUEST_WRITE 0x1
+#define EP2_MPS_REG 0x0F0110A0
+#define EP2_MPS 0x40
+
+#define EP2_CFG_REG 0x0F0110A8
+#define EP2_CFG_INT 0x27
+#define EP2_CFG_BULK 0x25
+
+#define EP4_MPS_REG 0x0F0110F0
+#define EP4_MPS 0x8C
+
+#define EP4_CFG_REG 0x0F0110F8
+
+#define ISO_MPS_REG 0x0F0110C8
+#define ISO_MPS 0x00000000
+
+
+#define EP1 0
+#define EP2 1
+#define EP3 2
+#define EP4 3
+#define EP5 4
+#define EP6 5
+
+
+typedef enum eInterface_setting
+{
+ DEFAULT_SETTING_0 = 0,
+ ALTERNATE_SETTING_1 = 1,
+}INTERFACE_SETTING;
+
+#endif //__ADAPTER_H__
+
diff --git a/drivers/staging/bcm/Arp.c b/drivers/staging/bcm/Arp.c
new file mode 100644
index 00000000000..d60d8593d2e
--- /dev/null
+++ b/drivers/staging/bcm/Arp.c
@@ -0,0 +1,94 @@
+
+/*
+ * File Name: Arp.c
+ * Abstract: This file contains the routines for handling ARP PACKETS
+ */
+#include "headers.h"
+#define ARP_PKT_SIZE 60
+
+/* =========================================================================
+ * Function - reply_to_arp_request()
+ *
+ * Description - When this host tries to broadcast ARP request packet through
+ * the virtual interface (veth0), reply directly to upper layer.
+ * This function allocates a new skb for ARP reply packet,
+ * fills in the fields of the packet and then sends it to
+ * upper layer.
+ *
+ * Parameters - skb: Pointer to sk_buff structure of the ARP request pkt.
+ *
+ * Returns - None
+ * =========================================================================*/
+
+VOID
+reply_to_arp_request(struct sk_buff *skb)
+{
+ PMINI_ADAPTER Adapter;
+ struct ArpHeader *pArpHdr = NULL;
+ struct ethhdr *pethhdr = NULL;
+ UCHAR uiIPHdr[4];
+ /* Check for valid skb */
+ if(skb == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid skb: Cannot reply to ARP request\n");
+ return;
+ }
+
+
+ Adapter = GET_BCM_ADAPTER(skb->dev);
+ /* Print the ARP Request Packet */
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP Packet Dump :");
+ BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len);
+
+ /*
+ * Extract the Ethernet Header and Arp Payload including Header
+ */
+ pethhdr = (struct ethhdr *)skb->data;
+ pArpHdr = (struct ArpHeader *)(skb->data+ETH_HLEN);
+
+ if(Adapter->bETHCSEnabled)
+ {
+ if(memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN))
+ {
+ bcm_kfree_skb(skb);
+ return;
+ }
+ }
+
+ // Set the Ethernet Header First.
+ memcpy(pethhdr->h_dest, pethhdr->h_source, ETH_ALEN);
+ if(!memcmp(pethhdr->h_source, Adapter->dev->dev_addr, ETH_ALEN))
+ {
+ pethhdr->h_source[5]++;
+ }
+
+ /* Set the reply to ARP Reply */
+ pArpHdr->arp.ar_op = ntohs(ARPOP_REPLY);
+
+ /* Set the HW Address properly */
+ memcpy(pArpHdr->ar_sha, pethhdr->h_source, ETH_ALEN);
+ memcpy(pArpHdr->ar_tha, pethhdr->h_dest, ETH_ALEN);
+
+ // Swapping the IP Adddress
+ memcpy(uiIPHdr,pArpHdr->ar_sip,4);
+ memcpy(pArpHdr->ar_sip,pArpHdr->ar_tip,4);
+ memcpy(pArpHdr->ar_tip,uiIPHdr,4);
+
+ /* Print the ARP Reply Packet */
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "ARP REPLY PACKET: ");
+
+ /* Send the Packet to upper layer */
+ BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, (PUCHAR)(skb->data), skb->len);
+
+ skb->protocol = eth_type_trans(skb,skb->dev);
+ skb->pkt_type = PACKET_HOST;
+
+// skb->mac.raw=skb->data+LEADER_SIZE;
+ skb_set_mac_header (skb, LEADER_SIZE);
+ netif_rx(skb);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, ARP_RESP, DBG_LVL_ALL, "<=============\n");
+ return;
+}
+
+
diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
new file mode 100644
index 00000000000..489487a6edb
--- /dev/null
+++ b/drivers/staging/bcm/Bcmchar.c
@@ -0,0 +1,2420 @@
+#include "headers.h"
+/***************************************************************
+* Function - bcm_char_open()
+*
+* Description - This is the "open" entry point for the character
+* driver.
+*
+* Parameters - inode: Pointer to the Inode structure of char device
+* filp : File pointer of the char device
+*
+* Returns - Zero(Success)
+****************************************************************/
+static struct class *bcm_class = NULL;
+static int bcm_char_open(struct inode *inode, struct file * filp)
+{
+ PMINI_ADAPTER Adapter = NULL;
+ PPER_TARANG_DATA pTarang = NULL;
+
+ Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ pTarang = (PPER_TARANG_DATA)kmalloc(sizeof(PER_TARANG_DATA), GFP_KERNEL);
+ if (!pTarang)
+ return -ENOMEM;
+
+ memset (pTarang, 0, sizeof(PER_TARANG_DATA));
+ pTarang->Adapter = Adapter;
+ pTarang->RxCntrlMsgBitMask = 0xFFFFFFFF & ~(1 << 0xB) ;
+
+ down(&Adapter->RxAppControlQueuelock);
+ pTarang->next = Adapter->pTarangs;
+ Adapter->pTarangs = pTarang;
+ up(&Adapter->RxAppControlQueuelock);
+
+ /* Store the Adapter structure */
+ filp->private_data = pTarang;
+
+ /*Start Queuing the control response Packets*/
+ atomic_inc(&Adapter->ApplicationRunning);
+ return 0;
+}
+static int bcm_char_release(struct inode *inode, struct file *filp)
+{
+ PPER_TARANG_DATA pTarang, tmp, ptmp;
+ PMINI_ADAPTER Adapter=NULL;
+ struct sk_buff * pkt, * npkt;
+
+ pTarang = (PPER_TARANG_DATA)filp->private_data;
+
+ if(pTarang == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ptarang is null\n");
+ return 0;
+ }
+
+ Adapter = pTarang->Adapter;
+
+ down( &Adapter->RxAppControlQueuelock);
+
+ tmp = Adapter->pTarangs;
+ for ( ptmp = NULL; tmp; ptmp = tmp, tmp = tmp->next )
+ {
+ if ( tmp == pTarang )
+ break;
+ }
+
+ if ( tmp )
+ {
+ if ( !ptmp )
+ Adapter->pTarangs = tmp->next;
+ else
+ ptmp->next = tmp->next;
+ }
+
+ else
+ {
+ up( &Adapter->RxAppControlQueuelock);
+ return 0;
+ }
+
+ pkt = pTarang->RxAppControlHead;
+ while ( pkt )
+ {
+ npkt = pkt->next;
+ kfree_skb(pkt);
+ pkt = npkt;
+ }
+
+ up( &Adapter->RxAppControlQueuelock);
+
+ /*Stop Queuing the control response Packets*/
+ atomic_dec(&Adapter->ApplicationRunning);
+
+ bcm_kfree(pTarang);
+
+ /* remove this filp from the asynchronously notified filp's */
+ filp->private_data = NULL;
+ return 0;
+}
+
+static int bcm_char_read(struct file *filp, PCHAR buf, size_t size, loff_t *f_pos)
+{
+ PPER_TARANG_DATA pTarang = (PPER_TARANG_DATA)filp->private_data;
+ PMINI_ADAPTER Adapter = pTarang->Adapter;
+ struct sk_buff* Packet = NULL;
+ UINT PktLen = 0;
+ int wait_ret_val=0;
+
+ wait_ret_val = wait_event_interruptible(Adapter->process_read_wait_queue,
+ (pTarang->RxAppControlHead || Adapter->device_removed));
+ if((wait_ret_val == -ERESTARTSYS))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Exiting as i've been asked to exit!!!\n");
+ return wait_ret_val;
+ }
+
+ if(Adapter->device_removed)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Device Removed... Killing the Apps...\n");
+ return -ENODEV;
+ }
+
+ if(FALSE == Adapter->fw_download_done)
+ return -EACCES;
+
+ down( &Adapter->RxAppControlQueuelock);
+
+ if(pTarang->RxAppControlHead)
+ {
+ Packet = pTarang->RxAppControlHead;
+ DEQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail);
+ pTarang->AppCtrlQueueLen--;
+ }
+
+ up(&Adapter->RxAppControlQueuelock);
+
+ if(Packet)
+ {
+ PktLen = Packet->len;
+ if(copy_to_user(buf, Packet->data, PktLen))
+ {
+ bcm_kfree_skb(Packet);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\nReturning from copy to user failure \n");
+ return -EFAULT;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Read %d Bytes From Adapter packet = 0x%p by process %d!\n", PktLen, Packet, current->pid);
+ bcm_kfree_skb(Packet);
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "<====\n");
+ return PktLen;
+}
+
+static INT bcm_char_ioctl(struct inode *inode, struct file *filp,
+ UINT cmd, ULONG arg)
+{
+ PPER_TARANG_DATA pTarang = (PPER_TARANG_DATA)filp->private_data;
+ PMINI_ADAPTER Adapter = pTarang->Adapter;
+ INT Status = STATUS_FAILURE;
+ IOCTL_BUFFER IoBuffer={0};
+#ifndef BCM_SHM_INTERFACE
+ int timeout = 0;
+#endif
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Parameters Passed to control IOCTL cmd=0x%X arg=0x%lX", cmd, arg);
+
+ if(_IOC_TYPE(cmd) != BCM_IOCTL)
+ return -EFAULT;
+ if(_IOC_DIR(cmd) & _IOC_READ)
+ Status = !access_ok(VERIFY_WRITE, (PVOID)arg, _IOC_SIZE(cmd));
+ else if (_IOC_DIR(cmd) & _IOC_WRITE)
+ Status = !access_ok(VERIFY_READ, (PVOID)arg, _IOC_SIZE(cmd));
+ else if (_IOC_NONE == (_IOC_DIR(cmd) & _IOC_NONE))
+ Status = STATUS_SUCCESS;
+
+ if(Status)
+ return -EFAULT;
+
+ if(Adapter->device_removed)
+ {
+ return -EFAULT;
+ }
+
+ if(FALSE == Adapter->fw_download_done)
+ {
+ switch (cmd)
+ {
+ case IOCTL_MAC_ADDR_REQ:
+ case IOCTL_LINK_REQ:
+ case IOCTL_CM_REQUEST:
+ case IOCTL_SS_INFO_REQ:
+ case IOCTL_SEND_CONTROL_MESSAGE:
+ case IOCTL_IDLE_REQ:
+ case IOCTL_BCM_GPIO_SET_REQUEST:
+ case IOCTL_BCM_GPIO_STATUS_REQUEST:
+ return -EACCES;
+ default:
+ break;
+ }
+ }
+
+ Status = vendorextnIoctl(Adapter, cmd, arg);
+ if(Status != CONTINUE_COMMON_PATH )
+ {
+ return Status;
+ }
+
+ switch(cmd){
+ // Rdms for Swin Idle...
+ case IOCTL_BCM_REGISTER_READ_PRIVATE:
+ {
+ RDM_BUFFER sRdmBuffer = {0};
+ PCHAR temp_buff = NULL;
+ UINT Bufflen = 0;
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg,
+ sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+
+ Bufflen = IoBuffer.OutputLength + (4 - IoBuffer.OutputLength%4)%4;
+ temp_buff = (PCHAR)kmalloc(Bufflen, GFP_KERNEL);
+ if(!temp_buff)
+ {
+ return STATUS_FAILURE;
+ }
+ if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer,
+ IoBuffer.InputLength))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ Status = rdmalt(Adapter, (UINT)sRdmBuffer.Register,
+ (PUINT)temp_buff, Bufflen);
+ if(Status != STATUS_SUCCESS)
+ {
+ bcm_kfree(temp_buff);
+ return Status;
+ }
+ if(copy_to_user((PCHAR)IoBuffer.OutputBuffer,
+ (PCHAR)temp_buff, (UINT)IoBuffer.OutputLength))
+ {
+ Status = -EFAULT;
+ }
+ bcm_kfree(temp_buff);
+ break;
+ }
+ case IOCTL_BCM_REGISTER_WRITE_PRIVATE:
+ {
+ WRM_BUFFER sWrmBuffer = {0};
+ UINT uiTempVar=0;
+ /* Copy Ioctl Buffer structure */
+
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg,
+ sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ /* Get WrmBuffer structure */
+ if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer,
+ IoBuffer.InputLength))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK;
+ if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) &&
+ ((uiTempVar == EEPROM_REJECT_REG_1)||
+ (uiTempVar == EEPROM_REJECT_REG_2) ||
+ (uiTempVar == EEPROM_REJECT_REG_3) ||
+ (uiTempVar == EEPROM_REJECT_REG_4)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n");
+ Status = -EFAULT;
+ break;
+ }
+ Status = wrmalt(Adapter, (UINT)sWrmBuffer.Register,
+ (PUINT)sWrmBuffer.Data, sizeof(ULONG));
+ if(Status == STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"WRM Done\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n");
+ Status = -EFAULT;
+ }
+ break;
+ }
+
+ case IOCTL_BCM_REGISTER_READ:
+ case IOCTL_BCM_EEPROM_REGISTER_READ:
+ {
+ RDM_BUFFER sRdmBuffer = {0};
+ PCHAR temp_buff = NULL;
+ UINT uiTempVar = 0;
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Rdms\n");
+ Status = -EACCES;
+ break;
+ }
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg,
+ sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+
+ temp_buff = (PCHAR)kmalloc(IoBuffer.OutputLength, GFP_KERNEL);
+ if(!temp_buff)
+ {
+ return STATUS_FAILURE;
+ }
+ if(copy_from_user(&sRdmBuffer, IoBuffer.InputBuffer,
+ IoBuffer.InputLength))
+ {
+ Status = -EFAULT;
+ break;
+ }
+
+ if(
+#if !defined(BCM_SHM_INTERFACE)
+ (((ULONG)sRdmBuffer.Register & 0x0F000000) != 0x0F000000) ||
+#endif
+ ((ULONG)sRdmBuffer.Register & 0x3)
+ )
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Done On invalid Address : %x Access Denied.\n",
+ (int)sRdmBuffer.Register);
+ Status = -EINVAL;
+ break;
+ }
+
+ uiTempVar = sRdmBuffer.Register & EEPROM_REJECT_MASK;
+ Status = rdmaltWithLock(Adapter, (UINT)sRdmBuffer.Register,
+ (PUINT)temp_buff, IoBuffer.OutputLength);
+ if(Status != STATUS_SUCCESS)
+ {
+ bcm_kfree(temp_buff);
+ return Status;
+ }
+ if(copy_to_user((PCHAR)IoBuffer.OutputBuffer,
+ (PCHAR)temp_buff, (UINT)IoBuffer.OutputLength))
+ {
+ Status = -EFAULT;
+ }
+ bcm_kfree(temp_buff);
+ break;
+ }
+ case IOCTL_BCM_REGISTER_WRITE:
+ case IOCTL_BCM_EEPROM_REGISTER_WRITE:
+ {
+ WRM_BUFFER sWrmBuffer = {0};
+ UINT uiTempVar=0;
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Device in Idle Mode, Blocking Wrms\n");
+ Status = -EACCES;
+ break;
+ }
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg,
+ sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ /* Get WrmBuffer structure */
+ if(copy_from_user(&sWrmBuffer, IoBuffer.InputBuffer,
+ IoBuffer.InputLength))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ if(
+#if !defined(BCM_SHM_INTERFACE)
+
+ (((ULONG)sWrmBuffer.Register & 0x0F000000) != 0x0F000000) ||
+#endif
+ ((ULONG)sWrmBuffer.Register & 0x3)
+ )
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Done On invalid Address : %x Access Denied.\n",
+ (int)sWrmBuffer.Register);
+ Status = -EINVAL;
+ break;
+ }
+ uiTempVar = sWrmBuffer.Register & EEPROM_REJECT_MASK;
+ if(!((Adapter->pstargetparams->m_u32Customize) & VSG_MODE) &&
+ ((uiTempVar == EEPROM_REJECT_REG_1)||
+ (uiTempVar == EEPROM_REJECT_REG_2) ||
+ (uiTempVar == EEPROM_REJECT_REG_3) ||
+ (uiTempVar == EEPROM_REJECT_REG_4)) &&
+ (cmd == IOCTL_BCM_REGISTER_WRITE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "EEPROM Access Denied, not in VSG Mode\n");
+ Status = -EFAULT;
+ break;
+ }
+
+ Status = wrmaltWithLock(Adapter, (UINT)sWrmBuffer.Register,
+ (PUINT)sWrmBuffer.Data, sWrmBuffer.Length);
+ if(Status == STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "WRM Done\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM Failed\n");
+ Status = -EFAULT;
+ }
+ break;
+ }
+ case IOCTL_BCM_GPIO_SET_REQUEST:
+ {
+ UCHAR ucResetValue[4];
+ UINT value =0;
+ UINT uiBit = 0;
+ UINT uiOperation = 0;
+
+ GPIO_INFO gpio_info = {0};
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode");
+ Status = -EACCES;
+ break;
+ }
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ uiBit = gpio_info.uiGpioNumber;
+ uiOperation = gpio_info.uiGpioValue;
+
+ value= (1<<uiBit);
+
+ if(IsReqGpioIsLedInNVM(Adapter,value) ==FALSE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to LED !!!",value);
+ Status = -EINVAL;
+ break;
+ }
+
+
+ if(uiOperation)//Set - setting 1
+ {
+ //Set the gpio output register
+ Status = wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_SET_REG ,
+ (PUINT)(&value), sizeof(UINT));
+ if(Status == STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Set the GPIO bit\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Failed to set the %dth GPIO \n",uiBit);
+ break;
+ }
+ }
+ else//Unset - setting 0
+ {
+ //Set the gpio output register
+ Status = wrmaltWithLock(Adapter,BCM_GPIO_OUTPUT_CLR_REG ,
+ (PUINT)(&value), sizeof(UINT));
+ if(Status == STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Set the GPIO bit\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Failed to clear the %dth GPIO \n",uiBit);
+ break;
+ }
+ }
+
+ Status = rdmaltWithLock(Adapter, (UINT)GPIO_MODE_REGISTER,
+ (PUINT)ucResetValue, sizeof(UINT));
+ if (STATUS_SUCCESS != Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO_MODE_REGISTER read failed");
+ break;
+ }
+ //Set the gpio mode register to output
+ *(UINT*)ucResetValue |= (1<<uiBit);
+ Status = wrmaltWithLock(Adapter,GPIO_MODE_REGISTER ,
+ (PUINT)ucResetValue, sizeof(UINT));
+ if(Status == STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Set the GPIO to output Mode\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Failed to put GPIO in Output Mode\n");
+ break;
+ }
+ }
+ break;
+ case BCM_LED_THREAD_STATE_CHANGE_REQ:
+ {
+
+ USER_THREAD_REQ threadReq = {0};
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"User made LED thread InActive");
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"GPIO Can't be set/clear in Low power Mode");
+ Status = -EACCES;
+ break;
+ }
+ Status =copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status);
+ break;
+ }
+
+ Status= copy_from_user(&threadReq, IoBuffer.InputBuffer, IoBuffer.InputLength);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the InputBuffer from user space err:%d",Status);
+ break;
+ }
+ //if LED thread is running(Actively or Inactively) set it state to make inactive
+ if(Adapter->LEDInfo.led_thread_running)
+ {
+ if(threadReq.ThreadState == LED_THREAD_ACTIVATION_REQ)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Activating thread req");
+ Adapter->DriverState = LED_THREAD_ACTIVE;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DeActivating Thread req.....");
+ Adapter->DriverState = LED_THREAD_INACTIVE;
+ }
+
+ //signal thread.
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+
+ }
+ }
+ break;
+ case IOCTL_BCM_GPIO_STATUS_REQUEST:
+ {
+ ULONG uiBit = 0;
+ UCHAR ucRead[4];
+ GPIO_INFO gpio_info = {0};
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ Status = -EACCES;
+ break;
+ }
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ if(copy_from_user(&gpio_info, IoBuffer.InputBuffer, IoBuffer.InputLength))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ uiBit = gpio_info.uiGpioNumber;
+ //Set the gpio output register
+ Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER,
+ (PUINT)ucRead, sizeof(UINT));
+ if(Status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "RDM Failed\n");
+ return Status;
+ }
+
+ }
+ break;
+ case IOCTL_BCM_GPIO_MULTI_REQUEST:
+ {
+ UCHAR ucResetValue[4];
+ GPIO_MULTI_INFO gpio_multi_info[MAX_IDX];
+ PGPIO_MULTI_INFO pgpio_multi_info = (PGPIO_MULTI_INFO)gpio_multi_info;
+
+ memset( pgpio_multi_info, 0, MAX_IDX * sizeof( GPIO_MULTI_INFO));
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ Status = -EINVAL;
+ break;
+ }
+ Status = copy_from_user( (PCHAR)&IoBuffer, ( PCHAR)arg, sizeof( IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status);
+ break;
+ }
+
+ Status = copy_from_user( &gpio_multi_info, IoBuffer.InputBuffer, IoBuffer.InputLength);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer Contents from user space err:%d",Status);
+ break;
+ }
+ if(IsReqGpioIsLedInNVM(Adapter,pgpio_multi_info[WIMAX_IDX].uiGPIOMask)== FALSE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",pgpio_multi_info[WIMAX_IDX].uiGPIOMask,Adapter->gpioBitMap);
+ Status = -EINVAL;
+ break;
+ }
+
+ /* Set the gpio output register */
+
+ if( ( pgpio_multi_info[WIMAX_IDX].uiGPIOMask) &
+ ( pgpio_multi_info[WIMAX_IDX].uiGPIOCommand))
+ {
+ /* Set 1's in GPIO OUTPUT REGISTER */
+ *(UINT*) ucResetValue = pgpio_multi_info[WIMAX_IDX].uiGPIOMask &
+ pgpio_multi_info[WIMAX_IDX].uiGPIOCommand &
+ pgpio_multi_info[WIMAX_IDX].uiGPIOValue;
+
+ if( *(UINT*) ucResetValue)
+ Status = wrmaltWithLock( Adapter, BCM_GPIO_OUTPUT_SET_REG , (PUINT) ucResetValue, sizeof(ULONG));
+
+ if( Status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to BCM_GPIO_OUTPUT_SET_REG Failed.");
+ return Status;
+ }
+
+ /* Clear to 0's in GPIO OUTPUT REGISTER */
+ *(UINT*) ucResetValue = (pgpio_multi_info[WIMAX_IDX].uiGPIOMask &
+ pgpio_multi_info[WIMAX_IDX].uiGPIOCommand &
+ ( ~( pgpio_multi_info[WIMAX_IDX].uiGPIOValue)));
+
+ if( *(UINT*) ucResetValue)
+ Status = wrmaltWithLock( Adapter, BCM_GPIO_OUTPUT_CLR_REG , (PUINT) ucResetValue, sizeof(ULONG));
+
+ if( Status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to BCM_GPIO_OUTPUT_CLR_REG Failed." );
+ return Status;
+ }
+ }
+
+ if( pgpio_multi_info[WIMAX_IDX].uiGPIOMask)
+ {
+ Status = rdmaltWithLock(Adapter, (UINT)GPIO_PIN_STATE_REGISTER, (PUINT)ucResetValue, sizeof(UINT));
+
+ if(Status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM to GPIO_PIN_STATE_REGISTER Failed.");
+ return Status;
+ }
+
+ pgpio_multi_info[WIMAX_IDX].uiGPIOValue = ( *(UINT*)ucResetValue &
+ pgpio_multi_info[WIMAX_IDX].uiGPIOMask);
+ }
+
+ Status = copy_to_user( (PCHAR)IoBuffer.OutputBuffer, &gpio_multi_info, IoBuffer.OutputLength);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status);
+ break;
+ }
+ }
+ break;
+ case IOCTL_BCM_GPIO_MODE_REQUEST:
+ {
+ UCHAR ucResetValue[4];
+ GPIO_MULTI_MODE gpio_multi_mode[MAX_IDX];
+ PGPIO_MULTI_MODE pgpio_multi_mode = ( PGPIO_MULTI_MODE) gpio_multi_mode;
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ Status = -EINVAL;
+ break;
+ }
+ Status = copy_from_user( (PCHAR)&IoBuffer, ( PCHAR)arg, sizeof( IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer from user space err:%d",Status);
+ break;
+ }
+
+ Status = copy_from_user( &gpio_multi_mode, IoBuffer.InputBuffer, IoBuffer.InputLength);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying the IOBufer Contents from user space err:%d",Status);
+ break;
+ }
+
+ Status = rdmaltWithLock( Adapter, ( UINT) GPIO_MODE_REGISTER, ( PUINT) ucResetValue, sizeof( UINT));
+ if( STATUS_SUCCESS != Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Read of GPIO_MODE_REGISTER failed");
+ return Status;
+ }
+
+ //Validating the request
+ if(IsReqGpioIsLedInNVM(Adapter,pgpio_multi_mode[WIMAX_IDX].uiGPIOMask)== FALSE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Sorry, Requested GPIO<0x%X> is not correspond to NVM LED bit map<0x%X>!!!",pgpio_multi_mode[WIMAX_IDX].uiGPIOMask,Adapter->gpioBitMap);
+ Status = -EINVAL;
+ break;
+ }
+
+ if( pgpio_multi_mode[WIMAX_IDX].uiGPIOMask)
+ {
+ /* write all OUT's (1's) */
+ *( UINT*) ucResetValue |= ( pgpio_multi_mode[WIMAX_IDX].uiGPIOMode &
+ pgpio_multi_mode[WIMAX_IDX].uiGPIOMask);
+ /* write all IN's (0's) */
+ *( UINT*) ucResetValue &= ~( ( ~pgpio_multi_mode[WIMAX_IDX].uiGPIOMode) &
+ pgpio_multi_mode[WIMAX_IDX].uiGPIOMask);
+
+ /* Currently implemented return the modes of all GPIO's
+ * else needs to bit AND with mask
+ * */
+ pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *(UINT*)ucResetValue;
+
+ Status = wrmaltWithLock( Adapter, GPIO_MODE_REGISTER , ( PUINT) ucResetValue, sizeof( ULONG));
+ if( Status == STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "WRM to GPIO_MODE_REGISTER Done");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to GPIO_MODE_REGISTER Failed");
+ Status = -EFAULT;
+ break;
+ }
+ }
+ else /* if uiGPIOMask is 0 then return mode register configuration */
+ {
+ pgpio_multi_mode[WIMAX_IDX].uiGPIOMode = *( UINT*) ucResetValue;
+ }
+ Status = copy_to_user( (PCHAR)IoBuffer.OutputBuffer, &gpio_multi_mode, IoBuffer.OutputLength);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed while copying Content to IOBufer for user space err:%d",Status);
+ break;
+ }
+ }
+ break;
+
+ case IOCTL_MAC_ADDR_REQ:
+ case IOCTL_LINK_REQ:
+ case IOCTL_CM_REQUEST:
+ case IOCTL_SS_INFO_REQ:
+ case IOCTL_SEND_CONTROL_MESSAGE:
+ case IOCTL_IDLE_REQ:
+ {
+ PVOID pvBuffer=NULL;
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg,
+ sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL);
+ if(!pvBuffer)
+ {
+ return -ENOMEM;
+ }
+
+ if(copy_from_user(pvBuffer, IoBuffer.InputBuffer,
+ IoBuffer.InputLength))
+ {
+ Status = -EFAULT;
+ bcm_kfree(pvBuffer);
+ break;
+ }
+
+ down(&Adapter->LowPowerModeSync);
+ Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue,
+ !Adapter->bPreparingForLowPowerMode,
+ (1 * HZ));
+ if(Status == -ERESTARTSYS)
+ goto cntrlEnd;
+
+ if(Adapter->bPreparingForLowPowerMode)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Preparing Idle Mode is still True - Hence Rejecting control message\n");
+ Status = STATUS_FAILURE ;
+ goto cntrlEnd ;
+ }
+ Status = CopyBufferToControlPacket(Adapter, (PVOID)pvBuffer);
+ cntrlEnd:
+ up(&Adapter->LowPowerModeSync);
+ bcm_kfree(pvBuffer);
+ break;
+ }
+#ifndef BCM_SHM_INTERFACE
+ case IOCTL_BCM_BUFFER_DOWNLOAD_START:
+ {
+ INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock) ;
+ if(NVMAccess)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n");
+ return -EACCES;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid);
+ if(!down_trylock(&Adapter->fw_download_sema))
+ {
+ Adapter->bBinDownloaded=FALSE;
+ Adapter->fw_download_process_pid=current->pid;
+ Adapter->bCfgDownloaded=FALSE;
+ Adapter->fw_download_done=FALSE;
+ netif_carrier_off(Adapter->dev);
+ netif_stop_queue(Adapter->dev);
+ Status = reset_card_proc(Adapter);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "reset_card_proc Failed!\n");
+ up(&Adapter->fw_download_sema);
+ up(&Adapter->NVMRdmWrmLock);
+ break;
+ }
+ mdelay(10);
+ }
+ else
+ {
+
+ Status = -EBUSY;
+
+ }
+ up(&Adapter->NVMRdmWrmLock);
+ break;
+ }
+ case IOCTL_BCM_BUFFER_DOWNLOAD:
+ {
+ FIRMWARE_INFO *psFwInfo=NULL;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Starting the firmware download PID =0x%x!!!!\n", current->pid);
+ do{
+ if(!down_trylock(&Adapter->fw_download_sema))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid way to download buffer. Use Start and then call this!!!\n");
+ Status=-EINVAL;
+ break;
+ }
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg,
+ sizeof(IOCTL_BUFFER)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n");
+ Status = -EFAULT;
+ break;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length for FW DLD is : %lx\n",
+ IoBuffer.InputLength);
+ psFwInfo=kmalloc(sizeof(*psFwInfo), GFP_KERNEL);
+ if(!psFwInfo)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Failed to allocate buffer!!!!\n");
+ Status = -ENOMEM;
+ break;
+ }
+ if(copy_from_user(psFwInfo, IoBuffer.InputBuffer,
+ IoBuffer.InputLength))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_from_user 2 failed\n");
+ Status = -EFAULT;
+ break;
+ }
+
+ if(!psFwInfo->pvMappedFirmwareAddress ||
+ (psFwInfo->u32FirmwareLength == 0))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Something else is wrong %lu\n",
+ psFwInfo->u32FirmwareLength);
+ Status = -EINVAL;
+ break;
+ }
+ Status = bcm_ioctl_fw_download(Adapter, psFwInfo);
+ if(Status != STATUS_SUCCESS)
+ {
+ if(psFwInfo->u32StartingAddress==CONFIG_BEGIN_ADDR)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "IOCTL: Configuration File Upload Failed\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "IOCTL: Firmware File Upload Failed\n");
+ }
+ //up(&Adapter->fw_download_sema);
+
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ Adapter->DriverState = DRIVER_INIT;
+ Adapter->LEDInfo.bLedInitDone = FALSE;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+ }
+ break ;
+ }while(0);
+
+ if(Status != STATUS_SUCCESS)
+ up(&Adapter->fw_download_sema);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, OSAL_DBG, DBG_LVL_ALL, "IOCTL: Firmware File Uploaded\n");
+ bcm_kfree(psFwInfo);
+ break;
+ }
+ case IOCTL_BCM_BUFFER_DOWNLOAD_STOP:
+ {
+ INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
+ if(NVMAccess)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " FW download blocked as EEPROM Read/Write is in progress\n");
+ up(&Adapter->fw_download_sema);
+ return -EACCES;
+ }
+ if(down_trylock(&Adapter->fw_download_sema))
+ {
+ Adapter->bBinDownloaded=TRUE;
+ Adapter->bCfgDownloaded=TRUE;
+ atomic_set(&Adapter->CurrNumFreeTxDesc, 0);
+ atomic_set(&Adapter->RxRollOverCount, 0);
+ Adapter->CurrNumRecvDescs=0;
+ Adapter->downloadDDR = 0;
+
+ //setting the Mips to Run
+ Status = run_card_proc(Adapter);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Firm Download Failed\n");
+ up(&Adapter->fw_download_sema);
+ up(&Adapter->NVMRdmWrmLock);
+ break;
+ }
+ else
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Firm Download Over...\n");
+ mdelay(10);
+ /* Wait for MailBox Interrupt */
+ if(StartInterruptUrb((PS_INTERFACE_ADAPTER)Adapter->pvInterfaceAdapter))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Unable to send interrupt...\n");
+ }
+ timeout = 5*HZ;
+ Adapter->waiting_to_fw_download_done = FALSE;
+ wait_event_timeout(Adapter->ioctl_fw_dnld_wait_queue,
+ Adapter->waiting_to_fw_download_done, timeout);
+ Adapter->fw_download_process_pid=INVALID_PID;
+ Adapter->fw_download_done=TRUE;
+ atomic_set(&Adapter->CurrNumFreeTxDesc, 0);
+ Adapter->CurrNumRecvDescs = 0;
+ Adapter->PrevNumRecvDescs = 0;
+ atomic_set(&Adapter->cntrlpktCnt,0);
+ Adapter->LinkUpStatus = 0;
+ Adapter->LinkStatus = 0;
+
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ Adapter->DriverState = FW_DOWNLOAD_DONE;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+
+ if(!timeout)
+ {
+ Status = -ENODEV;
+ }
+ }
+ else
+ {
+ Status = -EINVAL;
+ }
+ up(&Adapter->fw_download_sema);
+ up(&Adapter->NVMRdmWrmLock);
+ break;
+ }
+#endif
+ case IOCTL_BE_BUCKET_SIZE:
+ Adapter->BEBucketSize = *(PULONG)arg;
+ Status = STATUS_SUCCESS;
+ break;
+
+ case IOCTL_RTPS_BUCKET_SIZE:
+ Adapter->rtPSBucketSize = *(PULONG)arg;
+ Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_CHIP_RESET:
+ {
+ INT NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
+ if(NVMAccess)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " IOCTL_BCM_CHIP_RESET not allowed as EEPROM Read/Write is in progress\n");
+ return -EACCES;
+ }
+ down(&Adapter->RxAppControlQueuelock);
+ Status = reset_card_proc(Adapter);
+ flushAllAppQ();
+ up(&Adapter->RxAppControlQueuelock);
+ up(&Adapter->NVMRdmWrmLock);
+ ResetCounters(Adapter);
+ break;
+ }
+ case IOCTL_QOS_THRESHOLD:
+ {
+ USHORT uiLoopIndex;
+ for(uiLoopIndex = 0 ; uiLoopIndex < NO_OF_QUEUES ; uiLoopIndex++)
+ {
+ Adapter->PackInfo[uiLoopIndex].uiThreshold = *(PULONG)arg;
+ }
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
+ case IOCTL_DUMP_PACKET_INFO:
+
+ DumpPackInfo(Adapter);
+ DumpPhsRules(&Adapter->stBCMPhsContext);
+ Status = STATUS_SUCCESS;
+ break;
+
+ case IOCTL_GET_PACK_INFO:
+ if(copy_to_user((PCHAR)arg, &Adapter->PackInfo,
+ sizeof(PacketInfo)*NO_OF_QUEUES))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ Status = STATUS_SUCCESS;
+ break;
+ case IOCTL_BCM_SWITCH_TRANSFER_MODE:
+ {
+ UINT uiData = 0;
+ if(copy_from_user(&uiData, (PUINT)arg, sizeof(UINT)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ if(uiData) /* Allow All Packets */
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: ETH_PACKET_TUNNELING_MODE\n");
+ Adapter->TransferMode = ETH_PACKET_TUNNELING_MODE;
+ }
+ else /* Allow IP only Packets */
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SWITCH_TRANSFER_MODE: IP_PACKET_ONLY_MODE\n");
+ Adapter->TransferMode = IP_PACKET_ONLY_MODE;
+ }
+ Status = STATUS_SUCCESS;
+ break;
+ }
+
+ case IOCTL_BCM_GET_DRIVER_VERSION:
+ {
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer,
+ (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ if(copy_to_user((PUCHAR)IoBuffer.OutputBuffer,
+ VER_FILEVERSION_STR, (UINT)IoBuffer.OutputLength))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ Status = STATUS_SUCCESS;
+ break;
+ }
+ case IOCTL_BCM_GET_CURRENT_STATUS:
+ {
+ LINK_STATE *plink_state = NULL;
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer,
+ (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user failed..\n");
+ Status = -EFAULT;
+ break;
+ }
+ plink_state = (LINK_STATE*)arg;
+ plink_state->bIdleMode = (UCHAR)Adapter->IdleMode;
+ plink_state->bShutdownMode = Adapter->bShutStatus;
+ plink_state->ucLinkStatus = (UCHAR)Adapter->LinkStatus;
+ if(copy_to_user((PUCHAR)IoBuffer.OutputBuffer,
+ (PUCHAR)plink_state, (UINT)IoBuffer.OutputLength))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n");
+ Status = -EFAULT;
+ break;
+ }
+ Status = STATUS_SUCCESS;
+ break;
+ }
+ case IOCTL_BCM_SET_MAC_TRACING:
+ {
+ UINT tracing_flag;
+ /* copy ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer,
+ (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ if(copy_from_user((PCHAR)&tracing_flag,
+ (PCHAR)IoBuffer.InputBuffer,sizeof(UINT)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+ if (tracing_flag)
+ Adapter->pTarangs->MacTracingEnabled = TRUE;
+ else
+ Adapter->pTarangs->MacTracingEnabled = FALSE;
+ break;
+ }
+ case IOCTL_BCM_GET_DSX_INDICATION:
+ {
+ ULONG ulSFId=0;
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg,
+ sizeof(IOCTL_BUFFER)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid IO buffer!!!" );
+ Status = -EFAULT;
+ break;
+ }
+ if(IoBuffer.OutputLength < sizeof(stLocalSFAddIndicationAlt))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Mismatch req: %lx needed is =0x%x!!!",
+ IoBuffer.OutputLength, sizeof(stLocalSFAddIndicationAlt));
+ return -EINVAL;
+ }
+ if(copy_from_user((PCHAR)&ulSFId, (PCHAR)IoBuffer.InputBuffer,
+ sizeof(ulSFId)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Invalid SFID!!! %lu", ulSFId );
+ Status = -EFAULT;
+ break;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Get DSX Data SF ID is =%lx\n", ulSFId );
+ get_dsx_sf_data_to_application(Adapter, ulSFId,
+ IoBuffer.OutputBuffer);
+ Status=STATUS_SUCCESS;
+ }
+ break;
+ case IOCTL_BCM_GET_HOST_MIBS:
+ {
+ PCHAR temp_buff;
+
+ if(copy_from_user((PCHAR)&IoBuffer,
+ (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_from user for IoBuff failed\n");
+ Status = -EFAULT;
+ break;
+ }
+
+ if(IoBuffer.OutputLength != sizeof(S_MIBS_HOST_STATS_MIBS))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Length Check failed %lu %d\n", IoBuffer.OutputLength,
+ sizeof(S_MIBS_HOST_STATS_MIBS));
+ return -EINVAL;
+ }
+
+ temp_buff = (PCHAR)kmalloc(IoBuffer.OutputLength, GFP_KERNEL);
+
+ if(!temp_buff)
+ {
+ return STATUS_FAILURE;
+ }
+
+ Status = ProcessGetHostMibs(Adapter,
+ (PUCHAR)temp_buff, IoBuffer.OutputLength);
+
+ Status = GetDroppedAppCntrlPktMibs((PVOID)temp_buff,
+ (PPER_TARANG_DATA)filp->private_data);
+
+ if(copy_to_user((PCHAR)IoBuffer.OutputBuffer,(PCHAR)temp_buff,
+ sizeof(S_MIBS_HOST_STATS_MIBS)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy to user failed\n");
+ bcm_kfree(temp_buff);
+ return -EFAULT;
+ }
+
+ bcm_kfree(temp_buff);
+ break;
+ }
+
+ case IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE:
+ if((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) && (TRUE==Adapter->IdleMode))
+ {
+ Adapter->usIdleModePattern = ABORT_IDLE_MODE;
+ Adapter->bWakeUpDevice = TRUE;
+ wake_up(&Adapter->process_rx_cntrlpkt);
+ #if 0
+ Adapter->bTriedToWakeUpFromlowPowerMode = TRUE;
+ InterfaceAbortIdlemode (Adapter, Adapter->usIdleModePattern);
+ #endif
+ }
+ Status = STATUS_SUCCESS;
+ break;
+
+ case IOCTL_BCM_BULK_WRM:
+ {
+ PBULKWRM_BUFFER pBulkBuffer;
+ UINT uiTempVar=0;
+ PCHAR pvBuffer = NULL;
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Device in Idle/Shutdown Mode, Blocking Wrms\n");
+ Status = -EACCES;
+ break;
+ }
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+
+ pvBuffer=kmalloc(IoBuffer.InputLength, GFP_KERNEL);
+ if(!pvBuffer)
+ {
+ return -ENOMEM;
+ break;
+ }
+
+ /* Get WrmBuffer structure */
+ if(copy_from_user(pvBuffer, IoBuffer.InputBuffer, IoBuffer.InputLength))
+ {
+ bcm_kfree(pvBuffer);
+ Status = -EFAULT;
+ break;
+ }
+
+ pBulkBuffer = (PBULKWRM_BUFFER)pvBuffer;
+
+ if(((ULONG)pBulkBuffer->Register & 0x0F000000) != 0x0F000000 ||
+ ((ULONG)pBulkBuffer->Register & 0x3))
+ {
+ bcm_kfree(pvBuffer);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"WRM Done On invalid Address : %x Access Denied.\n",(int)pBulkBuffer->Register);
+ Status = -EINVAL;
+ break;
+ }
+
+
+ uiTempVar = pBulkBuffer->Register & EEPROM_REJECT_MASK;
+ if(!((Adapter->pstargetparams->m_u32Customize)&VSG_MODE)
+ && ((uiTempVar == EEPROM_REJECT_REG_1)||
+ (uiTempVar == EEPROM_REJECT_REG_2) ||
+ (uiTempVar == EEPROM_REJECT_REG_3) ||
+ (uiTempVar == EEPROM_REJECT_REG_4)) &&
+ (cmd == IOCTL_BCM_REGISTER_WRITE))
+ {
+ bcm_kfree(pvBuffer);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0,"EEPROM Access Denied, not in VSG Mode\n");
+ Status = -EFAULT;
+ break;
+ }
+
+ if(pBulkBuffer->SwapEndian == FALSE)
+ Status = wrmWithLock(Adapter, (UINT)pBulkBuffer->Register, (PCHAR)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG));
+ else
+ Status = wrmaltWithLock(Adapter, (UINT)pBulkBuffer->Register, (PUINT)pBulkBuffer->Values, IoBuffer.InputLength - 2*sizeof(ULONG));
+
+ if(Status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed\n");
+ }
+
+ bcm_kfree(pvBuffer);
+ break;
+ }
+
+ case IOCTL_BCM_GET_NVM_SIZE:
+ {
+
+ if(copy_from_user((unsigned char *)&IoBuffer,
+ (unsigned char *)arg, sizeof(IOCTL_BUFFER)))
+ {
+ //IOLog("failed NVM first");
+ Status = -EFAULT;
+ break;
+ }
+ if(Adapter->eNVMType == NVM_EEPROM || Adapter->eNVMType == NVM_FLASH ) {
+ if(copy_to_user(IoBuffer.OutputBuffer,
+ (unsigned char *)&Adapter->uiNVMDSDSize, (UINT)sizeof(UINT)))
+ {
+ Status = -EFAULT;
+ return Status;
+ }
+ }
+
+ Status = STATUS_SUCCESS ;
+ }
+ break;
+
+ case IOCTL_BCM_CAL_INIT :
+
+ {
+ UINT uiSectorSize = 0 ;
+ if(Adapter->eNVMType == NVM_FLASH)
+ {
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy From User space failed. status :%d", Status);
+ return Status;
+ }
+ uiSectorSize = *((PUINT)(IoBuffer.InputBuffer));
+ if((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE))
+ {
+
+ Status = copy_to_user(IoBuffer.OutputBuffer,
+ (unsigned char *)&Adapter->uiSectorSize ,
+ (UINT)sizeof(UINT));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Coping the sector size to use space failed. status:%d",Status);
+ return Status;
+ }
+ }
+ else
+ {
+ if(IsFlash2x(Adapter))
+ {
+ Status = copy_to_user(IoBuffer.OutputBuffer,
+ (unsigned char *)&Adapter->uiSectorSize ,
+ (UINT)sizeof(UINT));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Coping the sector size to use space failed. status:%d",Status);
+ return Status;
+ }
+
+ }
+ else
+ {
+ if((TRUE == Adapter->bShutStatus) ||
+ (TRUE == Adapter->IdleMode))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle/Shutdown Mode\n");
+ return -EACCES;
+ }
+
+ Adapter->uiSectorSize = uiSectorSize ;
+ BcmUpdateSectorSize(Adapter,Adapter->uiSectorSize);
+ }
+ }
+ Status = STATUS_SUCCESS ;
+ }
+ else
+ {
+ Status = STATUS_FAILURE;
+ }
+ }
+ break;
+ case IOCTL_BCM_SET_DEBUG :
+ {
+ USER_BCM_DBG_STATE sUserDebugState;
+
+// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Entered the ioctl %x \n", IOCTL_BCM_SET_DEBUG );
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In SET_DEBUG ioctl\n");
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy from user failed\n");
+ break;
+ }
+ Status = copy_from_user(&sUserDebugState,(USER_BCM_DBG_STATE *)IoBuffer.InputBuffer, sizeof(USER_BCM_DBG_STATE));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "Copy of IoBuffer.InputBuffer failed");
+ return Status;
+ }
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "IOCTL_BCM_SET_DEBUG: OnOff=%d Type = 0x%x ",
+ sUserDebugState.OnOff, sUserDebugState.Type);
+ //sUserDebugState.Subtype <<= 1;
+ sUserDebugState.Subtype = 1 << sUserDebugState.Subtype;
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "actual Subtype=0x%x\n", sUserDebugState.Subtype);
+
+ // Update new 'DebugState' in the Adapter
+ Adapter->stDebugState.type |= sUserDebugState.Type;
+ /* Subtype: A bitmap of 32 bits for Subtype per Type.
+ * Valid indexes in 'subtype' array: 1,2,4,8
+ * corresponding to valid Type values. Hence we can use the 'Type' field
+ * as the index value, ignoring the array entries 0,3,5,6,7 !
+ */
+ if (sUserDebugState.OnOff)
+ Adapter->stDebugState.subtype[sUserDebugState.Type] |= sUserDebugState.Subtype;
+ else
+ Adapter->stDebugState.subtype[sUserDebugState.Type] &= ~sUserDebugState.Subtype;
+
+ BCM_SHOW_DEBUG_BITMAP(Adapter);
+
+ }
+ break;
+ case IOCTL_BCM_NVM_READ:
+ case IOCTL_BCM_NVM_WRITE:
+ {
+
+ NVM_READWRITE stNVMReadWrite = {0};
+ PUCHAR pReadData = NULL;
+ PUCHAR pBuffertobeCopied = NULL;
+ ULONG ulDSDMagicNumInUsrBuff = 0 ;
+ struct timeval tv0, tv1;
+ memset(&tv0,0,sizeof(struct timeval));
+ memset(&tv1,0,sizeof(struct timeval));
+ if((Adapter->eNVMType == NVM_FLASH) && (Adapter->uiFlashLayoutMajorVersion == 0))
+ {
+ BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0,"The Flash Control Section is Corrupted. Hence Rejection on NVM Read/Write\n");
+ Status = -EFAULT;
+ break;
+ }
+
+ if(IsFlash2x(Adapter))
+ {
+ if((Adapter->eActiveDSD != DSD0) &&
+ (Adapter->eActiveDSD != DSD1) &&
+ (Adapter->eActiveDSD != DSD2))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"No DSD is active..hence NVM Command is blocked");
+ return STATUS_FAILURE ;
+ }
+ }
+
+ /* Copy Ioctl Buffer structure */
+
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copy_from_user failed\n");
+ Status = -EFAULT;
+ break;
+ }
+ if(IOCTL_BCM_NVM_READ == cmd)
+ pBuffertobeCopied = IoBuffer.OutputBuffer;
+ else
+ pBuffertobeCopied = IoBuffer.InputBuffer;
+
+ if(copy_from_user(&stNVMReadWrite, pBuffertobeCopied,sizeof(NVM_READWRITE)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+
+ //
+ // Deny the access if the offset crosses the cal area limit.
+ //
+ if((stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) > Adapter->uiNVMDSDSize)
+ {
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Can't allow access beyond NVM Size: 0x%x 0x%x\n", stNVMReadWrite.uiOffset ,
+// stNVMReadWrite.uiNumBytes);
+ Status = STATUS_FAILURE;
+ break;
+ }
+
+ pReadData =(PCHAR)kmalloc(stNVMReadWrite.uiNumBytes, GFP_KERNEL);
+
+ if(!pReadData)
+ return -ENOMEM;
+
+ memset(pReadData,0,stNVMReadWrite.uiNumBytes);
+
+ if(copy_from_user(pReadData, stNVMReadWrite.pBuffer,
+ stNVMReadWrite.uiNumBytes))
+ {
+ Status = -EFAULT;
+ bcm_kfree(pReadData);
+ break;
+ }
+
+ do_gettimeofday(&tv0);
+ if(IOCTL_BCM_NVM_READ == cmd)
+ {
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pReadData);
+ return -EACCES;
+ }
+
+ Status = BeceemNVMRead(Adapter, (PUINT)pReadData,
+ stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes);
+
+ up(&Adapter->NVMRdmWrmLock);
+
+ if(Status != STATUS_SUCCESS)
+ {
+ bcm_kfree(pReadData);
+ return Status;
+ }
+ if(copy_to_user((PCHAR)stNVMReadWrite.pBuffer,
+ (PCHAR)pReadData, (UINT)stNVMReadWrite.uiNumBytes))
+ {
+ bcm_kfree(pReadData);
+ Status = -EFAULT;
+ }
+ }
+ else
+ {
+
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pReadData);
+ return -EACCES;
+ }
+
+ Adapter->bHeaderChangeAllowed = TRUE ;
+ if(IsFlash2x(Adapter))
+ {
+ /*
+ New Requirement:-
+ DSD section updation will be allowed in two case:-
+ 1. if DSD sig is present in DSD header means dongle is ok and updation is fruitfull
+ 2. if point 1 failes then user buff should have DSD sig. this point ensures that if dongle is
+ corrupted then user space program first modify the DSD header with valid DSD sig so
+ that this as well as further write may be worthwhile.
+
+ This restriction has been put assuming that if DSD sig is corrupted, DSD
+ data won't be considered valid.
+
+
+ */
+ Status = BcmFlash2xCorruptSig(Adapter,Adapter->eActiveDSD);
+ if(Status != STATUS_SUCCESS)
+ {
+ if(( (stNVMReadWrite.uiOffset + stNVMReadWrite.uiNumBytes) != Adapter->uiNVMDSDSize ) ||
+ (stNVMReadWrite.uiNumBytes < SIGNATURE_SIZE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input..");
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pReadData);
+ return Status;
+ }
+
+ ulDSDMagicNumInUsrBuff = ntohl(*(PUINT)(pReadData + stNVMReadWrite.uiNumBytes - SIGNATURE_SIZE));
+ if(ulDSDMagicNumInUsrBuff != DSD_IMAGE_MAGIC_NUMBER)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"DSD Sig is present neither in Flash nor User provided Input..");
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pReadData);
+ return Status;
+ }
+ }
+ }
+ Status = BeceemNVMWrite(Adapter, (PUINT )pReadData,
+ stNVMReadWrite.uiOffset, stNVMReadWrite.uiNumBytes, stNVMReadWrite.bVerify);
+ if(IsFlash2x(Adapter))
+ BcmFlash2xWriteSig(Adapter,Adapter->eActiveDSD);
+
+ Adapter->bHeaderChangeAllowed = FALSE ;
+
+ up(&Adapter->NVMRdmWrmLock);
+
+
+ if(Status != STATUS_SUCCESS)
+ {
+ bcm_kfree(pReadData);
+ return Status;
+ }
+ }
+ do_gettimeofday(&tv1);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " timetaken by Write/read :%ld msec\n",(tv1.tv_sec - tv0.tv_sec)*1000 +(tv1.tv_usec - tv0.tv_usec)/1000);
+
+
+ bcm_kfree(pReadData);
+ Status = STATUS_SUCCESS;
+ }
+ break;
+ case IOCTL_BCM_FLASH2X_SECTION_READ :
+ {
+
+ FLASH2X_READWRITE sFlash2xRead = {0};
+ PUCHAR pReadBuff = NULL ;
+ UINT NOB = 0;
+ UINT BuffSize = 0;
+ UINT ReadBytes = 0;
+ UINT ReadOffset = 0;
+ PUCHAR OutPutBuff = NULL;
+
+ if(IsFlash2x(Adapter) != TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map");
+ return -EINVAL;
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_FLASH2X_SECTION_READ Called");
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ return Status ;
+ }
+
+ //Reading FLASH 2.x READ structure
+ Status = copy_from_user((PUCHAR)&sFlash2xRead, (PUCHAR)IoBuffer.InputBuffer,sizeof(FLASH2X_READWRITE));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Input Buffer failed");
+ return Status ;
+ }
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xRead.Section);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.offset :%x" ,sFlash2xRead.offset);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.numOfBytes :%x" ,sFlash2xRead.numOfBytes);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xRead.bVerify);
+
+ //This was internal to driver for raw read. now it has ben exposed to user space app.
+ if(validateFlash2xReadWrite(Adapter,&sFlash2xRead) == FALSE)
+ return STATUS_FAILURE ;
+
+ NOB = sFlash2xRead.numOfBytes;
+ if(NOB > Adapter->uiSectorSize )
+ BuffSize = Adapter->uiSectorSize;
+ else
+ BuffSize = NOB ;
+
+ ReadOffset = sFlash2xRead.offset ;
+ OutPutBuff = (PUCHAR)(IoBuffer.OutputBuffer) ;
+
+
+ pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL);
+ if(pReadBuff == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure");
+ return -ENOMEM;
+ }
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pReadBuff);
+ return -EACCES;
+ }
+
+ while(NOB)
+ {
+
+ if(NOB > Adapter->uiSectorSize )
+ ReadBytes = Adapter->uiSectorSize;
+ else
+ ReadBytes = NOB;
+
+
+ //Reading the data from Flash 2.x
+
+ Status = BcmFlash2xBulkRead(Adapter,(PUINT)pReadBuff,sFlash2xRead.Section,ReadOffset,ReadBytes);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Flash 2x read err with Status :%d", Status);
+ break ;
+ }
+
+ BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff, ReadBytes);
+
+ Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Copy to use failed with status :%d", Status);
+ break;
+ }
+ NOB = NOB - ReadBytes;
+ if(NOB)
+ {
+ ReadOffset = ReadOffset + ReadBytes ;
+ OutPutBuff = OutPutBuff + ReadBytes ;
+ }
+
+ }
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pReadBuff);
+
+ }
+ break ;
+ case IOCTL_BCM_FLASH2X_SECTION_WRITE :
+ {
+ FLASH2X_READWRITE sFlash2xWrite = {0};
+ PUCHAR pWriteBuff = NULL;
+ PUCHAR InputAddr = NULL;
+ UINT NOB = 0;
+ UINT BuffSize = 0;
+ UINT WriteOffset = 0;
+ UINT WriteBytes = 0;
+
+ if(IsFlash2x(Adapter) != TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map");
+ return -EINVAL;
+ }
+
+ //First make this False so that we can enable the Sector Permission Check in BeceemFlashBulkWrite
+ Adapter->bAllDSDWriteAllow = FALSE;
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_FLASH2X_SECTION_WRITE Called");
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ return Status;
+ }
+
+ //Reading FLASH 2.x READ structure
+ Status = copy_from_user((PCHAR)&sFlash2xWrite, (PCHAR)IoBuffer.InputBuffer, sizeof(FLASH2X_READWRITE));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reading of output Buffer from IOCTL buffer fails");
+ return Status;
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.Section :%x" ,sFlash2xWrite.Section);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.offset :%d" ,sFlash2xWrite.offset);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.numOfBytes :%x" ,sFlash2xWrite.numOfBytes);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\nsFlash2xRead.bVerify :%x\n" ,sFlash2xWrite.bVerify);
+ #if 0
+ if((sFlash2xWrite.Section == ISO_IMAGE1) ||(sFlash2xWrite.Section == ISO_IMAGE2) ||
+ (sFlash2xWrite.Section == DSD0) || (sFlash2xWrite.Section == DSD1) || (sFlash2xWrite.Section == DSD2))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"ISO/DSD Image write is not allowed.... ");
+ return STATUS_FAILURE ;
+ }
+ #endif
+ if((sFlash2xWrite.Section != VSA0) && (sFlash2xWrite.Section != VSA1) &&
+ (sFlash2xWrite.Section != VSA2) )
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Only VSA write is allowed");
+ return -EINVAL;
+ }
+
+ if(validateFlash2xReadWrite(Adapter,&sFlash2xWrite) == FALSE)
+ return STATUS_FAILURE ;
+
+ InputAddr = (PCHAR)(sFlash2xWrite.pDataBuff) ;
+ WriteOffset = sFlash2xWrite.offset ;
+ NOB = sFlash2xWrite.numOfBytes;
+
+ if(NOB > Adapter->uiSectorSize )
+ BuffSize = Adapter->uiSectorSize;
+ else
+ BuffSize = NOB ;
+
+ pWriteBuff = (PCHAR)kmalloc(BuffSize, GFP_KERNEL);
+ if(pWriteBuff == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure");
+ return -ENOMEM;
+ }
+
+ //extracting the remainder of the given offset.
+ WriteBytes = Adapter->uiSectorSize ;
+ if(WriteOffset % Adapter->uiSectorSize)
+ WriteBytes =Adapter->uiSectorSize - (WriteOffset % Adapter->uiSectorSize);
+ if(NOB < WriteBytes)
+ WriteBytes = NOB;
+
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pWriteBuff);
+ return -EACCES;
+ }
+
+ BcmFlash2xCorruptSig(Adapter,sFlash2xWrite.Section);
+ do
+ {
+ Status = copy_from_user(pWriteBuff,InputAddr,WriteBytes);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to user failed with status :%d", Status);
+ break ;
+ }
+ BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pWriteBuff,WriteBytes);
+ //Writing the data from Flash 2.x
+ Status = BcmFlash2xBulkWrite(Adapter,(PUINT)pWriteBuff,sFlash2xWrite.Section,WriteOffset,WriteBytes,sFlash2xWrite.bVerify);
+
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash 2x read err with Status :%d", Status);
+ break ;
+ }
+
+ NOB = NOB - WriteBytes;
+ if(NOB)
+ {
+ WriteOffset = WriteOffset + WriteBytes ;
+ InputAddr = InputAddr + WriteBytes ;
+ if(NOB > Adapter->uiSectorSize )
+ WriteBytes = Adapter->uiSectorSize;
+ else
+ WriteBytes = NOB;
+ }
+
+
+ } while(NOB > 0);
+ BcmFlash2xWriteSig(Adapter,sFlash2xWrite.Section);
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pWriteBuff);
+ }
+ break ;
+ case IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP :
+ {
+
+ PFLASH2X_BITMAP psFlash2xBitMap = NULL ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP Called");
+
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ return Status;
+ }
+ if(IoBuffer.OutputLength != sizeof(FLASH2X_BITMAP))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Structure size mismatch Lib :0x%lx Driver :0x%x ",IoBuffer.OutputLength, sizeof(FLASH2X_BITMAP));
+ break;
+ }
+
+ psFlash2xBitMap = (PFLASH2X_BITMAP)kzalloc(sizeof(FLASH2X_BITMAP), GFP_KERNEL);
+ if(psFlash2xBitMap == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory is not available");
+ return -ENOMEM ;
+ }
+ //Reading the Flash Sectio Bit map
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(psFlash2xBitMap);
+ return -EACCES;
+ }
+
+ BcmGetFlash2xSectionalBitMap(Adapter, psFlash2xBitMap);
+ up(&Adapter->NVMRdmWrmLock);
+ Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)psFlash2xBitMap, sizeof(FLASH2X_BITMAP));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x bitMap failed");
+ bcm_kfree(psFlash2xBitMap);
+ return Status;
+ }
+ bcm_kfree(psFlash2xBitMap);
+ }
+ break ;
+ case IOCTL_BCM_SET_ACTIVE_SECTION :
+ {
+ FLASH2X_SECTION_VAL eFlash2xSectionVal = 0;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_SET_ACTIVE_SECTION Called");
+
+ if(IsFlash2x(Adapter) != TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map");
+ return -EINVAL;
+ }
+
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ return Status;
+ }
+
+ Status = copy_from_user((PCHAR)&eFlash2xSectionVal,(PCHAR)IoBuffer.InputBuffer, sizeof(INT));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed");
+ return Status;
+ }
+
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ up(&Adapter->NVMRdmWrmLock);
+ return -EACCES;
+ }
+
+ Status = BcmSetActiveSection(Adapter,eFlash2xSectionVal);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Failed to make it's priority Highest. Status %d", Status);
+ }
+ up(&Adapter->NVMRdmWrmLock);
+ }
+ break ;
+ case IOCTL_BCM_IDENTIFY_ACTIVE_SECTION :
+ {
+ //Right Now we are taking care of only DSD
+ Adapter->bAllDSDWriteAllow = FALSE ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_IDENTIFY_ACTIVE_SECTION called");
+
+ #if 0
+ SECTION_TYPE section = 0 ;
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_IDENTIFY_ACTIVE_SECTION Called");
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy of IOCTL BUFFER failed");
+ return Status;
+ }
+ Status = copy_from_user((PCHAR)section,(PCHAR)&IoBuffer, sizeof(INT));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Copy of section type failed failed");
+ return Status;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", section);
+ if(section == DSD)
+ Adapter->ulFlashCalStart = Adapter->uiActiveDSDOffsetAtFwDld ;
+ else
+ Status = STATUS_FAILURE ;
+ #endif
+ Status = STATUS_SUCCESS ;
+ }
+ break ;
+ case IOCTL_BCM_COPY_SECTION :
+ {
+ FLASH2X_COPY_SECTION sCopySectStrut = {0};
+ Status = STATUS_SUCCESS;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "IOCTL_BCM_COPY_SECTION Called");
+
+ Adapter->bAllDSDWriteAllow = FALSE ;
+ if(IsFlash2x(Adapter) != TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map");
+ return -EINVAL;
+ }
+
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed Status :%d", Status);
+ return Status;
+ }
+
+ Status = copy_from_user((PCHAR)&sCopySectStrut,(PCHAR)IoBuffer.InputBuffer, sizeof(FLASH2X_COPY_SECTION));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of Copy_Section_Struct failed with Status :%d", Status);
+ return Status;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Source SEction :%x", sCopySectStrut.SrcSection);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Destination SEction :%x", sCopySectStrut.DstSection);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "offset :%x", sCopySectStrut.offset);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "NOB :%x", sCopySectStrut.numOfBytes);
+
+
+ if(IsSectionExistInFlash(Adapter,sCopySectStrut.SrcSection) == FALSE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Source Section<%x> does not exixt in Flash ", sCopySectStrut.SrcSection);
+ return -EINVAL;
+ }
+
+ if(IsSectionExistInFlash(Adapter,sCopySectStrut.DstSection) == FALSE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Destinatio Section<%x> does not exixt in Flash ", sCopySectStrut.DstSection);
+ return -EINVAL;
+ }
+
+ if(sCopySectStrut.SrcSection == sCopySectStrut.DstSection)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Source and Destination section should be different");
+ return -EINVAL;
+ }
+
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ up(&Adapter->NVMRdmWrmLock);
+ return -EACCES;
+ }
+
+ if(sCopySectStrut.SrcSection == ISO_IMAGE1 || sCopySectStrut.SrcSection == ISO_IMAGE2)
+ {
+ if(IsNonCDLessDevice(Adapter))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is Non-CDLess hence won't have ISO !!");
+ Status = -EINVAL ;
+ }
+ else if(sCopySectStrut.numOfBytes == 0)
+ {
+ Status = BcmCopyISO(Adapter,sCopySectStrut);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Partial Copy of ISO section is not Allowed..");
+ Status = STATUS_FAILURE ;
+ }
+ up(&Adapter->NVMRdmWrmLock);
+ return Status;
+ }
+
+ Status = BcmCopySection(Adapter, sCopySectStrut.SrcSection,
+ sCopySectStrut.DstSection,sCopySectStrut.offset,sCopySectStrut.numOfBytes);
+ up(&Adapter->NVMRdmWrmLock);
+ }
+ break ;
+ case IOCTL_BCM_GET_FLASH_CS_INFO :
+ {
+ Status = STATUS_SUCCESS;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_GET_FLASH_CS_INFO Called");
+
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ break;
+ }
+ if(Adapter->eNVMType != NVM_FLASH)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Connected device does not have flash");
+ Status = -EINVAL;
+ break;
+ }
+ if(IsFlash2x(Adapter) == TRUE)
+ {
+
+ if(IoBuffer.OutputLength < sizeof(FLASH2X_CS_INFO))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Passed buffer size:0x%lX is insufficient for the CS structure.. \nRequired size :0x%x ",IoBuffer.OutputLength, sizeof(FLASH2X_CS_INFO));
+ Status = -EINVAL;
+ break;
+ }
+
+ Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)Adapter->psFlash2xCSInfo, sizeof(FLASH2X_CS_INFO));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash2x cs info failed");
+ break;
+ }
+ }
+ else
+ {
+ if(IoBuffer.OutputLength < sizeof(FLASH_CS_INFO))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0," Passed buffer size:0x%lX is insufficient for the CS structure.. Required size :0x%u ",IoBuffer.OutputLength, sizeof(FLASH_CS_INFO));
+ Status = -EINVAL;
+ break;
+ }
+ Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)Adapter->psFlashCSInfo, sizeof(FLASH_CS_INFO));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copying Flash CS info failed");
+ break;
+ }
+
+ }
+ }
+ break ;
+ case IOCTL_BCM_SELECT_DSD :
+ {
+ UINT SectOfset = 0;
+ FLASH2X_SECTION_VAL eFlash2xSectionVal;
+ eFlash2xSectionVal = NO_SECTION_VAL ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, " IOCTL_BCM_SELECT_DSD Called");
+
+ if(IsFlash2x(Adapter) != TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash Does not have 2.x map");
+ return -EINVAL;
+ }
+
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ return Status;
+ }
+ Status = copy_from_user((PCHAR)&eFlash2xSectionVal,(PCHAR)IoBuffer.InputBuffer, sizeof(INT));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of flash section val failed");
+ return Status;
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Read Section :%d", eFlash2xSectionVal);
+ if((eFlash2xSectionVal != DSD0) &&
+ (eFlash2xSectionVal != DSD1) &&
+ (eFlash2xSectionVal != DSD2) )
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Passed section<%x> is not DSD section", eFlash2xSectionVal);
+ return STATUS_FAILURE ;
+ }
+
+ SectOfset= BcmGetSectionValStartOffset(Adapter,eFlash2xSectionVal);
+ if(SectOfset == INVALID_OFFSET)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Provided Section val <%d> does not exixt in Flash 2.x", eFlash2xSectionVal);
+ return -EINVAL;
+ }
+
+ Adapter->bAllDSDWriteAllow = TRUE ;
+
+ Adapter->ulFlashCalStart = SectOfset ;
+ Adapter->eActiveDSD = eFlash2xSectionVal;
+ }
+ Status = STATUS_SUCCESS ;
+ break;
+
+ case IOCTL_BCM_NVM_RAW_READ :
+ {
+
+ NVM_READWRITE stNVMRead = {0};
+ INT NOB ;
+ INT BuffSize ;
+ INT ReadOffset = 0;
+ UINT ReadBytes = 0 ;
+ PUCHAR pReadBuff = NULL ;
+ PUCHAR OutPutBuff = NULL ;
+
+ if(Adapter->eNVMType != NVM_FLASH)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"NVM TYPE is not Flash ");
+ return -EINVAL ;
+ }
+
+ /* Copy Ioctl Buffer structure */
+ if(copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy_from_user 1 failed\n");
+ Status = -EFAULT;
+ break;
+ }
+
+ if(copy_from_user(&stNVMRead, (PUCHAR)IoBuffer.OutputBuffer,sizeof(NVM_READWRITE)))
+ {
+ Status = -EFAULT;
+ break;
+ }
+
+ NOB = stNVMRead.uiNumBytes;
+ //In Raw-Read max Buff size : 64MB
+
+ if(NOB > DEFAULT_BUFF_SIZE)
+ BuffSize = DEFAULT_BUFF_SIZE;
+ else
+ BuffSize = NOB ;
+
+ ReadOffset = stNVMRead.uiOffset ;
+ OutPutBuff = (PUCHAR)(stNVMRead.pBuffer) ;
+
+
+ pReadBuff = (PCHAR)kzalloc(BuffSize , GFP_KERNEL);
+ if(pReadBuff == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Memory allocation failed for Flash 2.x Read Structure");
+ Status = -ENOMEM;
+ break;
+ }
+ down(&Adapter->NVMRdmWrmLock);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Device is in Idle/Shutdown Mode\n");
+ bcm_kfree(pReadBuff);
+ up(&Adapter->NVMRdmWrmLock);
+ return -EACCES;
+ }
+
+ Adapter->bFlashRawRead = TRUE ;
+ while(NOB)
+ {
+ if(NOB > DEFAULT_BUFF_SIZE )
+ ReadBytes = DEFAULT_BUFF_SIZE;
+ else
+ ReadBytes = NOB;
+
+ //Reading the data from Flash 2.x
+ Status = BeceemNVMRead(Adapter,(PUINT)pReadBuff,ReadOffset,ReadBytes);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Flash 2x read err with Status :%d", Status);
+ break;
+ }
+
+ BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,pReadBuff, ReadBytes);
+
+ Status = copy_to_user(OutPutBuff, pReadBuff,ReadBytes);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy to use failed with status :%d", Status);
+ break;
+ }
+ NOB = NOB - ReadBytes;
+ if(NOB)
+ {
+ ReadOffset = ReadOffset + ReadBytes ;
+ OutPutBuff = OutPutBuff + ReadBytes ;
+ }
+
+ }
+ Adapter->bFlashRawRead = FALSE ;
+ up(&Adapter->NVMRdmWrmLock);
+ bcm_kfree(pReadBuff);
+ break ;
+ }
+
+ case IOCTL_BCM_CNTRLMSG_MASK:
+ {
+ ULONG RxCntrlMsgBitMask = 0 ;
+
+ /* Copy Ioctl Buffer structure */
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of Ioctl buffer is failed from user space");
+ break;
+ }
+
+ Status = copy_from_user(&RxCntrlMsgBitMask, IoBuffer.InputBuffer, IoBuffer.InputLength);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"copy of control bit mask failed from user space");
+ break;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"\n Got user defined cntrl msg bit mask :%lx", RxCntrlMsgBitMask);
+ pTarang->RxCntrlMsgBitMask = RxCntrlMsgBitMask ;
+ }
+ break;
+ case IOCTL_BCM_GET_DEVICE_DRIVER_INFO:
+ {
+ DEVICE_DRIVER_INFO DevInfo;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n");
+
+ DevInfo.MaxRDMBufferSize = BUFFER_4K;
+ DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START;
+ DevInfo.u32RxAlignmentCorrection = 0;
+ DevInfo.u32NVMType = Adapter->eNVMType;
+ DevInfo.u32InterfaceType = BCM_USB;
+
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ break;
+ }
+ if(IoBuffer.OutputLength < sizeof(DevInfo))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"User Passed buffer length is less than actural buffer size");
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"user passed buffer size :0x%lX, expected size :0x%x",IoBuffer.OutputLength, sizeof(DevInfo));
+ Status = -EINVAL;
+ break;
+ }
+ Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)&DevInfo, sizeof(DevInfo));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copying Dev info structure to user space buffer failed");
+ break;
+ }
+ }
+ break ;
+
+ case IOCTL_BCM_TIME_SINCE_NET_ENTRY:
+ {
+ ST_TIME_ELAPSED stTimeElapsedSinceNetEntry = {0};
+ struct timeval tv = {0} ;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL,"IOCTL_BCM_TIME_SINCE_NET_ENTRY called");
+
+ Status = copy_from_user((PCHAR)&IoBuffer, (PCHAR)arg, sizeof(IOCTL_BUFFER));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy of IOCTL BUFFER failed");
+ break;
+ }
+ if(IoBuffer.OutputLength < sizeof(ST_TIME_ELAPSED))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"User Passed buffer length:0x%lx is less than expected buff size :0x%X",IoBuffer.OutputLength,sizeof(ST_TIME_ELAPSED));
+ Status = -EINVAL;
+ break;
+ }
+
+ //stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = Adapter->liTimeSinceLastNetEntry;
+ do_gettimeofday(&tv);
+ stTimeElapsedSinceNetEntry.ul64TimeElapsedSinceNetEntry = tv.tv_sec - Adapter->liTimeSinceLastNetEntry;
+
+ Status = copy_to_user((PCHAR)IoBuffer.OutputBuffer, (PCHAR)&stTimeElapsedSinceNetEntry, sizeof(ST_TIME_ELAPSED));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"copying ST_TIME_ELAPSED structure to user space buffer failed");
+ break;
+ }
+
+ }
+ break;
+
+ default:
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "wrong input %x",cmd);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "In default ioctl %d\n", cmd);
+ Status = STATUS_FAILURE;
+
+ break;
+ }
+ return Status;
+}
+
+
+static struct file_operations bcm_fops = {
+ .owner = THIS_MODULE,
+ .open = bcm_char_open,
+ .release = bcm_char_release,
+ .read = bcm_char_read,
+ .unlocked_ioctl = bcm_char_ioctl,
+};
+
+
+int register_control_device_interface(PMINI_ADAPTER Adapter)
+{
+ if(Adapter->major>0)
+ return Adapter->major;
+ Adapter->major = register_chrdev(0, "tarang", &bcm_fops);
+ if(Adapter->major < 0)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "register_chrdev:Failed to registering WiMax control char device!");
+ return Adapter->major;
+ }
+
+ bcm_class = NULL;
+ bcm_class = class_create (THIS_MODULE, "tarang");
+ if(IS_ERR (bcm_class))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unable to create class\n");
+ unregister_chrdev(Adapter->major, "tarang");
+ Adapter->major = 0;
+ return -ENODEV;
+ }
+ Adapter->pstCreatedClassDevice = device_create (bcm_class, NULL,
+ MKDEV(Adapter->major, 0),
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
+ NULL ,
+#endif
+ "tarang");
+
+ if(IS_ERR(Adapter->pstCreatedClassDevice))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "class device did not get created : %ld", PTR_ERR(Adapter->pstCreatedClassDevice) );
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Got Major No: %d", Adapter->major);
+ return 0;
+}
+
+void unregister_control_device_interface(PMINI_ADAPTER Adapter)
+{
+ if(Adapter->major > 0)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "destroying class device");
+ device_destroy (bcm_class, MKDEV(Adapter->major, 0));
+ }
+ if(!IS_ERR(bcm_class))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "destroying created class ");
+ class_destroy (bcm_class);
+ bcm_class = NULL;
+ }
+ if(Adapter->major > 0)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"unregistering character interface");
+ unregister_chrdev(Adapter->major, "tarang");
+ }
+
+}
diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c
new file mode 100644
index 00000000000..d4f4800ca5d
--- /dev/null
+++ b/drivers/staging/bcm/Bcmnet.c
@@ -0,0 +1,266 @@
+#include "headers.h"
+
+static INT bcm_notify_event(struct notifier_block *nb, ULONG event, PVOID dev)
+{
+ struct net_device *ndev = (struct net_device*)dev;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ //PMINI_ADAPTER Adapter = (PMINI_ADAPTER)ndev->priv;
+ if(strncmp(ndev->name,gblpnetdev->name,5)==0)
+ {
+ switch(event)
+ {
+ case NETDEV_CHANGEADDR:
+ case NETDEV_GOING_DOWN:
+ /*ignore this */
+ break;
+ case NETDEV_DOWN:
+ break;
+
+ case NETDEV_UP:
+ break;
+
+ case NETDEV_REGISTER:
+ /* Increment the Reference Count for "veth0" */
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register RefCount: %x\n",
+ atomic_read(&ndev->refcnt));
+ atomic_inc(&ndev->refcnt);
+ break;
+
+ case NETDEV_UNREGISTER:
+ /* Decrement the Reference Count for "veth0" */
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregister RefCnt: %x\n",
+ atomic_read(&ndev->refcnt));
+ atomic_dec(&ndev->refcnt);
+ if((int)atomic_read(&ndev->refcnt) < 0)
+ atomic_set(&ndev->refcnt, 0);
+ break;
+ };
+ }
+ return NOTIFY_DONE;
+}
+
+/* Notifier block to receive netdevice events */
+static struct notifier_block bcm_notifier_block =
+{
+ .notifier_call = bcm_notify_event,
+};
+
+struct net_device *gblpnetdev;
+/***************************************************************************************/
+/* proto-type of lower function */
+#ifdef BCM_SHM_INTERFACE
+const char *bcmVirtDeviceName="bcmeth";
+#endif
+
+static INT bcm_open(struct net_device *dev)
+{
+ PMINI_ADAPTER Adapter = NULL ; //(PMINI_ADAPTER)dev->priv;
+ Adapter = GET_BCM_ADAPTER(dev);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "======>");
+ if(Adapter->fw_download_done==FALSE)
+ return -EINVAL;
+ Adapter->if_up=1;
+ if(Adapter->LinkUpStatus == 1){
+ if(netif_queue_stopped(Adapter->dev)){
+ netif_carrier_on(Adapter->dev);
+ netif_start_queue(Adapter->dev);
+ }
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "<======");
+ return 0;
+}
+
+static INT bcm_close(struct net_device *dev)
+{
+ PMINI_ADAPTER Adapter = NULL ;//gpadapter ;
+ Adapter = GET_BCM_ADAPTER(dev);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=====>");
+ Adapter->if_up=0;
+ if(!netif_queue_stopped(dev)) {
+ netif_carrier_off(dev);
+ netif_stop_queue(dev);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"<=====");
+ return 0;
+}
+
+static struct net_device_stats *bcm_get_stats(struct net_device *dev)
+{
+ PLINUX_DEP_DATA pLinuxData=NULL;
+ PMINI_ADAPTER Adapter = NULL ;// gpadapter ;
+ Adapter = GET_BCM_ADAPTER(dev);
+ pLinuxData = (PLINUX_DEP_DATA)(Adapter->pvOsDepData);
+
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Dev = %p, pLinuxData = %p", dev, pLinuxData);
+ pLinuxData->netstats.rx_packets=atomic_read(&Adapter->RxRollOverCount)*64*1024+Adapter->PrevNumRecvDescs;
+ pLinuxData->netstats.rx_bytes=atomic_read(&Adapter->GoodRxByteCount)+atomic_read(&Adapter->BadRxByteCount);
+ pLinuxData->netstats.rx_dropped=atomic_read(&Adapter->RxPacketDroppedCount);
+ pLinuxData->netstats.rx_errors=atomic_read(&Adapter->RxPacketDroppedCount);
+ pLinuxData->netstats.rx_length_errors=0;
+ pLinuxData->netstats.rx_frame_errors=0;
+ pLinuxData->netstats.rx_crc_errors=0;
+ pLinuxData->netstats.tx_bytes=atomic_read(&Adapter->GoodTxByteCount);
+ pLinuxData->netstats.tx_packets=atomic_read(&Adapter->TxTotalPacketCount);
+ pLinuxData->netstats.tx_dropped=atomic_read(&Adapter->TxDroppedPacketCount);
+
+ return &(pLinuxData->netstats);
+}
+/**
+@ingroup init_functions
+Register other driver entry points with the kernel
+*/
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
+struct net_device_ops bcmNetDevOps = {
+ .ndo_open = bcm_open,
+ .ndo_stop = bcm_close,
+ .ndo_get_stats = bcm_get_stats,
+ .ndo_start_xmit = bcm_transmit,
+ .ndo_change_mtu = eth_change_mtu,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_validate_addr = eth_validate_addr,
+};
+#endif
+
+int register_networkdev(PMINI_ADAPTER Adapter)
+{
+ int result=0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ int *temp = NULL ;
+#endif
+ Adapter->dev = alloc_etherdev(sizeof(PMINI_ADAPTER));
+ if(!Adapter->dev)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "ERR: No Dev");
+ return -ENOMEM;
+ }
+ gblpnetdev = Adapter->dev;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+ Adapter->dev->priv = Adapter;
+#else
+ temp = netdev_priv(Adapter->dev);
+ *temp = (UINT)Adapter;
+#endif
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "init adapterptr: %x %x\n", (UINT)Adapter, temp);
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
+ Adapter->dev->netdev_ops = &bcmNetDevOps;
+#else
+ Adapter->dev->open = bcm_open;
+ Adapter->dev->stop = bcm_close;
+ Adapter->dev->get_stats = bcm_get_stats;
+ Adapter->dev->hard_start_xmit = bcm_transmit;
+ Adapter->dev->hard_header_len = ETH_HLEN + LEADER_SIZE;
+#endif
+
+#ifndef BCM_SHM_INTERFACE
+ Adapter->dev->mtu = MTU_SIZE; /* 1400 Bytes */
+ /* Read the MAC Address from EEPROM */
+ ReadMacAddressFromNVM(Adapter);
+
+
+ /* Register the notifier block for getting netdevice events */
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering netdevice notifier\n");
+ result = register_netdevice_notifier(&bcm_notifier_block);
+ if(result)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM Notifier Block did not get registered");
+ Adapter->bNetdeviceNotifierRegistered = FALSE;
+ return result;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM Notifier got Registered");
+ Adapter->bNetdeviceNotifierRegistered = TRUE;
+ }
+
+#else
+
+ Adapter->dev->mtu = CPE_MTU_SIZE;
+
+#if 0
+ //for CPE - harcode the virtual mac address
+ Adapter->dev->dev_addr[0] = MII_WIMAX_MACADDRESS[0];
+ Adapter->dev->dev_addr[1] = MII_WIMAX_MACADDRESS[1];
+ Adapter->dev->dev_addr[2] = MII_WIMAX_MACADDRESS[2];
+ Adapter->dev->dev_addr[3] = MII_WIMAX_MACADDRESS[3];
+ Adapter->dev->dev_addr[4] = MII_WIMAX_MACADDRESS[4];
+ Adapter->dev->dev_addr[5] = MII_WIMAX_MACADDRESS[5];
+#else
+ ReadMacAddressFromNVM(Adapter);
+#endif
+ strcpy(Adapter->dev->name, bcmVirtDeviceName); //Copy the device name
+
+#endif
+
+ result = register_netdev(Adapter->dev);
+ if (!result)
+ {
+ Adapter->bNetworkInterfaceRegistered = TRUE ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Beceem Network device name is %s!", Adapter->dev->name);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Network device can not be registered!");
+ Adapter->bNetworkInterfaceRegistered = FALSE ;
+ return result;
+ }
+
+#if 0
+ Adapter->stDebugState.debug_level = DBG_LVL_CURR;
+ Adapter->stDebugState.type =(UINT)0xffffffff;
+ Adapter->stDebugState.subtype[DBG_TYPE_OTHERS] = 0xffffffff;
+ Adapter->stDebugState.subtype[DBG_TYPE_RX] = 0xffffffff;
+ Adapter->stDebugState.subtype[DBG_TYPE_TX] = 0xffffffff;
+ Adapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xffffffff;
+
+ printk("-------ps_adapter->stDebugState.type=%x\n",Adapter->stDebugState.type);
+ printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_OTHERS]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_OTHERS]);
+ printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_RX]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_RX]);
+ printk("-------ps_adapter->stDebugState.subtype[DBG_TYPE_TX]=%x\n",Adapter->stDebugState.subtype[DBG_TYPE_TX]);
+#endif
+
+ return 0;
+}
+
+void bcm_unregister_networkdev(PMINI_ADAPTER Adapter)
+{
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregistering the Net Dev...\n");
+ if(Adapter->dev && !IS_ERR(Adapter->dev) && Adapter->bNetworkInterfaceRegistered)
+ unregister_netdev(Adapter->dev);
+ /* Unregister the notifier block */
+ if(Adapter->bNetdeviceNotifierRegistered == TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregistering netdevice notifier\n");
+ unregister_netdevice_notifier(&bcm_notifier_block);
+ }
+}
+
+static int bcm_init(void)
+{
+ int result;
+ result = InterfaceInitialize();
+ if(result)
+ {
+ printk("Initialisation failed for usbbcm");
+ }
+ else
+ {
+ printk("Initialised usbbcm");
+ }
+ return result;
+}
+
+
+static void bcm_exit(void)
+{
+ printk("%s %s Calling InterfaceExit\n",__FILE__, __FUNCTION__);
+ InterfaceExit();
+ printk("%s %s InterfaceExit returned\n",__FILE__, __FUNCTION__);
+}
+
+module_init(bcm_init);
+module_exit(bcm_exit);
+MODULE_LICENSE ("GPL");
+
+
diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c
new file mode 100644
index 00000000000..d1a66833998
--- /dev/null
+++ b/drivers/staging/bcm/CmHost.c
@@ -0,0 +1,2443 @@
+/************************************************************
+* CMHOST.C
+* This file contains the routines for handling Connnection
+* Management.
+************************************************************/
+
+//#define CONN_MSG
+#include "headers.h"
+
+typedef enum _E_CLASSIFIER_ACTION
+{
+ eInvalidClassifierAction,
+ eAddClassifier,
+ eReplaceClassifier,
+ eDeleteClassifier
+}E_CLASSIFIER_ACTION;
+
+
+/************************************************************
+* Function - SearchSfid
+*
+* Description - This routinue would search QOS queues having
+* specified SFID as input parameter.
+*
+* Parameters - Adapter: Pointer to the Adapter structure
+* uiSfid : Given SFID for matching
+*
+* Returns - Queue index for this SFID(If matched)
+ Else Invalid Queue Index(If Not matched)
+************************************************************/
+__inline INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid)
+{
+ INT iIndex=0;
+ for(iIndex=(NO_OF_QUEUES-1); iIndex>=0; iIndex--)
+ if(Adapter->PackInfo[iIndex].ulSFID==uiSfid)
+ return iIndex;
+ return NO_OF_QUEUES+1;
+}
+
+/***************************************************************
+* Function - SearchFreeSfid
+*
+* Description - This routinue would search Free available SFID.
+*
+* Parameter - Adapter: Pointer to the Adapter structure
+*
+* Returns - Queue index for the free SFID
+* Else returns Invalid Index.
+****************************************************************/
+__inline INT SearchFreeSfid(PMINI_ADAPTER Adapter)
+{
+ UINT uiIndex=0;
+ for(uiIndex=0; uiIndex < (NO_OF_QUEUES-1); uiIndex++)
+ if(Adapter->PackInfo[uiIndex].ulSFID==0)
+ return uiIndex;
+ return NO_OF_QUEUES+1;
+}
+
+__inline int SearchVcid(PMINI_ADAPTER Adapter,unsigned short usVcid)
+{
+ int iIndex=0;
+ for(iIndex=(NO_OF_QUEUES-1);iIndex>=0;iIndex--)
+ if(Adapter->PackInfo[iIndex].usVCID_Value == usVcid)
+ return iIndex;
+ return NO_OF_QUEUES+1;
+
+}
+
+
+/*
+Function: SearchClsid
+Description: This routinue would search Classifier having specified ClassifierID as input parameter
+Input parameters: PMINI_ADAPTER Adapter - Adapter Context
+ unsigned int uiSfid - The SF in which the classifier is to searched
+ B_UINT16 uiClassifierID - The classifier ID to be searched
+Return: int :Classifier table index of matching entry
+*/
+
+__inline int SearchClsid(PMINI_ADAPTER Adapter,ULONG ulSFID,B_UINT16 uiClassifierID)
+{
+ unsigned int uiClassifierIndex = 0;
+ for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++)
+ {
+ if((Adapter->astClassifierTable[uiClassifierIndex].bUsed) &&
+ (Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex == uiClassifierID)&&
+ (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == ulSFID))
+ return uiClassifierIndex;
+ }
+ return MAX_CLASSIFIERS+1;
+}
+
+/**
+@ingroup ctrl_pkt_functions
+This routinue would search Free available Classifier entry in classifier table.
+@return free Classifier Entry index in classifier table for specified SF
+*/
+static __inline int SearchFreeClsid(PMINI_ADAPTER Adapter /**Adapter Context*/
+ )
+{
+ unsigned int uiClassifierIndex = 0;
+ for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++)
+ {
+ if(!Adapter->astClassifierTable[uiClassifierIndex].bUsed)
+ return uiClassifierIndex;
+ }
+ return MAX_CLASSIFIERS+1;
+}
+
+VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex)
+{
+ //deleting all the packet held in the SF
+ flush_queue(Adapter,uiSearchRuleIndex);
+
+ //Deleting the all classifiers for this SF
+ DeleteAllClassifiersForSF(Adapter,uiSearchRuleIndex);
+
+ //Resetting only MIBS related entries in the SF
+ memset((PVOID)&Adapter->PackInfo[uiSearchRuleIndex], 0, sizeof(S_MIBS_SERVICEFLOW_TABLE));
+}
+
+static inline VOID
+CopyIpAddrToClassifier(S_CLASSIFIER_RULE *pstClassifierEntry ,
+ B_UINT8 u8IpAddressLen , B_UINT8 *pu8IpAddressMaskSrc ,
+ BOOLEAN bIpVersion6 , E_IPADDR_CONTEXT eIpAddrContext)
+{
+ UINT ucLoopIndex=0;
+ UINT nSizeOfIPAddressInBytes = IP_LENGTH_OF_ADDRESS;
+ UCHAR *ptrClassifierIpAddress = NULL;
+ UCHAR *ptrClassifierIpMask = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+ if(bIpVersion6)
+ {
+ nSizeOfIPAddressInBytes = IPV6_ADDRESS_SIZEINBYTES;
+ }
+ //Destination Ip Address
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Address Range Length:0x%X ",
+ u8IpAddressLen);
+ if((bIpVersion6?(IPV6_ADDRESS_SIZEINBYTES * MAX_IP_RANGE_LENGTH * 2):
+ (TOTAL_MASKED_ADDRESS_IN_BYTES)) >= u8IpAddressLen)
+ {
+ /*
+ //checking both the mask and address togethor in Classification.
+ //So length will be : TotalLengthInBytes/nSizeOfIPAddressInBytes * 2
+ //(nSizeOfIPAddressInBytes for address and nSizeOfIPAddressInBytes for mask)
+ */
+ if(eIpAddrContext == eDestIpAddress)
+ {
+ pstClassifierEntry->ucIPDestinationAddressLength =
+ u8IpAddressLen/(nSizeOfIPAddressInBytes * 2);
+ if(bIpVersion6)
+ {
+ ptrClassifierIpAddress =
+ pstClassifierEntry->stDestIpAddress.ucIpv6Address;
+ ptrClassifierIpMask =
+ pstClassifierEntry->stDestIpAddress.ucIpv6Mask;
+ }
+ else
+ {
+ ptrClassifierIpAddress =
+ pstClassifierEntry->stDestIpAddress.ucIpv4Address;
+ ptrClassifierIpMask =
+ pstClassifierEntry->stDestIpAddress.ucIpv4Mask;
+ }
+ }
+ else if(eIpAddrContext == eSrcIpAddress)
+ {
+ pstClassifierEntry->ucIPSourceAddressLength =
+ u8IpAddressLen/(nSizeOfIPAddressInBytes * 2);
+ if(bIpVersion6)
+ {
+ ptrClassifierIpAddress =
+ pstClassifierEntry->stSrcIpAddress.ucIpv6Address;
+ ptrClassifierIpMask =
+ pstClassifierEntry->stSrcIpAddress.ucIpv6Mask;
+ }
+ else
+ {
+ ptrClassifierIpAddress =
+ pstClassifierEntry->stSrcIpAddress.ucIpv4Address;
+ ptrClassifierIpMask =
+ pstClassifierEntry->stSrcIpAddress.ucIpv4Mask;
+ }
+ }
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Address Length:0x%X \n",
+ pstClassifierEntry->ucIPDestinationAddressLength);
+ while((u8IpAddressLen>= nSizeOfIPAddressInBytes) &&
+ (ucLoopIndex < MAX_IP_RANGE_LENGTH))
+ {
+ memcpy(ptrClassifierIpAddress +
+ (ucLoopIndex * nSizeOfIPAddressInBytes),
+ (pu8IpAddressMaskSrc+(ucLoopIndex*nSizeOfIPAddressInBytes*2)),
+ nSizeOfIPAddressInBytes);
+ if(!bIpVersion6)
+ {
+ if(eIpAddrContext == eSrcIpAddress)
+ {
+ pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[ucLoopIndex]=
+ ntohl(pstClassifierEntry->stSrcIpAddress.
+ ulIpv4Addr[ucLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Src Ip Address:0x%luX ",pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[ucLoopIndex]);
+ }
+ else if(eIpAddrContext == eDestIpAddress)
+ {
+ pstClassifierEntry->stDestIpAddress.ulIpv4Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress.
+ ulIpv4Addr[ucLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Dest Ip Address:0x%luX ",pstClassifierEntry->stDestIpAddress.ulIpv4Addr[ucLoopIndex]);
+ }
+ }
+ u8IpAddressLen-=nSizeOfIPAddressInBytes;
+ if(u8IpAddressLen >= nSizeOfIPAddressInBytes)
+ {
+ memcpy(ptrClassifierIpMask +
+ (ucLoopIndex * nSizeOfIPAddressInBytes),
+ (pu8IpAddressMaskSrc+nSizeOfIPAddressInBytes +
+ (ucLoopIndex*nSizeOfIPAddressInBytes*2)),
+ nSizeOfIPAddressInBytes);
+ if(!bIpVersion6)
+ {
+ if(eIpAddrContext == eSrcIpAddress)
+ {
+ pstClassifierEntry->stSrcIpAddress.
+ ulIpv4Mask[ucLoopIndex]=
+ ntohl(pstClassifierEntry->stSrcIpAddress.
+ ulIpv4Mask[ucLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Src Ip Mask Address:0x%luX ",pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[ucLoopIndex]);
+ }
+ else if(eIpAddrContext == eDestIpAddress)
+ {
+ pstClassifierEntry->stDestIpAddress.
+ ulIpv4Mask[ucLoopIndex] =
+ ntohl(pstClassifierEntry->stDestIpAddress.
+ ulIpv4Mask[ucLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Dest Ip Mask Address:0x%luX ",pstClassifierEntry->stDestIpAddress.ulIpv4Mask[ucLoopIndex]);
+ }
+ }
+ u8IpAddressLen-=nSizeOfIPAddressInBytes;
+ }
+ if(0==u8IpAddressLen)
+ {
+ pstClassifierEntry->bDestIpValid=TRUE;
+ }
+ ucLoopIndex++;
+ }
+ if(bIpVersion6)
+ {
+ //Restore EndianNess of Struct
+ for(ucLoopIndex =0 ; ucLoopIndex < MAX_IP_RANGE_LENGTH * 4 ;
+ ucLoopIndex++)
+ {
+ if(eIpAddrContext == eSrcIpAddress)
+ {
+ pstClassifierEntry->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]=
+ ntohl(pstClassifierEntry->stSrcIpAddress.
+ ulIpv6Addr[ucLoopIndex]);
+ pstClassifierEntry->stSrcIpAddress.ulIpv6Mask[ucLoopIndex]= ntohl(pstClassifierEntry->stSrcIpAddress.
+ ulIpv6Mask[ucLoopIndex]);
+ }
+ else if(eIpAddrContext == eDestIpAddress)
+ {
+ pstClassifierEntry->stDestIpAddress.ulIpv6Addr[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress.
+ ulIpv6Addr[ucLoopIndex]);
+ pstClassifierEntry->stDestIpAddress.ulIpv6Mask[ucLoopIndex]= ntohl(pstClassifierEntry->stDestIpAddress.
+ ulIpv6Mask[ucLoopIndex]);
+ }
+ }
+ }
+ }
+}
+
+
+void ClearTargetDSXBuffer(PMINI_ADAPTER Adapter,B_UINT16 TID,BOOLEAN bFreeAll)
+{
+ ULONG ulIndex;
+ for(ulIndex=0; ulIndex < Adapter->ulTotalTargetBuffersAvailable; ulIndex++)
+ {
+ if(Adapter->astTargetDsxBuffer[ulIndex].valid)
+ continue;
+ if ((bFreeAll) || (Adapter->astTargetDsxBuffer[ulIndex].tid == TID)){
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "ClearTargetDSXBuffer: found tid %d buffer cleared %lx\n",
+ TID, Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer);
+ Adapter->astTargetDsxBuffer[ulIndex].valid=1;
+ Adapter->astTargetDsxBuffer[ulIndex].tid=0;
+ Adapter->ulFreeTargetBufferCnt++;
+ }
+ }
+}
+
+/**
+@ingroup ctrl_pkt_functions
+copy classifier rule into the specified SF index
+*/
+static inline VOID CopyClassifierRuleToSF(PMINI_ADAPTER Adapter,stConvergenceSLTypes *psfCSType,UINT uiSearchRuleIndex,UINT nClassifierIndex)
+{
+ S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+ //VOID *pvPhsContext = NULL;
+ UINT ucLoopIndex=0;
+ //UCHAR ucProtocolLength=0;
+ //ULONG ulPhsStatus;
+
+
+ if(Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value == 0 ||
+ nClassifierIndex > (MAX_CLASSIFIERS-1))
+ return;
+
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Storing Classifier Rule Index : %X",ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex));
+
+ if(nClassifierIndex > MAX_CLASSIFIERS-1)
+ return;
+
+ pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex];
+ if(pstClassifierEntry)
+ {
+ //Store if Ipv6
+ pstClassifierEntry->bIpv6Protocol =
+ (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)?TRUE:FALSE;
+
+ //Destinaiton Port
+ pstClassifierEntry->ucDestPortRangeLength=psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength/4;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Destination Port Range Length:0x%X ",pstClassifierEntry->ucDestPortRangeLength);
+ if( MAX_PORT_RANGE >= psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength)
+ {
+ for(ucLoopIndex=0;ucLoopIndex<(pstClassifierEntry->ucDestPortRangeLength);ucLoopIndex++)
+ {
+ pstClassifierEntry->usDestPortRangeLo[ucLoopIndex] =
+ *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+ucLoopIndex));
+ pstClassifierEntry->usDestPortRangeHi[ucLoopIndex] =
+ *((PUSHORT)(psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange+2+ucLoopIndex));
+ pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]=ntohs(pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Destination Port Range Lo:0x%X ",pstClassifierEntry->usDestPortRangeLo[ucLoopIndex]);
+ pstClassifierEntry->usDestPortRangeHi[ucLoopIndex]=ntohs(pstClassifierEntry->usDestPortRangeHi[ucLoopIndex]);
+ }
+ }
+ else
+ {
+ pstClassifierEntry->ucDestPortRangeLength=0;
+ }
+ //Source Port
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Source Port Range Length:0x%X ",psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength);
+ if(MAX_PORT_RANGE >=
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength)
+ {
+ pstClassifierEntry->ucSrcPortRangeLength =
+ psfCSType->cCPacketClassificationRule.
+ u8ProtocolSourcePortRangeLength/4;
+ for(ucLoopIndex = 0; ucLoopIndex <
+ (pstClassifierEntry->ucSrcPortRangeLength); ucLoopIndex++)
+ {
+ pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex] =
+ *((PUSHORT)(psfCSType->cCPacketClassificationRule.
+ u8ProtocolSourcePortRange+ucLoopIndex));
+ pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex] =
+ *((PUSHORT)(psfCSType->cCPacketClassificationRule.
+ u8ProtocolSourcePortRange+2+ucLoopIndex));
+ pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex] =
+ ntohs(pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Source Port Range Lo:0x%X ",pstClassifierEntry->usSrcPortRangeLo[ucLoopIndex]);
+ pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex]=ntohs(pstClassifierEntry->usSrcPortRangeHi[ucLoopIndex]);
+ }
+ }
+ //Destination Ip Address and Mask
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Destination Parameters : ");
+
+ CopyIpAddrToClassifier(pstClassifierEntry,
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength,
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddress,
+ (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)?
+ TRUE:FALSE, eDestIpAddress);
+
+ //Source Ip Address and Mask
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Ip Source Parameters : ");
+
+ CopyIpAddrToClassifier(pstClassifierEntry,
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength,
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress,
+ (Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion == IPV6)?TRUE:FALSE,
+ eSrcIpAddress);
+
+ //TOS
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"TOS Length:0x%X ",psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength);
+ if(3 == psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength)
+ {
+ pstClassifierEntry->ucIPTypeOfServiceLength =
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength;
+ pstClassifierEntry->ucTosLow =
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0];
+ pstClassifierEntry->ucTosHigh =
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1];
+ pstClassifierEntry->ucTosMask =
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2];
+ pstClassifierEntry->bTOSValid = TRUE;
+ }
+ if(psfCSType->cCPacketClassificationRule.u8Protocol == 0)
+ {
+ //we didnt get protocol field filled in by the BS
+ pstClassifierEntry->ucProtocolLength=0;
+ }
+ else
+ {
+ pstClassifierEntry->ucProtocolLength=1;// 1 valid protocol
+ }
+
+ pstClassifierEntry->ucProtocol[0] =
+ psfCSType->cCPacketClassificationRule.u8Protocol;
+
+ pstClassifierEntry->u8ClassifierRulePriority =
+ psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority;
+
+ //store the classifier rule ID and set this classifier entry as valid
+ pstClassifierEntry->ucDirection =
+ Adapter->PackInfo[uiSearchRuleIndex].ucDirection;
+ pstClassifierEntry->uiClassifierRuleIndex = ntohs(psfCSType->
+ cCPacketClassificationRule.u16PacketClassificationRuleIndex);
+ pstClassifierEntry->usVCID_Value =
+ Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
+ pstClassifierEntry->ulSFID =
+ Adapter->PackInfo[uiSearchRuleIndex].ulSFID;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Index %d Dir: %d, Index: %d, Vcid: %d\n",
+ uiSearchRuleIndex, pstClassifierEntry->ucDirection,
+ pstClassifierEntry->uiClassifierRuleIndex,
+ pstClassifierEntry->usVCID_Value);
+
+ if(psfCSType->cCPacketClassificationRule.u8AssociatedPHSI)
+ {
+ pstClassifierEntry->u8AssociatedPHSI = psfCSType->cCPacketClassificationRule.u8AssociatedPHSI;
+ }
+
+ //Copy ETH CS Parameters
+ pstClassifierEntry->ucEthCSSrcMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddressLength);
+ memcpy(pstClassifierEntry->au8EThCSSrcMAC,psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress,MAC_ADDRESS_SIZE);
+ memcpy(pstClassifierEntry->au8EThCSSrcMACMask,psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress+MAC_ADDRESS_SIZE,MAC_ADDRESS_SIZE);
+ pstClassifierEntry->ucEthCSDestMACLen = (psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
+ memcpy(pstClassifierEntry->au8EThCSDestMAC,psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress,MAC_ADDRESS_SIZE);
+ memcpy(pstClassifierEntry->au8EThCSDestMACMask,psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress+MAC_ADDRESS_SIZE,MAC_ADDRESS_SIZE);
+ pstClassifierEntry->ucEtherTypeLen = (psfCSType->cCPacketClassificationRule.u8EthertypeLength);
+ memcpy(pstClassifierEntry->au8EthCSEtherType,psfCSType->cCPacketClassificationRule.u8Ethertype,NUM_ETHERTYPE_BYTES);
+ memcpy(pstClassifierEntry->usUserPriority, &psfCSType->cCPacketClassificationRule.u16UserPriority, 2);
+ pstClassifierEntry->usVLANID = ntohs(psfCSType->cCPacketClassificationRule.u16VLANID);
+ pstClassifierEntry->usValidityBitMap = ntohs(psfCSType->cCPacketClassificationRule.u16ValidityBitMap);
+
+ pstClassifierEntry->bUsed = TRUE;
+ }
+}
+
+
+/**
+@ingroup ctrl_pkt_functions
+*/
+static inline VOID DeleteClassifierRuleFromSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex,UINT nClassifierIndex)
+{
+ S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+ B_UINT16 u16PacketClassificationRuleIndex;
+ USHORT usVCID;
+ //VOID *pvPhsContext = NULL;
+ //ULONG ulPhsStatus;
+
+ usVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
+
+ if(nClassifierIndex > MAX_CLASSIFIERS-1)
+ return;
+
+ if(usVCID == 0)
+ return;
+
+ u16PacketClassificationRuleIndex = Adapter->astClassifierTable[nClassifierIndex].uiClassifierRuleIndex;
+
+
+ pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex];
+ if(pstClassifierEntry)
+ {
+ pstClassifierEntry->bUsed = FALSE;
+ pstClassifierEntry->uiClassifierRuleIndex = 0;
+ memset(pstClassifierEntry,0,sizeof(S_CLASSIFIER_RULE));
+
+ //Delete the PHS Rule for this classifier
+ PhsDeleteClassifierRule(
+ &Adapter->stBCMPhsContext,
+ usVCID,
+ u16PacketClassificationRuleIndex);
+ }
+}
+
+/**
+@ingroup ctrl_pkt_functions
+*/
+VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex)
+{
+ S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+ UINT nClassifierIndex;
+ //B_UINT16 u16PacketClassificationRuleIndex;
+ USHORT ulVCID;
+ //VOID *pvPhsContext = NULL;
+ //ULONG ulPhsStatus;
+
+ ulVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
+
+ if(ulVCID == 0)
+ return;
+
+
+ for(nClassifierIndex =0 ; nClassifierIndex < MAX_CLASSIFIERS ; nClassifierIndex++)
+ {
+ if(Adapter->astClassifierTable[nClassifierIndex].usVCID_Value == ulVCID)
+ {
+ pstClassifierEntry = &Adapter->astClassifierTable[nClassifierIndex];
+ if(pstClassifierEntry->bUsed)
+ {
+ DeleteClassifierRuleFromSF(Adapter,uiSearchRuleIndex,nClassifierIndex);
+ }
+ }
+ }
+
+ //Delete All Phs Rules Associated with this SF
+ PhsDeleteSFRules(
+ &Adapter->stBCMPhsContext,
+ ulVCID);
+
+}
+
+
+/**
+This routinue copies the Connection Management
+related data into the Adapter structure.
+@ingroup ctrl_pkt_functions
+*/
+
+static VOID CopyToAdapter( register PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/
+ register pstServiceFlowParamSI psfLocalSet, /**<Pointer to the ServiceFlowParamSI structure*/
+ register UINT uiSearchRuleIndex, /**<Index of Queue, to which this data belongs*/
+ register UCHAR ucDsxType,
+ stLocalSFAddIndicationAlt *pstAddIndication)
+{
+ //UCHAR ucProtocolLength=0;
+ ULONG ulSFID;
+ UINT nClassifierIndex = 0;
+ E_CLASSIFIER_ACTION eClassifierAction = eInvalidClassifierAction;
+ B_UINT16 u16PacketClassificationRuleIndex=0;
+ UINT nIndex=0;
+ stConvergenceSLTypes *psfCSType = NULL;
+ S_PHS_RULE sPhsRule;
+ USHORT uVCID = Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value;
+ UINT UGIValue = 0;
+
+
+ Adapter->PackInfo[uiSearchRuleIndex].bValid=TRUE;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Search Rule Index = %d\n", uiSearchRuleIndex);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"%s: SFID= %x ",__FUNCTION__, ntohl(psfLocalSet->u32SFID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Updating Queue %d",uiSearchRuleIndex);
+
+ ulSFID = ntohl(psfLocalSet->u32SFID);
+ //Store IP Version used
+ //Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF
+
+ Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = 0;
+ Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0;
+
+ /*Enable IP/ETh CS Support As Required*/
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : u8CSSpecification : %X\n",psfLocalSet->u8CSSpecification);
+ switch(psfLocalSet->u8CSSpecification)
+ {
+ case eCSPacketIPV4:
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS;
+ break;
+ }
+ case eCSPacketIPV6:
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS;
+ break;
+ }
+
+ case eCS802_3PacketEthernet:
+ case eCS802_1QPacketVLAN:
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3;
+ break;
+ }
+
+ case eCSPacketIPV4Over802_1QVLAN:
+ case eCSPacketIPV4Over802_3Ethernet:
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS;
+ Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3;
+ break;
+ }
+
+ case eCSPacketIPV6Over802_1QVLAN:
+ case eCSPacketIPV6Over802_3Ethernet:
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS;
+ Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3;
+ break;
+ }
+
+ default:
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error in value of CS Classification.. setting default to IP CS\n");
+ Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS;
+ break;
+ }
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X \n",
+ uiSearchRuleIndex,
+ Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport,
+ Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport);
+
+ //Store IP Version used
+ //Get The Version Of IP used (IPv6 or IPv4) from CSSpecification field of SF
+ if(Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport == IPV6_CS)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV6;
+ }
+ else
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].ucIpVersion = IPV4;
+ }
+
+ /* To ensure that the ETH CS code doesn't gets executed if the BS doesn't supports ETH CS */
+ if(!Adapter->bETHCSEnabled)
+ Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = 0;
+
+ if(psfLocalSet->u8ServiceClassNameLength > 0 &&
+ psfLocalSet->u8ServiceClassNameLength < 32)
+ {
+ memcpy(Adapter->PackInfo[uiSearchRuleIndex].ucServiceClassName,
+ psfLocalSet->u8ServiceClassName,
+ psfLocalSet->u8ServiceClassNameLength);
+ }
+ Adapter->PackInfo[uiSearchRuleIndex].u8QueueType =
+ psfLocalSet->u8ServiceFlowSchedulingType;
+
+ if(Adapter->PackInfo[uiSearchRuleIndex].u8QueueType==BE &&
+ Adapter->PackInfo[uiSearchRuleIndex].ucDirection)
+ {
+ Adapter->usBestEffortQueueIndex=uiSearchRuleIndex;
+ }
+
+ Adapter->PackInfo[uiSearchRuleIndex].ulSFID = ntohl(psfLocalSet->u32SFID);
+
+ Adapter->PackInfo[uiSearchRuleIndex].u8TrafficPriority = psfLocalSet->u8TrafficPriority;
+
+ //copy all the classifier in the Service Flow param structure
+ for(nIndex=0; nIndex<psfLocalSet->u8TotalClassifiers; nIndex++)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Classifier index =%d",nIndex);
+ psfCSType = &psfLocalSet->cConvergenceSLTypes[nIndex];
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Classifier index =%d",nIndex);
+
+ if(psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority=TRUE;
+ }
+
+ if(psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bClassifierPriority=TRUE;
+ }
+
+
+ if(ucDsxType== DSA_ACK)
+ {
+ eClassifierAction = eAddClassifier;
+ }
+ else if(ucDsxType == DSC_ACK)
+ {
+ switch(psfCSType->u8ClassfierDSCAction)
+ {
+ case 0://DSC Add Classifier
+ {
+ eClassifierAction = eAddClassifier;
+ }
+ break;
+ case 1://DSC Replace Classifier
+ {
+ eClassifierAction = eReplaceClassifier;
+ }
+ break;
+ case 2://DSC Delete Classifier
+ {
+ eClassifierAction = eDeleteClassifier;
+
+ }
+ break;
+ default:
+ {
+ eClassifierAction = eInvalidClassifierAction;
+ }
+ }
+ }
+
+ u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);
+
+ switch(eClassifierAction)
+ {
+ case eAddClassifier:
+ {
+ //Get a Free Classifier Index From Classifier table for this SF to add the Classifier
+ //Contained in this message
+ nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex);
+
+ if(nClassifierIndex > MAX_CLASSIFIERS)
+ {
+ nClassifierIndex = SearchFreeClsid(Adapter);
+ if(nClassifierIndex > MAX_CLASSIFIERS)
+ {
+ //Failed To get a free Entry
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Failed To get a free Classifier Entry");
+ break;
+ }
+ //Copy the Classifier Rule for this service flow into our Classifier table maintained per SF.
+ CopyClassifierRuleToSF(Adapter,psfCSType,uiSearchRuleIndex,nClassifierIndex);
+ }
+
+ else
+ {
+ //This Classifier Already Exists and it is invalid to Add Classifier with existing PCRI
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"CopyToAdapter : Error The Specified Classifier Already Exists \
+ and attempted To Add Classifier with Same PCRI : 0x%x\n", u16PacketClassificationRuleIndex);
+ }
+ }
+ break;
+
+ case eReplaceClassifier:
+ {
+ //Get the Classifier Index From Classifier table for this SF and replace existing Classifier
+ //with the new classifier Contained in this message
+ nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex);
+ if(nClassifierIndex > MAX_CLASSIFIERS)
+ {
+ //Failed To search the classifier
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Search for Classifier To be replaced failed");
+ break;
+ }
+ //Copy the Classifier Rule for this service flow into our Classifier table maintained per SF.
+ CopyClassifierRuleToSF(Adapter,psfCSType,uiSearchRuleIndex,nClassifierIndex);
+ }
+ break;
+
+ case eDeleteClassifier:
+ {
+ //Get the Classifier Index From Classifier table for this SF and replace existing Classifier
+ //with the new classifier Contained in this message
+ nClassifierIndex = SearchClsid(Adapter,ulSFID,u16PacketClassificationRuleIndex);
+ if(nClassifierIndex > MAX_CLASSIFIERS)
+ {
+ //Failed To search the classifier
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Error Search for Classifier To be deleted failed");
+ break;
+ }
+
+ //Delete This classifier
+ DeleteClassifierRuleFromSF(Adapter,uiSearchRuleIndex,nClassifierIndex);
+ }
+ break;
+
+ default:
+ {
+ //Invalid Action for classifier
+ break;
+ }
+ }
+ }
+
+ //Repeat parsing Classification Entries to process PHS Rules
+ for(nIndex=0; nIndex < psfLocalSet->u8TotalClassifiers; nIndex++)
+ {
+ psfCSType = &psfLocalSet->cConvergenceSLTypes[nIndex];
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "psfCSType->u8PhsDSCAction : 0x%x\n",
+ psfCSType->u8PhsDSCAction );
+
+ switch (psfCSType->u8PhsDSCAction)
+ {
+ case eDeleteAllPHSRules:
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Deleting All PHS Rules For VCID: 0x%X\n",uVCID);
+
+ //Delete All the PHS rules for this Service flow
+
+ PhsDeleteSFRules(
+ &Adapter->stBCMPhsContext,
+ uVCID);
+
+ break;
+ }
+ case eDeletePHSRule:
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"PHS DSC Action = Delete PHS Rule \n");
+
+ if(psfCSType->cPhsRule.u8PHSI)
+ {
+ PhsDeletePHSRule(
+ &Adapter->stBCMPhsContext,
+ uVCID,
+ psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);
+ }
+ else
+ {
+ //BCM_DEBUG_PRINT(CONN_MSG,("Error CPHSRule.PHSI is ZERO \n"));
+ }
+ break;
+ }
+ default :
+ {
+ if(ucDsxType == DSC_ACK)
+ {
+ //BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC \n",psfCSType->cPhsRule.u8PHSI));
+ break; //FOr DSC ACK Case PHS DSC Action must be in valid set
+ }
+ }
+ //Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified
+ //No Break Here . Intentionally!
+
+ case eAddPHSRule:
+ case eSetPHSRule:
+ {
+ if(psfCSType->cPhsRule.u8PHSI)
+ {
+ //Apply This PHS Rule to all classifiers whose Associated PHSI Match
+ unsigned int uiClassifierIndex = 0;
+ if(pstAddIndication->u8Direction == UPLINK_DIR )
+ {
+ for(uiClassifierIndex=0;uiClassifierIndex<MAX_CLASSIFIERS;uiClassifierIndex++)
+ {
+ if((Adapter->astClassifierTable[uiClassifierIndex].bUsed) &&
+ (Adapter->astClassifierTable[uiClassifierIndex].ulSFID == Adapter->PackInfo[uiSearchRuleIndex].ulSFID) &&
+ (Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI == psfCSType->cPhsRule.u8PHSI))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adding PHS Rule For Classifier : 0x%x cPhsRule.u8PHSI : 0x%x\n",
+ Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex,
+ psfCSType->cPhsRule.u8PHSI);
+ //Update The PHS Rule for this classifier as Associated PHSI id defined
+
+ //Copy the PHS Rule
+ sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI;
+ sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength;
+ sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength;
+ sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS;
+ sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV;
+ memcpy(sPhsRule.u8PHSF,psfCSType->cPhsRule.u8PHSF,MAX_PHS_LENGTHS);
+ memcpy(sPhsRule.u8PHSM,psfCSType->cPhsRule.u8PHSM,MAX_PHS_LENGTHS);
+ sPhsRule.u8RefCnt = 0;
+ sPhsRule.bUnclassifiedPHSRule = FALSE;
+ sPhsRule.PHSModifiedBytes = 0;
+ sPhsRule.PHSModifiedNumPackets = 0;
+ sPhsRule.PHSErrorNumPackets = 0;
+
+ //bPHSRuleAssociated = TRUE;
+ //Store The PHS Rule for this classifier
+
+ PhsUpdateClassifierRule(
+ &Adapter->stBCMPhsContext,
+ uVCID,
+ Adapter->astClassifierTable[uiClassifierIndex].uiClassifierRuleIndex,
+ &sPhsRule,
+ Adapter->astClassifierTable[uiClassifierIndex].u8AssociatedPHSI);
+
+ //Update PHS Rule For the Classifier
+ if(sPhsRule.u8PHSI)
+ {
+ Adapter->astClassifierTable[uiClassifierIndex].u32PHSRuleID = sPhsRule.u8PHSI;
+ memcpy(&Adapter->astClassifierTable[uiClassifierIndex].sPhsRule,&sPhsRule,sizeof(S_PHS_RULE));
+ }
+
+ }
+ }
+ }
+ else
+ {
+ //Error PHS Rule specified in signaling could not be applied to any classifier
+
+ //Copy the PHS Rule
+ sPhsRule.u8PHSI = psfCSType->cPhsRule.u8PHSI;
+ sPhsRule.u8PHSFLength = psfCSType->cPhsRule.u8PHSFLength;
+ sPhsRule.u8PHSMLength = psfCSType->cPhsRule.u8PHSMLength;
+ sPhsRule.u8PHSS = psfCSType->cPhsRule.u8PHSS;
+ sPhsRule.u8PHSV = psfCSType->cPhsRule.u8PHSV;
+ memcpy(sPhsRule.u8PHSF,psfCSType->cPhsRule.u8PHSF,MAX_PHS_LENGTHS);
+ memcpy(sPhsRule.u8PHSM,psfCSType->cPhsRule.u8PHSM,MAX_PHS_LENGTHS);
+ sPhsRule.u8RefCnt = 0;
+ sPhsRule.bUnclassifiedPHSRule = TRUE;
+ sPhsRule.PHSModifiedBytes = 0;
+ sPhsRule.PHSModifiedNumPackets = 0;
+ sPhsRule.PHSErrorNumPackets = 0;
+ //Store The PHS Rule for this classifier
+
+ /*
+ Passing the argument u8PHSI instead of clsid. Because for DL with no classifier rule,
+ clsid will be zero hence we cant have multiple PHS rules for the same SF.
+ To support multiple PHS rule, passing u8PHSI.
+ */
+
+ PhsUpdateClassifierRule(
+ &Adapter->stBCMPhsContext,
+ uVCID,
+ sPhsRule.u8PHSI,
+ &sPhsRule,
+ sPhsRule.u8PHSI);
+
+ }
+
+ }
+ }
+ break;
+ }
+ }
+
+ if(psfLocalSet->u32MaxSustainedTrafficRate == 0 )
+ {
+ //No Rate Limit . Set Max Sustained Traffic Rate to Maximum
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate =
+ WIMAX_MAX_ALLOWED_RATE;
+
+ }
+ else if (ntohl(psfLocalSet->u32MaxSustainedTrafficRate) >
+ WIMAX_MAX_ALLOWED_RATE)
+ {
+ //Too large Allowed Rate specified. Limiting to Wi Max Allowed rate
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate =
+ WIMAX_MAX_ALLOWED_RATE;
+ }
+ else
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate =
+ ntohl(psfLocalSet->u32MaxSustainedTrafficRate);
+ }
+
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = ntohl(psfLocalSet->u32MaximumLatency);
+
+ if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency == 0) /* 0 should be treated as infinite */
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency = MAX_LATENCY_ALLOWED;
+
+
+ if(( Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == ERTPS ||
+ Adapter->PackInfo[uiSearchRuleIndex].u8QueueType == UGS ) )
+ UGIValue = ntohs(psfLocalSet->u16UnsolicitedGrantInterval);
+
+ if(UGIValue == 0)
+ UGIValue = DEFAULT_UG_INTERVAL;
+
+ /*
+ For UGI based connections...
+ DEFAULT_UGI_FACTOR*UGIInterval worth of data is the max token count at host...
+ The extra amount of token is to ensure that a large amount of jitter won't have loss in throughput...
+ In case of non-UGI based connection, 200 frames worth of data is the max token count at host...
+ */
+
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize =
+ (DEFAULT_UGI_FACTOR*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000;
+
+ if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize < WIMAX_MAX_MTU*8)
+ {
+ UINT UGIFactor = 0;
+ /* Special Handling to ensure the biggest size of packet can go out from host to FW as follows:
+ 1. Any packet from Host to FW can go out in different packet size.
+ 2. So in case the Bucket count is smaller than MTU, the packets of size (Size > TokenCount), will get dropped.
+ 3. We can allow packets of MaxSize from Host->FW that can go out from FW in multiple SDUs by fragmentation at Wimax Layer
+ */
+ UGIFactor = (Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency/UGIValue + 1);
+
+ if(UGIFactor > DEFAULT_UGI_FACTOR)
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize =
+ (UGIFactor*Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate*UGIValue)/1000;
+
+ if(Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize > WIMAX_MAX_MTU*8)
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize = WIMAX_MAX_MTU*8;
+ }
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"LAT: %d, UGI: %d \n", Adapter->PackInfo[uiSearchRuleIndex].uiMaxLatency, UGIValue);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"uiMaxAllowedRate: 0x%x, u32MaxSustainedTrafficRate: 0x%x ,uiMaxBucketSize: 0x%x",
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxAllowedRate,
+ ntohl(psfLocalSet->u32MaxSustainedTrafficRate),
+ Adapter->PackInfo[uiSearchRuleIndex].uiMaxBucketSize);
+
+ //copy the extended SF Parameters to Support MIBS
+ CopyMIBSExtendedSFParameters(Adapter,psfLocalSet,uiSearchRuleIndex);
+
+ //store header suppression enabled flag per SF
+ Adapter->PackInfo[uiSearchRuleIndex].bHeaderSuppressionEnabled =
+ !(psfLocalSet->u8RequesttransmissionPolicy &
+ MASK_DISABLE_HEADER_SUPPRESSION);
+
+ if(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication)
+ {
+ bcm_kfree(Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication);
+ Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = NULL;
+ }
+ Adapter->PackInfo[uiSearchRuleIndex].pstSFIndication = pstAddIndication;
+
+ //Re Sort the SF list in PackInfo according to Traffic Priority
+ SortPackInfo(Adapter);
+
+ /* Re Sort the Classifier Rules table and re - arrange
+ according to Classifier Rule Priority */
+ SortClassifiers(Adapter);
+
+ DumpPhsRules(&Adapter->stBCMPhsContext);
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"%s <=====", __FUNCTION__);
+}
+
+
+/***********************************************************************
+* Function - DumpCmControlPacket
+*
+* Description - This routinue Dumps the Contents of the AddIndication
+* Structure in the Connection Management Control Packet
+*
+* Parameter - pvBuffer: Pointer to the buffer containing the
+* AddIndication data.
+*
+* Returns - None
+*************************************************************************/
+VOID DumpCmControlPacket(PVOID pvBuffer)
+{
+ UINT uiLoopIndex;
+ UINT nIndex;
+ stLocalSFAddIndicationAlt *pstAddIndication;
+ UINT nCurClassifierCnt;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+ pstAddIndication = (stLocalSFAddIndicationAlt *)pvBuffer;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "======>");
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Type : 0x%X",pstAddIndication->u8Type);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Direction : 0x%X",pstAddIndication->u8Direction);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TID: 0x%X", ntohs(pstAddIndication->u16TID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",ntohs(pstAddIndication->u16CID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VCID : 0x%X",ntohs(pstAddIndication->u16VCID));
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " AuthorizedSet--->");
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",htonl(pstAddIndication->sfAuthorizedSet.u32SFID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",htons(pstAddIndication->sfAuthorizedSet.u16CID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8ServiceClassNameLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x%X ,0x%X , 0x%X, 0x%X, 0x%X, 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8ServiceClassName[0],
+ pstAddIndication->sfAuthorizedSet.u8ServiceClassName[1],
+ pstAddIndication->sfAuthorizedSet.u8ServiceClassName[2],
+ pstAddIndication->sfAuthorizedSet.u8ServiceClassName[3],
+ pstAddIndication->sfAuthorizedSet.u8ServiceClassName[4],
+ pstAddIndication->sfAuthorizedSet.u8ServiceClassName[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8MBSService);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8QosParamSet);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%X, %p",
+ pstAddIndication->sfAuthorizedSet.u8TrafficPriority, &pstAddIndication->sfAuthorizedSet.u8TrafficPriority);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%X 0x%p",
+ pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate,
+ &pstAddIndication->sfAuthorizedSet.u32MaxSustainedTrafficRate);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u32MaxTrafficBurst);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u32MinReservedTrafficRate);
+#if 0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u32MinimumTolerableTrafficRate);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u32RequesttransmissionPolicy);
+#endif
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParamLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8VendorSpecificQoSParam[0]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8ServiceFlowSchedulingType);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u32ToleratedJitter);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u32MaximumLatency);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8FixedLengthVSVariableLengthSDUIndicator);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8SDUSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16TargetSAID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8ARQEnable);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16ARQWindowSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16ARQRetryTxTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16ARQRetryRxTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16ARQBlockLifeTime);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16ARQSyncLossTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8ARQDeliverInOrder);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16ARQRxPurgeTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16ARQBlockSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8CSSpecification);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8TypeOfDataDeliveryService);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16SDUInterArrivalTime);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16TimeBase);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8PagingPreference);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UnsolicitedPollingInterval : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u16UnsolicitedPollingInterval);
+#if 0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X",
+ pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignmentLength);
+ for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X",
+ pstAddIndication->sfAuthorizedSet.MBSZoneIdentifierassignment[uiLoopIndex]);
+#endif
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "sfAuthorizedSet.u8HARQChannelMapping %x %x %x ",
+ *(unsigned int*)pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping,
+ *(unsigned int*)&pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[4],
+ *(USHORT*) &pstAddIndication->sfAuthorizedSet.u8HARQChannelMapping[8]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%X",
+ pstAddIndication->sfAuthorizedSet.u8TrafficIndicationPreference);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfAuthorizedSet.u8TotalClassifiers);
+
+ nCurClassifierCnt = pstAddIndication->sfAuthorizedSet.u8TotalClassifiers;
+
+ if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF)
+ {
+ nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF;
+ }
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.bValid %d", pstAddIndication->sfAuthorizedSet.bValid);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "pstAddIndication->sfAuthorizedSet.u16MacOverhead %x", pstAddIndication->sfAuthorizedSet.u16MacOverhead);
+ if(!pstAddIndication->sfAuthorizedSet.bValid)
+ pstAddIndication->sfAuthorizedSet.bValid=1;
+ for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++)
+ {
+ stConvergenceSLTypes *psfCSType = NULL;
+ psfCSType = &pstAddIndication->sfAuthorizedSet.cConvergenceSLTypes[nIndex];
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "psfCSType = %p", psfCSType);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "CCPacketClassificationRuleSI====>");
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3] :0x%X ,0x%X ,0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0],
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1],
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]);
+#if 0
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u8ProtocolLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolLength);
+#endif
+
+ for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8Protocol);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength);
+
+ for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32] : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength);
+
+ for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32] : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4]: 0x%02X ,0x%02X ,0x%02X ,0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6] : 0x %02X %02X %02X %02X %02X %02X",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6] : 0x %02X %02X %02X %02X %02X %02X",
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8EthertypeLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3] : 0x%02X ,0x%02X ,0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8Ethertype[0],
+ psfCSType->cCPacketClassificationRule.u8Ethertype[1],
+ psfCSType->cCPacketClassificationRule.u8Ethertype[2]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u16UserPriority);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u16VLANID);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1] : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]);
+#ifdef VERSION_D5
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLable[6] : 0x %02X %02X %02X %02X %02X %02X ",
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]);
+#endif
+ }
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid : 0x%02X",pstAddIndication->sfAuthorizedSet.bValid);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "AdmittedSet--->");
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",pstAddIndication->sfAdmittedSet.u32SFID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",pstAddIndication->sfAdmittedSet.u16CID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X",
+ pstAddIndication->sfAdmittedSet.u8ServiceClassNameLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x %02X %02X %02X %02X %02X %02X",
+ pstAddIndication->sfAdmittedSet.u8ServiceClassName[0],
+ pstAddIndication->sfAdmittedSet.u8ServiceClassName[1],
+ pstAddIndication->sfAdmittedSet.u8ServiceClassName[2],
+ pstAddIndication->sfAdmittedSet.u8ServiceClassName[3],
+ pstAddIndication->sfAdmittedSet.u8ServiceClassName[4],
+ pstAddIndication->sfAdmittedSet.u8ServiceClassName[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8MBSService);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8QosParamSet);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8TrafficPriority);
+#if 0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X",
+ ntohl(pstAddIndication->sfAdmittedSet.u32MaxSustainedTrafficRate));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X",
+ pstAddIndication->sfAdmittedSet.u32MinimumTolerableTrafficRate);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X",
+ pstAddIndication->sfAdmittedSet.u32RequesttransmissionPolicy);
+#endif
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X",
+ pstAddIndication->sfAdmittedSet.u32MaxTrafficBurst);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X",
+ pstAddIndication->sfAdmittedSet.u32MinReservedTrafficRate);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParamLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8VendorSpecificQoSParam[0]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8ServiceFlowSchedulingType);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X",
+ pstAddIndication->sfAdmittedSet.u32ToleratedJitter);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X",
+ pstAddIndication->sfAdmittedSet.u32MaximumLatency);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8FixedLengthVSVariableLengthSDUIndicator);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8SDUSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TargetSAID : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u16TargetSAID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQEnable : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8ARQEnable);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQWindowSize : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16ARQWindowSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryTxTimeOut : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16ARQRetryTxTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRetryRxTimeOut : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16ARQRetryRxTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockLifeTime : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16ARQBlockLifeTime);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQSyncLossTimeOut : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16ARQSyncLossTimeOut);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ARQDeliverInOrder : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8ARQDeliverInOrder);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQRxPurgeTimeOut : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16ARQRxPurgeTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16ARQBlockSize : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16ARQBlockSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8CSSpecification : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8CSSpecification);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TypeOfDataDeliveryService : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8TypeOfDataDeliveryService);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16SDUInterArrivalTime : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16SDUInterArrivalTime);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16TimeBase : 0x%X",
+ pstAddIndication->sfAdmittedSet.u16TimeBase);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8PagingPreference : 0x%X",
+ pstAddIndication->sfAdmittedSet.u8PagingPreference);
+#if 0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignmentLength : 0x%X",
+ pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignmentLength);
+ for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "MBSZoneIdentifierassignment : 0x%X",
+ pstAddIndication->sfAdmittedSet.MBSZoneIdentifierassignment[uiLoopIndex]);
+#endif
+
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficIndicationPreference : 0x%02X",
+ pstAddIndication->sfAdmittedSet.u8TrafficIndicationPreference);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfAdmittedSet.u8TotalClassifiers);
+
+ nCurClassifierCnt = pstAddIndication->sfAdmittedSet.u8TotalClassifiers;
+
+ if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF)
+ {
+ nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF;
+ }
+
+
+ for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++)
+ {
+
+ stConvergenceSLTypes *psfCSType = NULL;
+ psfCSType = &pstAddIndication->sfAdmittedSet.cConvergenceSLTypes[nIndex];
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>");
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ClassifierRulePriority :0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfServiceLength :0x%02X",
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPTypeOfService[3] :0x%02X %02X %02X",
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0],
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1],
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]);
+#if 0
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolLength :0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolLength);
+#endif
+ for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Protocol: 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8Protocol);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength);
+
+ for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32] : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength);
+
+ for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddress[32] : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRangeLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolSourcePortRange[4] : 0x %02X %02X %02X %02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRangeLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ProtocolDestPortRange[4] : 0x %02X %02X %02X %02X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddressLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetDestMacAddress[6] : 0x %02X %02X %02X %02X %02X %02X",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddressLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6] : 0x %02X %02X %02X %02X %02X %02X",
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthertypeLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8EthertypeLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8Ethertype[3] : 0x%02X %02X %02X",
+ psfCSType->cCPacketClassificationRule.u8Ethertype[0],
+ psfCSType->cCPacketClassificationRule.u8Ethertype[1],
+ psfCSType->cCPacketClassificationRule.u8Ethertype[2]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16UserPriority : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u16UserPriority);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16VLANID : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u16VLANID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8AssociatedPHSI : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16PacketClassificationRuleIndex : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParamLength : 0x%02X",
+ psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificClassifierParam[1] : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]);
+#ifdef VERSION_D5
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLableLength : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPv6FlowLable[6] : 0x %02X %02X %02X %02X %02X %02X ",
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]);
+#endif
+ }
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "bValid : 0x%X",pstAddIndication->sfAdmittedSet.bValid);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " ActiveSet--->");
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32SFID : 0x%X",pstAddIndication->sfActiveSet.u32SFID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u16CID : 0x%X",pstAddIndication->sfActiveSet.u16CID);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassNameLength : 0x%X",
+ pstAddIndication->sfActiveSet.u8ServiceClassNameLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceClassName : 0x %02X %02X %02X %02X %02X %02X",
+ pstAddIndication->sfActiveSet.u8ServiceClassName[0],
+ pstAddIndication->sfActiveSet.u8ServiceClassName[1],
+ pstAddIndication->sfActiveSet.u8ServiceClassName[2],
+ pstAddIndication->sfActiveSet.u8ServiceClassName[3],
+ pstAddIndication->sfActiveSet.u8ServiceClassName[4],
+ pstAddIndication->sfActiveSet.u8ServiceClassName[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8MBSService : 0x%02X",
+ pstAddIndication->sfActiveSet.u8MBSService);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8QosParamSet : 0x%02X",
+ pstAddIndication->sfActiveSet.u8QosParamSet);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8TrafficPriority : 0x%02X",
+ pstAddIndication->sfActiveSet.u8TrafficPriority);
+#if 0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MaxSustainedTrafficRate : 0x%02X",
+ ntohl(pstAddIndication->sfActiveSet.u32MaxSustainedTrafficRate));
+#endif
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaxTrafficBurst : 0x%X",
+ pstAddIndication->sfActiveSet.u32MaxTrafficBurst);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MinReservedTrafficRate : 0x%X",
+ pstAddIndication->sfActiveSet.u32MinReservedTrafficRate);
+#if 0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32MinimumTolerableTrafficRate : 0x%X",
+ pstAddIndication->sfActiveSet.u32MinimumTolerableTrafficRate);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32RequesttransmissionPolicy : 0x%X",
+ pstAddIndication->sfActiveSet.u32RequesttransmissionPolicy);
+#endif
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParamLength : 0x%02X",
+ pstAddIndication->sfActiveSet.u8VendorSpecificQoSParamLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8VendorSpecificQoSParam : 0x%02X",
+ pstAddIndication->sfActiveSet.u8VendorSpecificQoSParam[0]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8ServiceFlowSchedulingType : 0x%02X",
+ pstAddIndication->sfActiveSet.u8ServiceFlowSchedulingType);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32ToleratedJitter : 0x%X",
+ pstAddIndication->sfActiveSet.u32ToleratedJitter);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u32MaximumLatency : 0x%X",
+ pstAddIndication->sfActiveSet.u32MaximumLatency);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8FixedLengthVSVariableLengthSDUIndicator: 0x%02X",
+ pstAddIndication->sfActiveSet.u8FixedLengthVSVariableLengthSDUIndicator);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8SDUSize : 0x%X",
+ pstAddIndication->sfActiveSet.u8SDUSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TargetSAID : 0x%X",
+ pstAddIndication->sfActiveSet.u16TargetSAID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQEnable : 0x%X",
+ pstAddIndication->sfActiveSet.u8ARQEnable);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQWindowSize : 0x%X",
+ pstAddIndication->sfActiveSet.u16ARQWindowSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryTxTimeOut : 0x%X",
+ pstAddIndication->sfActiveSet.u16ARQRetryTxTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRetryRxTimeOut : 0x%X",
+ pstAddIndication->sfActiveSet.u16ARQRetryRxTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockLifeTime : 0x%X",
+ pstAddIndication->sfActiveSet.u16ARQBlockLifeTime);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQSyncLossTimeOut : 0x%X",
+ pstAddIndication->sfActiveSet.u16ARQSyncLossTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ARQDeliverInOrder : 0x%X",
+ pstAddIndication->sfActiveSet.u8ARQDeliverInOrder);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQRxPurgeTimeOut : 0x%X",
+ pstAddIndication->sfActiveSet.u16ARQRxPurgeTimeOut);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16ARQBlockSize : 0x%X",
+ pstAddIndication->sfActiveSet.u16ARQBlockSize);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8CSSpecification : 0x%X",
+ pstAddIndication->sfActiveSet.u8CSSpecification);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TypeOfDataDeliveryService : 0x%X",
+ pstAddIndication->sfActiveSet.u8TypeOfDataDeliveryService);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16SDUInterArrivalTime : 0x%X",
+ pstAddIndication->sfActiveSet.u16SDUInterArrivalTime);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16TimeBase : 0x%X",
+ pstAddIndication->sfActiveSet.u16TimeBase);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8PagingPreference : 0x%X",
+ pstAddIndication->sfActiveSet.u8PagingPreference);
+#if 0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignmentLength : 0x%X",
+ pstAddIndication->sfActiveSet.MBSZoneIdentifierassignmentLength);
+ for(uiLoopIndex=0; uiLoopIndex < MAX_STRING_LEN; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " MBSZoneIdentifierassignment : 0x%X",
+ pstAddIndication->sfActiveSet.MBSZoneIdentifierassignment[uiLoopIndex]);
+#endif
+
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8TrafficIndicationPreference : 0x%X",
+ pstAddIndication->sfActiveSet.u8TrafficIndicationPreference);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " Total Classifiers Recieved : 0x%X",pstAddIndication->sfActiveSet.u8TotalClassifiers);
+
+ nCurClassifierCnt = pstAddIndication->sfActiveSet.u8TotalClassifiers;
+
+ if(nCurClassifierCnt > MAX_CLASSIFIERS_IN_SF)
+ {
+ nCurClassifierCnt = MAX_CLASSIFIERS_IN_SF;
+ }
+
+ for(nIndex = 0 ; nIndex < nCurClassifierCnt ; nIndex++)
+ {
+
+ stConvergenceSLTypes *psfCSType = NULL;
+ psfCSType = &pstAddIndication->sfActiveSet.cConvergenceSLTypes[nIndex];
+
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " CCPacketClassificationRuleSI====>");
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ClassifierRulePriority :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ClassifierRulePriority);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfServiceLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfServiceLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPTypeOfService[3] :0x%X ,0x%X ,0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[0],
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[1],
+ psfCSType->cCPacketClassificationRule.u8IPTypeOfService[2]);
+#if 0
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " u8ProtocolLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolLength);
+#endif
+ for(uiLoopIndex=0; uiLoopIndex < 1; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Protocol : 0x%X ",
+ psfCSType->cCPacketClassificationRule.u8Protocol);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddressLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddressLength);
+
+ for(uiLoopIndex=0; uiLoopIndex < 32; uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPMaskedSourceAddress[32]:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPMaskedSourceAddress[uiLoopIndex]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8IPDestinationAddressLength : 0x%02X ",
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddressLength);
+
+ for(uiLoopIndex=0;uiLoopIndex<32;uiLoopIndex++)
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPDestinationAddress[32]:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPDestinationAddress[uiLoopIndex]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRangeLength:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRangeLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolSourcePortRange[4]:0x%X ,0x%X ,0x%X ,0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[0],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[1],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[2],
+ psfCSType->cCPacketClassificationRule.u8ProtocolSourcePortRange[3]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRangeLength:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRangeLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8ProtocolDestPortRange[4]:0x%X ,0x%X ,0x%X ,0x%X ",
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[0],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[1],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[2],
+ psfCSType->cCPacketClassificationRule.u8ProtocolDestPortRange[3]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddressLength:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetDestMacAddress[6]:0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[0],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[1],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[2],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[3],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[4],
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddress[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthernetSourceMACAddressLength:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8EthernetDestMacAddressLength);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, "u8EthernetSourceMACAddress[6]:0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X",
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[0],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[1],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[2],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[3],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[4],
+ psfCSType->cCPacketClassificationRule.u8EthernetSourceMACAddress[5]);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8EthertypeLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8EthertypeLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8Ethertype[3] :0x%X ,0x%X ,0x%X ",
+ psfCSType->cCPacketClassificationRule.u8Ethertype[0],
+ psfCSType->cCPacketClassificationRule.u8Ethertype[1],
+ psfCSType->cCPacketClassificationRule.u8Ethertype[2]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16UserPriority :0x%X ",
+ psfCSType->cCPacketClassificationRule.u16UserPriority);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16VLANID :0x%X ",
+ psfCSType->cCPacketClassificationRule.u16VLANID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8AssociatedPHSI :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8AssociatedPHSI);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u16PacketClassificationRuleIndex:0x%X ",
+ psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParamLength:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParamLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8VendorSpecificClassifierParam[1]:0x%X ",
+ psfCSType->cCPacketClassificationRule.u8VendorSpecificClassifierParam[0]);
+#ifdef VERSION_D5
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLableLength :0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLableLength);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " u8IPv6FlowLable[6] :0x%X ,0x%X ,0x%X ,0x%X ,0x%X ,0x%X ",
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[0],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[1],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[2],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[3],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[4],
+ psfCSType->cCPacketClassificationRule.u8IPv6FlowLable[5]);
+#endif
+ }
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, DUMP_CONTROL, DBG_LVL_ALL, " bValid : 0x%X",pstAddIndication->sfActiveSet.bValid);
+
+}
+
+static inline ULONG RestoreSFParam(PMINI_ADAPTER Adapter, ULONG ulAddrSFParamSet,PUCHAR pucDestBuffer)
+{
+ UINT nBytesToRead = sizeof(stServiceFlowParamSI);
+
+ if(ulAddrSFParamSet == 0 || NULL == pucDestBuffer)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Got Param address as 0!!");
+ return 0;
+ }
+ ulAddrSFParamSet = ntohl(ulAddrSFParamSet);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " RestoreSFParam: Total Words of DSX Message To Read: 0x%x From Target At : 0x%lx ",
+ nBytesToRead/sizeof(ULONG),ulAddrSFParamSet);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "sizeof(stServiceFlowParamSI) = %x", sizeof(stServiceFlowParamSI));
+
+ //Read out the SF Param Set At the indicated Location
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "nBytesToRead = %x", nBytesToRead);
+ if(rdm(Adapter, ulAddrSFParamSet, (PUCHAR)pucDestBuffer, nBytesToRead) < 0)
+ return STATUS_FAILURE;
+
+ return 1;
+}
+
+
+static __inline ULONG StoreSFParam(PMINI_ADAPTER Adapter,PUCHAR pucSrcBuffer,ULONG ulAddrSFParamSet)
+{
+ UINT nBytesToWrite = sizeof(stServiceFlowParamSI);
+ UINT uiRetVal =0;
+
+ if(ulAddrSFParamSet == 0 || NULL == pucSrcBuffer)
+ {
+ return 0;
+ }
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " StoreSFParam: Total Words of DSX Message To Write: 0x%X To Target At : 0x%lX ",(nBytesToWrite/sizeof(ULONG)),ulAddrSFParamSet);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "WRM with %x bytes",nBytesToWrite);
+
+ uiRetVal = wrm(Adapter,ulAddrSFParamSet,(PUCHAR)pucSrcBuffer, nBytesToWrite);
+ if(uiRetVal < 0) {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "%s:%d WRM failed",__FUNCTION__, __LINE__);
+ return uiRetVal;
+ }
+ return 1;
+}
+
+ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength)
+{
+ stLocalSFAddIndicationAlt *pstAddIndicationAlt = NULL;
+ stLocalSFAddIndication * pstAddIndication = NULL;
+ stLocalSFDeleteRequest *pstDeletionRequest;
+ UINT uiSearchRuleIndex;
+ ULONG ulSFID;
+
+ pstAddIndicationAlt = (stLocalSFAddIndicationAlt *)(pvBuffer);
+
+ /*
+ * In case of DSD Req By MS, we should immediately delete this SF so that
+ * we can stop the further classifying the pkt for this SF.
+ */
+ if(pstAddIndicationAlt->u8Type == DSD_REQ)
+ {
+ pstDeletionRequest = (stLocalSFDeleteRequest *)pvBuffer;
+
+ ulSFID = ntohl(pstDeletionRequest->u32SFID);
+ uiSearchRuleIndex=SearchSfid(Adapter,ulSFID);
+
+ if(uiSearchRuleIndex < NO_OF_QUEUES)
+ {
+ deleteSFBySfid(Adapter,uiSearchRuleIndex);
+ Adapter->u32TotalDSD++;
+ }
+ return 1;
+ }
+
+
+ if( (pstAddIndicationAlt->u8Type == DSD_RSP) ||
+ (pstAddIndicationAlt->u8Type == DSD_ACK))
+ {
+ //No Special handling send the message as it is
+ return 1;
+ }
+ // For DSA_REQ, only upto "psfAuthorizedSet" parameter should be accessed by driver!
+
+ pstAddIndication=(stLocalSFAddIndication *)kmalloc(sizeof(*pstAddIndication), GFP_KERNEL);
+ if(NULL==pstAddIndication)
+ return 0;
+
+ /* AUTHORIZED SET */
+ pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *)
+ GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID);
+ if(!pstAddIndication->psfAuthorizedSet)
+ return 0;
+
+ if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAuthorizedSet,
+ (ULONG)pstAddIndication->psfAuthorizedSet)!= 1)
+ return 0;
+
+ pstAddIndication->psfAuthorizedSet = (stServiceFlowParamSI *)
+ ntohl((ULONG)pstAddIndication->psfAuthorizedSet);
+
+ if(pstAddIndicationAlt->u8Type == DSA_REQ)
+ {
+ stLocalSFAddRequest AddRequest;
+
+ AddRequest.u8Type = pstAddIndicationAlt->u8Type;
+ AddRequest.eConnectionDir = pstAddIndicationAlt->u8Direction;
+ AddRequest.u16TID = pstAddIndicationAlt->u16TID;
+ AddRequest.u16CID = pstAddIndicationAlt->u16CID;
+ AddRequest.u16VCID = pstAddIndicationAlt->u16VCID;
+ AddRequest.psfParameterSet =pstAddIndication->psfAuthorizedSet ;
+ (*puBufferLength) = sizeof(stLocalSFAddRequest);
+ memcpy(pvBuffer,&AddRequest,sizeof(stLocalSFAddRequest));
+ return 1;
+ }
+
+ // Since it's not DSA_REQ, we can access all field in pstAddIndicationAlt
+
+ //We need to extract the structure from the buffer and pack it differently
+
+ pstAddIndication->u8Type = pstAddIndicationAlt->u8Type;
+ pstAddIndication->eConnectionDir= pstAddIndicationAlt->u8Direction ;
+ pstAddIndication->u16TID = pstAddIndicationAlt->u16TID;
+ pstAddIndication->u16CID = pstAddIndicationAlt->u16CID;
+ pstAddIndication->u16VCID = pstAddIndicationAlt->u16VCID;
+ pstAddIndication->u8CC = pstAddIndicationAlt->u8CC;
+
+ /* ADMITTED SET */
+ pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *)
+ GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID);
+ if(!pstAddIndication->psfAdmittedSet)
+ return 0;
+ if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfAdmittedSet,(ULONG)pstAddIndication->psfAdmittedSet) != 1)
+ return 0;
+
+ pstAddIndication->psfAdmittedSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfAdmittedSet);
+
+
+ /* ACTIVE SET */
+ pstAddIndication->psfActiveSet = (stServiceFlowParamSI *)
+ GetNextTargetBufferLocation(Adapter, pstAddIndicationAlt->u16TID);
+ if(!pstAddIndication->psfActiveSet)
+ return 0;
+ if(StoreSFParam(Adapter,(PUCHAR)&pstAddIndicationAlt->sfActiveSet,(ULONG)pstAddIndication->psfActiveSet) != 1)
+ return 0;
+
+ pstAddIndication->psfActiveSet = (stServiceFlowParamSI *)ntohl((ULONG)pstAddIndication->psfActiveSet);
+
+ (*puBufferLength) = sizeof(stLocalSFAddIndication);
+ *(stLocalSFAddIndication *)pvBuffer = *pstAddIndication;
+ bcm_kfree(pstAddIndication);
+ return 1;
+}
+
+
+static inline stLocalSFAddIndicationAlt
+*RestoreCmControlResponseMessage(register PMINI_ADAPTER Adapter,register PVOID pvBuffer)
+{
+ ULONG ulStatus=0;
+ stLocalSFAddIndication *pstAddIndication = NULL;
+ stLocalSFAddIndicationAlt *pstAddIndicationDest = NULL;
+ pstAddIndication = (stLocalSFAddIndication *)(pvBuffer);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "=====>" );
+ if ((pstAddIndication->u8Type == DSD_REQ) ||
+ (pstAddIndication->u8Type == DSD_RSP) ||
+ (pstAddIndication->u8Type == DSD_ACK))
+ {
+ return (stLocalSFAddIndicationAlt *)pvBuffer;
+ }
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Inside RestoreCmControlResponseMessage ");
+ /*
+ //Need to Allocate memory to contain the SUPER Large structures
+ //Our driver cant create these structures on Stack :(
+ */
+ pstAddIndicationDest=kmalloc(sizeof(stLocalSFAddIndicationAlt), GFP_KERNEL);
+
+ if(pstAddIndicationDest)
+ {
+ memset(pstAddIndicationDest,0,sizeof(stLocalSFAddIndicationAlt));
+ }
+ else
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Failed to allocate memory for SF Add Indication Structure ");
+ return NULL;
+ }
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Type : 0x%X",pstAddIndication->u8Type);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8Direction : 0x%X",pstAddIndication->eConnectionDir);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8TID : 0x%X",ntohs(pstAddIndication->u16TID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u8CID : 0x%X",ntohs(pstAddIndication->u16CID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-u16VCID : 0x%X",ntohs(pstAddIndication->u16VCID));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-autorized set loc : 0x%x",ntohl(pstAddIndication->psfAuthorizedSet));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-admitted set loc : 0x%x",ntohl(pstAddIndication->psfAdmittedSet));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "AddIndication-Active set loc : 0x%x",ntohl(pstAddIndication->psfActiveSet));
+
+ pstAddIndicationDest->u8Type = pstAddIndication->u8Type;
+ pstAddIndicationDest->u8Direction = pstAddIndication->eConnectionDir;
+ pstAddIndicationDest->u16TID = pstAddIndication->u16TID;
+ pstAddIndicationDest->u16CID = pstAddIndication->u16CID;
+ pstAddIndicationDest->u16VCID = pstAddIndication->u16VCID;
+ pstAddIndicationDest->u8CC = pstAddIndication->u8CC;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Active Set ");
+ ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfActiveSet, (PUCHAR)&pstAddIndicationDest->sfActiveSet);
+ if(ulStatus != 1)
+ {
+ goto failed_restore_sf_param;
+ }
+ if(pstAddIndicationDest->sfActiveSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF)
+ pstAddIndicationDest->sfActiveSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Admitted Set ");
+ ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfAdmittedSet,(PUCHAR)&pstAddIndicationDest->sfAdmittedSet);
+ if(ulStatus != 1)
+ {
+ goto failed_restore_sf_param;
+ }
+ if(pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF)
+ pstAddIndicationDest->sfAdmittedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Restoring Authorized Set ");
+ ulStatus=RestoreSFParam(Adapter,(ULONG)pstAddIndication->psfAuthorizedSet,(PUCHAR)&pstAddIndicationDest->sfAuthorizedSet);
+ if(ulStatus != 1)
+ {
+ goto failed_restore_sf_param;
+ }
+ if(pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers > MAX_CLASSIFIERS_IN_SF)
+ pstAddIndicationDest->sfAuthorizedSet.u8TotalClassifiers = MAX_CLASSIFIERS_IN_SF;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Dumping the whole raw packet");
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================");
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " pstAddIndicationDest->sfActiveSet size %x %p", sizeof(*pstAddIndicationDest), pstAddIndicationDest);
+ //BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, (unsigned char *)pstAddIndicationDest, sizeof(*pstAddIndicationDest));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============================================================");
+ return pstAddIndicationDest;
+failed_restore_sf_param:
+ bcm_kfree(pstAddIndicationDest);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "<=====" );
+ return NULL;
+}
+
+ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter)
+{
+ ULONG ulTargetDsxBuffersBase = 0;
+ ULONG ulCntTargetBuffers;
+ ULONG ulIndex=0;
+ int Status;
+
+ if(Adapter->astTargetDsxBuffer[0].ulTargetDsxBuffer)
+ return 1;
+
+ if(NULL == Adapter)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Adapter was NULL!!!");
+ return 0;
+ }
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Size of Each DSX Buffer(Also size of ServiceFlowParamSI): %x ",sizeof(stServiceFlowParamSI));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Reading DSX buffer From Target location %x ",DSX_MESSAGE_EXCHANGE_BUFFER);
+
+ Status = rdmalt(Adapter, DSX_MESSAGE_EXCHANGE_BUFFER,
+ (PUINT)&ulTargetDsxBuffersBase, sizeof(UINT));
+ if(Status < 0)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "RDM failed!!");
+ return 0;
+ }
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Base Address Of DSX Target Buffer : 0x%lx",ulTargetDsxBuffersBase);
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Tgt Buffer is Now %lx :",ulTargetDsxBuffersBase);
+
+ ulCntTargetBuffers = DSX_MESSAGE_EXCHANGE_BUFFER_SIZE/sizeof(stServiceFlowParamSI);
+
+ Adapter->ulTotalTargetBuffersAvailable =
+ ulCntTargetBuffers > MAX_TARGET_DSX_BUFFERS ?
+ MAX_TARGET_DSX_BUFFERS : ulCntTargetBuffers;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Total Target DSX Buffer setup %lx ",Adapter->ulTotalTargetBuffersAvailable);
+
+ for(ulIndex=0; ulIndex < Adapter->ulTotalTargetBuffersAvailable ; ulIndex++)
+ {
+ Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer = ulTargetDsxBuffersBase;
+ Adapter->astTargetDsxBuffer[ulIndex].valid=1;
+ Adapter->astTargetDsxBuffer[ulIndex].tid=0;
+ ulTargetDsxBuffersBase+=sizeof(stServiceFlowParamSI);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " Target DSX Buffer %lx setup at 0x%lx",
+ ulIndex, Adapter->astTargetDsxBuffer[ulIndex].ulTargetDsxBuffer);
+ }
+ Adapter->ulCurrentTargetBuffer = 0;
+ Adapter->ulFreeTargetBufferCnt = Adapter->ulTotalTargetBuffersAvailable;
+ return 1;
+}
+
+ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid)
+{
+ ULONG ulTargetDSXBufferAddress;
+ ULONG ulTargetDsxBufferIndexToUse,ulMaxTry;
+
+ if((Adapter->ulTotalTargetBuffersAvailable == 0)||
+ (Adapter->ulFreeTargetBufferCnt == 0))
+ {
+ ClearTargetDSXBuffer(Adapter,tid,FALSE);
+ return 0;
+ }
+
+ ulTargetDsxBufferIndexToUse = Adapter->ulCurrentTargetBuffer;
+ ulMaxTry = Adapter->ulTotalTargetBuffersAvailable;
+ while((ulMaxTry)&&(Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid != 1))
+ {
+ ulTargetDsxBufferIndexToUse = (ulTargetDsxBufferIndexToUse+1)%
+ Adapter->ulTotalTargetBuffersAvailable;
+ ulMaxTry--;
+ }
+
+ if(ulMaxTry==0)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "\n GetNextTargetBufferLocation : Error No Free Target DSX Buffers FreeCnt : %lx ",Adapter->ulFreeTargetBufferCnt);
+ ClearTargetDSXBuffer(Adapter,tid,FALSE);
+ return 0;
+ }
+
+
+ ulTargetDSXBufferAddress =
+ Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].ulTargetDsxBuffer;
+ Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].valid=0;
+ Adapter->astTargetDsxBuffer[ulTargetDsxBufferIndexToUse].tid=tid;
+ Adapter->ulFreeTargetBufferCnt--;
+
+
+ ulTargetDsxBufferIndexToUse =
+ (ulTargetDsxBufferIndexToUse+1)%Adapter->ulTotalTargetBuffersAvailable;
+ Adapter->ulCurrentTargetBuffer = ulTargetDsxBufferIndexToUse;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "GetNextTargetBufferLocation :Returning address %lx tid %d\n",
+ ulTargetDSXBufferAddress,tid);
+ return ulTargetDSXBufferAddress;
+}
+
+
+INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter)
+{
+ /*
+ //Need to Allocate memory to contain the SUPER Large structures
+ //Our driver cant create these structures on Stack
+ */
+ Adapter->caDsxReqResp=kmalloc(sizeof(stLocalSFAddIndicationAlt)+LEADER_SIZE, GFP_KERNEL);
+ if(!Adapter->caDsxReqResp)
+ return -ENOMEM;
+ return 0;
+}
+
+INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter)
+{
+ if(Adapter->caDsxReqResp)
+ {
+ bcm_kfree(Adapter->caDsxReqResp);
+ }
+ return 0;
+
+}
+/**
+@ingroup ctrl_pkt_functions
+This routinue would process the Control responses
+for the Connection Management.
+@return - Queue index for the free SFID else returns Invalid Index.
+*/
+BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/
+ PVOID pvBuffer /**Starting Address of the Buffer, that contains the AddIndication Data*/
+ )
+{
+ stServiceFlowParamSI *psfLocalSet=NULL;
+ stLocalSFAddIndicationAlt *pstAddIndication = NULL;
+ stLocalSFChangeIndicationAlt *pstChangeIndication = NULL;
+ PLEADER pLeader=NULL;
+ /*
+ //Otherwise the message contains a target address from where we need to
+ //read out the rest of the service flow param structure
+ */
+ if((pstAddIndication = RestoreCmControlResponseMessage(Adapter,pvBuffer))
+ == NULL)
+ {
+ ClearTargetDSXBuffer(Adapter,((stLocalSFAddIndication *)pvBuffer)->u16TID, FALSE);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "Error in restoring Service Flow param structure from DSx message");
+ return FALSE;
+ }
+
+ DumpCmControlPacket(pstAddIndication);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "====>");
+ pLeader = (PLEADER)Adapter->caDsxReqResp;
+
+ pLeader->Status =CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ;
+ pLeader->Vcid = 0;
+
+ ClearTargetDSXBuffer(Adapter,pstAddIndication->u16TID,FALSE);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "### TID RECEIVED %d\n",pstAddIndication->u16TID);
+ switch(pstAddIndication->u8Type)
+ {
+ case DSA_REQ:
+ {
+ pLeader->PLength = sizeof(stLocalSFAddIndicationAlt);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Sending DSA Response....\n");
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA RESPONSE TO MAC %d", pLeader->PLength );
+ *((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))
+ = *pstAddIndication;
+ ((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_RSP;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, " VCID = %x", ntohs(pstAddIndication->u16VCID));
+ CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp);
+ bcm_kfree(pstAddIndication);
+ }
+ break;
+ case DSA_RSP:
+ {
+ pLeader->PLength = sizeof(stLocalSFAddIndicationAlt);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSA ACK TO MAC %d",
+ pLeader->PLength);
+ *((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))
+ = *pstAddIndication;
+ ((stLocalSFAddIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSA_ACK;
+
+ }//no break here..we should go down.
+ case DSA_ACK:
+ {
+ UINT uiSearchRuleIndex=0;
+ struct timeval tv = {0};
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "VCID:0x%X",
+ ntohs(pstAddIndication->u16VCID));
+ uiSearchRuleIndex=SearchFreeSfid(Adapter);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"uiSearchRuleIndex:0x%X ",
+ uiSearchRuleIndex);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Direction:0x%X ",
+ pstAddIndication->u8Direction);
+ if((uiSearchRuleIndex< NO_OF_QUEUES) )
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].ucDirection =
+ pstAddIndication->u8Direction;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "bValid:0x%X ",
+ pstAddIndication->sfActiveSet.bValid);
+ if(pstAddIndication->sfActiveSet.bValid==TRUE)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bActiveSet=TRUE;
+ }
+ if(pstAddIndication->sfAuthorizedSet.bValid==TRUE)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet=TRUE;
+ }
+ if(pstAddIndication->sfAdmittedSet.bValid==TRUE)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet=TRUE;
+ }
+ if(FALSE == pstAddIndication->sfActiveSet.bValid)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE;
+ Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE;
+ if(pstAddIndication->sfAdmittedSet.bValid)
+ {
+ psfLocalSet = &pstAddIndication->sfAdmittedSet;
+ }
+ else if(pstAddIndication->sfAuthorizedSet.bValid)
+ {
+ psfLocalSet = &pstAddIndication->sfAuthorizedSet;
+ }
+ }
+ else
+ {
+ psfLocalSet = &pstAddIndication->sfActiveSet;
+ Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE;
+ }
+
+ if(!psfLocalSet)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No set is valid\n");
+ Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE;
+ Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE;
+ Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0;
+ bcm_kfree(pstAddIndication);
+ }
+
+ else if(psfLocalSet->bValid && (pstAddIndication->u8CC == 0))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSA ACK");
+ Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value =
+ ntohs(pstAddIndication->u16VCID);
+ Adapter->PackInfo[uiSearchRuleIndex].usCID =
+ ntohs(pstAddIndication->u16CID);
+
+ if(UPLINK_DIR == pstAddIndication->u8Direction)
+ atomic_set(&Adapter->PackInfo[uiSearchRuleIndex].uiPerSFTxResourceCount, DEFAULT_PERSFCOUNT);
+ CopyToAdapter(Adapter,psfLocalSet,uiSearchRuleIndex,
+ DSA_ACK, pstAddIndication);
+ // don't free pstAddIndication
+
+ /* Inside CopyToAdapter, Sorting of all the SFs take place.
+ Hence any access to the newly added SF through uiSearchRuleIndex is invalid.
+ SHOULD BE STRICTLY AVOIDED.
+ */
+// *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID;
+ memcpy((((PUCHAR)pvBuffer)+1), &psfLocalSet->u32SFID, 4);
+
+ if(pstAddIndication->sfActiveSet.bValid == TRUE)
+ {
+ if(UPLINK_DIR == pstAddIndication->u8Direction)
+ {
+ if(!Adapter->LinkUpStatus)
+ {
+ netif_carrier_on(Adapter->dev);
+ netif_start_queue(Adapter->dev);
+ Adapter->LinkUpStatus = 1;
+ do_gettimeofday(&tv);
+
+ atomic_set(&Adapter->TxPktAvail, 1);
+ wake_up(&Adapter->tx_packet_wait_queue);
+ Adapter->liTimeSinceLastNetEntry = tv.tv_sec;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "============Tx Service Flow Created!");
+ }
+ }
+ }
+ }
+
+ else
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE;
+ Adapter->PackInfo[uiSearchRuleIndex].bValid=FALSE;
+ Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value=0;
+ bcm_kfree(pstAddIndication);
+ }
+ }
+ else
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSA ACK did not get valid SFID");
+ bcm_kfree(pstAddIndication);
+ return FALSE;
+ }
+ }
+ break;
+ case DSC_REQ:
+ {
+ pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt);
+ pstChangeIndication = (stLocalSFChangeIndicationAlt*)pstAddIndication;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC RESPONSE TO MAC %d", pLeader->PLength);
+
+ *((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication;
+ ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_RSP;
+
+ CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp);
+ bcm_kfree(pstAddIndication);
+ }
+ break;
+ case DSC_RSP:
+ {
+ pLeader->PLength = sizeof(stLocalSFChangeIndicationAlt);
+ pstChangeIndication = (stLocalSFChangeIndicationAlt*)pstAddIndication;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSC ACK TO MAC %d", pLeader->PLength);
+ *((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *pstChangeIndication;
+ ((stLocalSFChangeIndicationAlt*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSC_ACK;
+ }
+ case DSC_ACK:
+ {
+ UINT uiSearchRuleIndex=0;
+
+ pstChangeIndication = (stLocalSFChangeIndicationAlt *)pstAddIndication;
+ uiSearchRuleIndex=SearchSfid(Adapter,ntohl(pstChangeIndication->sfActiveSet.u32SFID));
+ if(uiSearchRuleIndex > NO_OF_QUEUES-1)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "SF doesn't exist for which DSC_ACK is received");
+ }
+ if((uiSearchRuleIndex < NO_OF_QUEUES))
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].ucDirection = pstChangeIndication->u8Direction;
+ if(pstChangeIndication->sfActiveSet.bValid==TRUE)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bActiveSet=TRUE;
+ }
+ if(pstChangeIndication->sfAuthorizedSet.bValid==TRUE)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet=TRUE;
+ }
+ if(pstChangeIndication->sfAdmittedSet.bValid==TRUE)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet=TRUE;
+ }
+
+ if(FALSE==pstChangeIndication->sfActiveSet.bValid)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bActive = FALSE;
+ Adapter->PackInfo[uiSearchRuleIndex].bActivateRequestSent = FALSE;
+ if(pstChangeIndication->sfAdmittedSet.bValid)
+ {
+ psfLocalSet = &pstChangeIndication->sfAdmittedSet;
+ }
+ else if(pstChangeIndication->sfAuthorizedSet.bValid)
+ {
+ psfLocalSet = &pstChangeIndication->sfAuthorizedSet;
+ }
+ }
+
+ else
+ {
+ psfLocalSet = &pstChangeIndication->sfActiveSet;
+ Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE;
+ }
+ if(psfLocalSet->bValid && (pstChangeIndication->u8CC == 0))
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value =
+ ntohs(pstChangeIndication->u16VCID);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "CC field is %d bvalid = %d\n",
+ pstChangeIndication->u8CC, psfLocalSet->bValid);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "VCID= %d\n", ntohs(pstChangeIndication->u16VCID));
+ Adapter->PackInfo[uiSearchRuleIndex].usCID =
+ ntohs(pstChangeIndication->u16CID);
+ CopyToAdapter(Adapter,psfLocalSet,uiSearchRuleIndex,
+ DSC_ACK, pstAddIndication);
+
+ *(PULONG)(((PUCHAR)pvBuffer)+1)=psfLocalSet->u32SFID;
+ }
+ else if(pstChangeIndication->u8CC == 6)
+ {
+ deleteSFBySfid(Adapter,uiSearchRuleIndex);
+ bcm_kfree(pstAddIndication);
+ }
+ }
+ else
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_PRINTK, 0, 0, "DSC ACK did not get valid SFID");
+ bcm_kfree(pstAddIndication);
+ return FALSE;
+ }
+ }
+ break;
+ case DSD_REQ:
+ {
+ UINT uiSearchRuleIndex;
+ ULONG ulSFID;
+
+ pLeader->PLength = sizeof(stLocalSFDeleteIndication);
+ *((stLocalSFDeleteIndication*)&(Adapter->caDsxReqResp[LEADER_SIZE])) = *((stLocalSFDeleteIndication*)pstAddIndication);
+
+ ulSFID = ntohl(((stLocalSFDeleteIndication*)pstAddIndication)->u32SFID);
+ uiSearchRuleIndex=SearchSfid(Adapter,ulSFID);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD - Removing connection %x",uiSearchRuleIndex);
+
+ if(uiSearchRuleIndex < NO_OF_QUEUES)
+ {
+ //Delete All Classifiers Associated with this SFID
+ deleteSFBySfid(Adapter,uiSearchRuleIndex);
+ Adapter->u32TotalDSD++;
+ }
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SENDING DSD RESPONSE TO MAC");
+ ((stLocalSFDeleteIndication*)&(Adapter->caDsxReqResp[LEADER_SIZE]))->u8Type = DSD_RSP;
+ CopyBufferToControlPacket(Adapter,(PVOID)Adapter->caDsxReqResp);
+ }
+ case DSD_RSP:
+ {
+ //Do nothing as SF has already got Deleted
+ }
+ break;
+ case DSD_ACK:
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "DSD ACK Rcd, let App handle it\n");
+ break;
+ default:
+ bcm_kfree(pstAddIndication);
+ return FALSE ;
+ }
+ return TRUE;
+}
+
+int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId, PUCHAR user_buffer)
+{
+ int status = 0;
+ struct _packet_info *psSfInfo=NULL;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d",status);
+ status = SearchSfid(Adapter, uiSFId);
+ if(status>NO_OF_QUEUES)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "SFID %d not present in queue !!!", uiSFId );
+ return -EINVAL;
+ }
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "status =%d",status);
+ psSfInfo=&Adapter->PackInfo[status];
+ if(psSfInfo->pstSFIndication && copy_to_user((PCHAR)user_buffer,
+ (PCHAR)psSfInfo->pstSFIndication, sizeof(stLocalSFAddIndicationAlt)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "copy to user failed SFID %d, present in queue !!!", uiSFId );
+ status = -EFAULT;
+ return status;
+ }
+ return STATUS_SUCCESS;
+}
+
+VOID OverrideServiceFlowParams(PMINI_ADAPTER Adapter,PUINT puiBuffer)
+{
+ B_UINT32 u32NumofSFsinMsg = ntohl(*(puiBuffer + 1));
+ stIM_SFHostNotify *pHostInfo = NULL;
+ UINT uiSearchRuleIndex = 0;
+ ULONG ulSFID = 0;
+
+ puiBuffer+=2;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "u32NumofSFsinMsg: 0x%x\n",u32NumofSFsinMsg);
+
+ while(u32NumofSFsinMsg != 0 && u32NumofSFsinMsg < NO_OF_QUEUES)
+ {
+ u32NumofSFsinMsg--;
+ pHostInfo = (stIM_SFHostNotify *)puiBuffer;
+ puiBuffer = (PUINT)(pHostInfo + 1);
+
+ ulSFID = ntohl(pHostInfo->SFID);
+ uiSearchRuleIndex=SearchSfid(Adapter,ulSFID);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"SFID: 0x%lx\n",ulSFID);
+
+ if(uiSearchRuleIndex >= NO_OF_QUEUES || uiSearchRuleIndex == HiPriority)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"The SFID <%lx> doesn't exist in host entry or is Invalid\n", ulSFID);
+ continue;
+ }
+
+ if(pHostInfo->RetainSF == FALSE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"Going to Delete SF");
+ deleteSFBySfid(Adapter,uiSearchRuleIndex);
+ }
+ else
+ {
+
+ Adapter->PackInfo[uiSearchRuleIndex].usVCID_Value = ntohs(pHostInfo->VCID);
+ Adapter->PackInfo[uiSearchRuleIndex].usCID = ntohs(pHostInfo->newCID);
+ Adapter->PackInfo[uiSearchRuleIndex].bActive=FALSE;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL,"pHostInfo->QoSParamSet: 0x%x\n",pHostInfo->QoSParamSet);
+
+ if(pHostInfo->QoSParamSet & 0x1)
+ Adapter->PackInfo[uiSearchRuleIndex].bAuthorizedSet =TRUE;
+ if(pHostInfo->QoSParamSet & 0x2)
+ Adapter->PackInfo[uiSearchRuleIndex].bAdmittedSet =TRUE;
+ if(pHostInfo->QoSParamSet & 0x4)
+ {
+ Adapter->PackInfo[uiSearchRuleIndex].bActiveSet =TRUE;
+ Adapter->PackInfo[uiSearchRuleIndex].bActive=TRUE;
+ }
+ }
+ }
+}
+
+
+
diff --git a/drivers/staging/bcm/CmHost.h b/drivers/staging/bcm/CmHost.h
new file mode 100644
index 00000000000..847782c3765
--- /dev/null
+++ b/drivers/staging/bcm/CmHost.h
@@ -0,0 +1,166 @@
+/// **************************************************************************
+/// (c) Beceem Communications Inc.
+/// All Rights Reserved
+///
+/// \file : CmHost.h
+/// \author : Rajeev Tirumala
+/// \date : September 8 , 2006
+/// \brief : Definitions for Connection Management Requests structure
+/// which we will use to setup our connection structures.Its high
+/// time we had a header file for CmHost.cpp to isolate the way
+/// f/w sends DSx messages and the way we interpret them in code.
+/// Revision History
+///
+/// Date Author Version Description
+/// 08-Sep-06 Rajeev 0.1 Created
+/// **************************************************************************
+#ifndef _CM_HOST_H
+#define _CM_HOST_H
+
+#pragma once
+#pragma pack (push,4)
+
+#define DSX_MESSAGE_EXCHANGE_BUFFER 0xBF60AC84 // This contains the pointer
+#define DSX_MESSAGE_EXCHANGE_BUFFER_SIZE 72000 // 24 K Bytes
+
+/// \brief structure stLocalSFAddRequest
+typedef struct stLocalSFAddRequestAlt{
+ B_UINT8 u8Type;
+ B_UINT8 u8Direction;
+
+ B_UINT16 u16TID;
+ /// \brief 16bitCID
+ B_UINT16 u16CID;
+ /// \brief 16bitVCID
+ B_UINT16 u16VCID;
+
+
+ /// \brief structure ParameterSet
+ stServiceFlowParamSI sfParameterSet;
+
+ //USE_MEMORY_MANAGER();
+}stLocalSFAddRequestAlt;
+
+/// \brief structure stLocalSFAddIndication
+typedef struct stLocalSFAddIndicationAlt{
+ B_UINT8 u8Type;
+ B_UINT8 u8Direction;
+ B_UINT16 u16TID;
+ /// \brief 16bitCID
+ B_UINT16 u16CID;
+ /// \brief 16bitVCID
+ B_UINT16 u16VCID;
+ /// \brief structure AuthorizedSet
+ stServiceFlowParamSI sfAuthorizedSet;
+ /// \brief structure AdmittedSet
+ stServiceFlowParamSI sfAdmittedSet;
+ /// \brief structure ActiveSet
+ stServiceFlowParamSI sfActiveSet;
+
+ B_UINT8 u8CC; /**< Confirmation Code*/
+ B_UINT8 u8Padd; /**< 8-bit Padding */
+ B_UINT16 u16Padd; /**< 16 bit Padding */
+// USE_MEMORY_MANAGER();
+}stLocalSFAddIndicationAlt;
+
+/// \brief structure stLocalSFAddConfirmation
+typedef struct stLocalSFAddConfirmationAlt{
+ B_UINT8 u8Type;
+ B_UINT8 u8Direction;
+ B_UINT16 u16TID;
+ /// \brief 16bitCID
+ B_UINT16 u16CID;
+ /// \brief 16bitVCID
+ B_UINT16 u16VCID;
+ /// \brief structure AuthorizedSet
+ stServiceFlowParamSI sfAuthorizedSet;
+ /// \brief structure AdmittedSet
+ stServiceFlowParamSI sfAdmittedSet;
+ /// \brief structure ActiveSet
+ stServiceFlowParamSI sfActiveSet;
+}stLocalSFAddConfirmationAlt;
+
+
+/// \brief structure stLocalSFChangeRequest
+typedef struct stLocalSFChangeRequestAlt{
+ B_UINT8 u8Type;
+ B_UINT8 u8Direction;
+ B_UINT16 u16TID;
+ /// \brief 16bitCID
+ B_UINT16 u16CID;
+ /// \brief 16bitVCID
+ B_UINT16 u16VCID;
+ /*
+ //Pointer location at which following Service Flow param Structure can be read
+ //from the target. We get only the address location and we need to read out the
+ //entire SF param structure at the given location on target
+ */
+ /// \brief structure AuthorizedSet
+ stServiceFlowParamSI sfAuthorizedSet;
+ /// \brief structure AdmittedSet
+ stServiceFlowParamSI sfAdmittedSet;
+ /// \brief structure ParameterSet
+ stServiceFlowParamSI sfActiveSet;
+
+ B_UINT8 u8CC; /**< Confirmation Code*/
+ B_UINT8 u8Padd; /**< 8-bit Padding */
+ B_UINT16 u16Padd; /**< 16 bit */
+
+}stLocalSFChangeRequestAlt;
+
+/// \brief structure stLocalSFChangeConfirmation
+typedef struct stLocalSFChangeConfirmationAlt{
+ B_UINT8 u8Type;
+ B_UINT8 u8Direction;
+ B_UINT16 u16TID;
+ /// \brief 16bitCID
+ B_UINT16 u16CID;
+ /// \brief 16bitVCID
+ B_UINT16 u16VCID;
+ /// \brief structure AuthorizedSet
+ stServiceFlowParamSI sfAuthorizedSet;
+ /// \brief structure AdmittedSet
+ stServiceFlowParamSI sfAdmittedSet;
+ /// \brief structure ActiveSet
+ stServiceFlowParamSI sfActiveSet;
+
+}stLocalSFChangeConfirmationAlt;
+
+/// \brief structure stLocalSFChangeIndication
+typedef struct stLocalSFChangeIndicationAlt{
+ B_UINT8 u8Type;
+ B_UINT8 u8Direction;
+ B_UINT16 u16TID;
+ /// \brief 16bitCID
+ B_UINT16 u16CID;
+ /// \brief 16bitVCID
+ B_UINT16 u16VCID;
+ /// \brief structure AuthorizedSet
+ stServiceFlowParamSI sfAuthorizedSet;
+ /// \brief structure AdmittedSet
+ stServiceFlowParamSI sfAdmittedSet;
+ /// \brief structure ActiveSet
+ stServiceFlowParamSI sfActiveSet;
+
+ B_UINT8 u8CC; /**< Confirmation Code*/
+ B_UINT8 u8Padd; /**< 8-bit Padding */
+ B_UINT16 u16Padd; /**< 16 bit */
+
+}stLocalSFChangeIndicationAlt;
+
+ULONG StoreCmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT *puBufferLength);
+
+ULONG GetNextTargetBufferLocation(PMINI_ADAPTER Adapter,B_UINT16 tid);
+
+INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
+
+INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
+ULONG SetUpTargetDsxBuffers(PMINI_ADAPTER Adapter);
+
+BOOLEAN CmControlResponseMessage(PMINI_ADAPTER Adapter,PVOID pvBuffer);
+
+VOID deleteSFBySfid(PMINI_ADAPTER Adapter, UINT uiSearchRuleIndex);
+
+#pragma pack (pop)
+
+#endif
diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c
new file mode 100644
index 00000000000..8907e211d48
--- /dev/null
+++ b/drivers/staging/bcm/DDRInit.c
@@ -0,0 +1,1302 @@
+#include "headers.h"
+
+#ifndef BCM_SHM_INTERFACE
+
+
+#define DDR_DUMP_INTERNAL_DEVICE_MEMORY 0xBFC02B00
+#define MIPS_CLOCK_REG 0x0f000820
+
+ //DDR INIT-133Mhz
+#define T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 12 //index for 0x0F007000
+static DDR_SET_NODE asT3_DDRSetting133MHz[]= {// # DPLL Clock Setting
+ {0x0F000800,0x00007212},
+ {0x0f000820,0x07F13FFF},
+ {0x0f000810,0x00000F95},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0f000840,0x0FFF1B00},
+ {0x0f000870,0x00000002},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ {0x0F00a04C,0x0000000C},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001
+ {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x02000007},
+ {0x0F007028,0x02020202},
+ {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a
+ {0x0F007030,0x05000000},
+ {0x0F007034,0x00000003},
+ {0x0F007038,0x110a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200
+ {0x0F00703C,0x02101010},//ROB - 0x02101010,//0x02101018},
+ {0x0F007040,0x45751200},//ROB - 0x45751200,//0x450f1200},
+ {0x0F007044,0x110a0d00},//ROB - 0x110a0d00//0x111f0d00
+ {0x0F007048,0x081b0306},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0000001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x0010246c},
+ {0x0F007064,0x00000010},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00007000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ //# Enable BW improvement within memory controller
+ {0x0F007094,0x00000104},
+ //# Enable 2 ports within X-bar
+ {0x0F00A000,0x00000016},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+ };
+//80Mhz
+#define T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 10 //index for 0x0F007000
+static DDR_SET_NODE asT3_DDRSetting80MHz[]= {// # DPLL Clock Setting
+ {0x0f000810,0x00000F95},
+ {0x0f000820,0x07f1ffff},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ {0x0F00a000,0x00000016},
+ {0x0F00a04C,0x0000000C},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01000000},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020000},
+ {0x0F007020,0x04020107},
+ {0x0F007024,0x00000007},
+ {0x0F007028,0x02020201},
+ {0x0F00702c,0x0204040a},
+ {0x0F007030,0x04000000},
+ {0x0F007034,0x00000002},
+ {0x0F007038,0x1F060200},
+ {0x0F00703C,0x1C22221F},
+ {0x0F007040,0x8A006600},
+ {0x0F007044,0x221a0800},
+ {0x0F007048,0x02690204},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0000001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x000A15D6},
+ {0x0F007064,0x0000000A},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00004000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ {0x0F007094,0x00000104},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+ };
+//100Mhz
+#define T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 13 //index for 0x0F007000
+static DDR_SET_NODE asT3_DDRSetting100MHz[]= {// # DPLL Clock Setting
+ {0x0F000800,0x00007008},
+ {0x0f000810,0x00000F95},
+ {0x0f000820,0x07F13E3F},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ // Changed source for X-bar and MIPS clock to APLL
+ //0x0f000840,0x0FFF1800,
+ {0x0f000840,0x0FFF1B00},
+ {0x0f000870,0x00000002},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ {0x0F00a04C,0x0000000C},
+ //# Enable 2 ports within X-bar
+ {0x0F00A000,0x00000016},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020001}, // POP - 0x00020000 Normal 0x01020000
+ {0x0F007020,0x04020107},//Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x00000007},
+ {0x0F007028,0x01020201},
+ {0x0F00702c,0x0204040A},
+ {0x0F007030,0x06000000},
+ {0x0F007034,0x00000004},
+ {0x0F007038,0x20080200},
+ {0x0F00703C,0x02030320},
+ {0x0F007040,0x6E7F1200},
+ {0x0F007044,0x01190A00},
+ {0x0F007048,0x06120305},//0x02690204 // 0x06120305
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0000001C},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x00082ED6},
+ {0x0F007064,0x0000000A},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00005000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ //# Enable BW improvement within memory controller
+ {0x0F007094,0x00000104},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+ };
+
+//Net T3B DDR Settings
+//DDR INIT-133Mhz
+static DDR_SET_NODE asDPLL_266MHZ[] = {
+ {0x0F000800,0x00007212},
+ {0x0f000820,0x07F13FFF},
+ {0x0f000810,0x00000F95},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0f000840,0x0FFF1B00},
+ {0x0f000870,0x00000002}
+ };
+#if 0
+static DDR_SET_NODE asDPLL_800MHZ[] = {
+ {0x0f000810,0x00000F95},
+ {0x0f000810,0x00000F95},
+ {0x0f000810,0x00000F95},
+ {0x0f000820,0x03F1365B},
+ {0x0f000840,0x0FFF0000},
+ {0x0f000880,0x000003DD},
+ {0x0f000860,0x00000000}
+ };
+#endif
+
+#define T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 11 //index for 0x0F007000
+static DDR_SET_NODE asT3B_DDRSetting133MHz[] = {// # DPLL Clock Setting
+ {0x0f000810,0x00000F95},
+ {0x0f000810,0x00000F95},
+ {0x0f000810,0x00000F95},
+ {0x0f000820,0x07F13652},
+ {0x0f000840,0x0FFF0800},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0f000880,0x000003DD},
+ {0x0f000860,0x00000000},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ //# Enable 2 ports within X-bar
+ {0x0F00A000,0x00000016},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001
+ {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x02000007},
+ {0x0F007028,0x02020202},
+ {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a
+ {0x0F007030,0x05000000},
+ {0x0F007034,0x00000003},
+ {0x0F007038,0x130a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200
+ {0x0F00703C,0x02101012},//ROB - 0x02101010,//0x02101018},
+ {0x0F007040,0x457D1200},//ROB - 0x45751200,//0x450f1200},
+ {0x0F007044,0x11130d00},//ROB - 0x110a0d00//0x111f0d00
+ {0x0F007048,0x040D0306},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0000001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x0010246c},
+ {0x0F007064,0x00000012},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00007000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ //# Enable BW improvement within memory controller
+ {0x0F007094,0x00000104},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000},
+ };
+
+#define T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000
+static DDR_SET_NODE asT3B_DDRSetting80MHz[] = {// # DPLL Clock Setting
+ {0x0f000810,0x00000F95},
+ {0x0f000820,0x07F13FFF},
+ {0x0f000840,0x0FFF1F00},
+ {0x0f000880,0x000003DD},
+ {0x0f000860,0x00000000},
+
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ {0x0F00a000,0x00000016},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01000000},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020000},
+ {0x0F007020,0x04020107},
+ {0x0F007024,0x00000007},
+ {0x0F007028,0x02020201},
+ {0x0F00702c,0x0204040a},
+ {0x0F007030,0x04000000},
+ {0x0F007034,0x02000002},
+ {0x0F007038,0x1F060202},
+ {0x0F00703C,0x1C22221F},
+ {0x0F007040,0x8A006600},
+ {0x0F007044,0x221a0800},
+ {0x0F007048,0x02690204},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0100001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x000A15D6},
+ {0x0F007064,0x0000000A},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00004000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ {0x0F007094,0x00000104},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+ };
+
+//100Mhz
+#define T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 9 //index for 0x0F007000
+static DDR_SET_NODE asT3B_DDRSetting100MHz[] = {// # DPLL Clock Setting
+ {0x0f000810,0x00000F95},
+ {0x0f000820,0x07F1369B},
+ {0x0f000840,0x0FFF0800},
+ {0x0f000880,0x000003DD},
+ {0x0f000860,0x00000000},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ //# Enable 2 ports within X-bar
+ {0x0F00A000,0x00000016},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020000}, // POP - 0x00020000 Normal 0x01020000
+ {0x0F007020,0x04020107},//Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x00000007},
+ {0x0F007028,0x01020201},
+ {0x0F00702c,0x0204040A},
+ {0x0F007030,0x06000000},
+ {0x0F007034,0x02000004},
+ {0x0F007038,0x20080200},
+ {0x0F00703C,0x02030320},
+ {0x0F007040,0x6E7F1200},
+ {0x0F007044,0x01190A00},
+ {0x0F007048,0x06120305},//0x02690204 // 0x06120305
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0100001C},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x00082ED6},
+ {0x0F007064,0x0000000A},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00005000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ //# Enable BW improvement within memory controller
+ {0x0F007094,0x00000104},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+ };
+
+
+#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 9 //index for 0x0F007000
+static DDR_SET_NODE asT3LP_DDRSetting133MHz[]= {// # DPLL Clock Setting
+ {0x0f000820,0x03F1365B},
+ {0x0f000810,0x00002F95},
+ {0x0f000880,0x000003DD},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0f000840,0x0FFF0000},
+ {0x0f000860,0x00000000},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ {0x0F00A000,0x00000016},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001
+ {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x02000007},
+ {0x0F007028,0x02020200},
+ {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a
+ {0x0F007030,0x05000000},
+ {0x0F007034,0x00000003},
+ {0x0F007038,0x200a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200
+ {0x0F00703C,0x02101020},//ROB - 0x02101010,//0x02101018,
+ {0x0F007040,0x45711200},//ROB - 0x45751200,//0x450f1200,
+ {0x0F007044,0x110D0D00},//ROB - 0x110a0d00//0x111f0d00
+ {0x0F007048,0x04080306},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0100001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x0010245F},
+ {0x0F007064,0x00000010},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00007000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ {0x0F007088,0x01000001},
+ {0x0F00708c,0x00000101},
+ {0x0F007090,0x00000000},
+ //# Enable BW improvement within memory controller
+ {0x0F007094,0x00040000},
+ {0x0F007098,0x00000000},
+ {0x0F0070c8,0x00000104},
+ //# Enable 2 ports within X-bar
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+};
+
+#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 11 //index for 0x0F007000
+static DDR_SET_NODE asT3LP_DDRSetting100MHz[]= {// # DPLL Clock Setting
+ {0x0f000810,0x00002F95},
+ {0x0f000820,0x03F1369B},
+ {0x0f000840,0x0fff0000},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0f000840,0x0FFF0000},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020000},// POP - 0x00020001 Normal 0x01020001
+ {0x0F007020,0x04020107}, //Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x00000007},
+ {0x0F007028,0x01020200},
+ {0x0F00702c,0x0204040a},//ROB- 0x0205050a,//0x0206060a
+ {0x0F007030,0x06000000},
+ {0x0F007034,0x00000004},
+ {0x0F007038,0x1F080200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200
+ {0x0F00703C,0x0203031F},//ROB - 0x02101010,//0x02101018,
+ {0x0F007040,0x6e001200},//ROB - 0x45751200,//0x450f1200,
+ {0x0F007044,0x011a0a00},//ROB - 0x110a0d00//0x111f0d00
+ {0x0F007048,0x03000305},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0100001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x00082ED6},
+ {0x0F007064,0x0000000A},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00005000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ {0x0F007088,0x01000001},
+ {0x0F00708c,0x00000101},
+ {0x0F007090,0x00000000},
+ {0x0F007094,0x00010000},
+ {0x0F007098,0x00000000},
+ {0x0F0070C8,0x00000104},
+ //# Enable 2 ports within X-bar
+ {0x0F00A000,0x00000016},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+};
+
+#define T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 9 //index for 0x0F007000
+static DDR_SET_NODE asT3LP_DDRSetting80MHz[]= {// # DPLL Clock Setting
+ {0x0f000820,0x07F13FFF},
+ {0x0f000810,0x00002F95},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ {0x0f000840,0x0FFF1F00},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0F00a084,0x1Cffffff},
+ {0x0F00a080,0x1C000000},
+ {0x0F00A000,0x00000016},
+ {0x0f007000,0x00010001},
+ {0x0f007004,0x01000000},
+ {0x0f007008,0x01000001},
+ {0x0f00700c,0x00000000},
+ {0x0f007010,0x01000000},
+ {0x0f007014,0x01000100},
+ {0x0f007018,0x01000000},
+ {0x0f00701c,0x01020000},
+ {0x0f007020,0x04020107},
+ {0x0f007024,0x00000007},
+ {0x0f007028,0x02020200},
+ {0x0f00702c,0x0204040a},
+ {0x0f007030,0x04000000},
+ {0x0f007034,0x00000002},
+ {0x0f007038,0x1d060200},
+ {0x0f00703c,0x1c22221d},
+ {0x0f007040,0x8A116600},
+ {0x0f007044,0x222d0800},
+ {0x0f007048,0x02690204},
+ {0x0f00704c,0x00000000},
+ {0x0f007050,0x0100001c},
+ {0x0f007054,0x00000000},
+ {0x0f007058,0x00000000},
+ {0x0f00705c,0x00000000},
+ {0x0f007060,0x000A15D6},
+ {0x0f007064,0x0000000A},
+ {0x0f007068,0x00000000},
+ {0x0f00706c,0x00000001},
+ {0x0f007070,0x00004000},
+ {0x0f007074,0x00000000},
+ {0x0f007078,0x00000000},
+ {0x0f00707c,0x00000000},
+ {0x0f007080,0x00000000},
+ {0x0f007084,0x00000000},
+ {0x0f007088,0x01000001},
+ {0x0f00708c,0x00000101},
+ {0x0f007090,0x00000000},
+ {0x0f007094,0x00010000},
+ {0x0f007098,0x00000000},
+ {0x0F0070C8,0x00000104},
+ {0x0F007018,0x01010000}
+};
+
+
+
+
+///T3 LP-B (UMA-B)
+
+#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ 7 //index for 0x0F007000
+static DDR_SET_NODE asT3LPB_DDRSetting160MHz[]= {// # DPLL Clock Setting
+
+ {0x0f000820,0x03F137DB},
+ {0x0f000810,0x01842795},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ {0x0f000840,0x0FFF0400},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0f003050,0x00000021},//this is flash/eeprom clock divisor which set the flash clock to 20 MHz
+ {0x0F00a084,0x1Cffffff},//Now dump from her in internal memory
+ {0x0F00a080,0x1C000000},
+ {0x0F00A000,0x00000016},
+ {0x0f007000,0x00010001},
+ {0x0f007004,0x01000001},
+ {0x0f007008,0x01000101},
+ {0x0f00700c,0x00000000},
+ {0x0f007010,0x01000100},
+ {0x0f007014,0x01000100},
+ {0x0f007018,0x01000000},
+ {0x0f00701c,0x01020000},
+ {0x0f007020,0x04030107},
+ {0x0f007024,0x02000007},
+ {0x0f007028,0x02020200},
+ {0x0f00702c,0x0206060a},
+ {0x0f007030,0x050d0d00},
+ {0x0f007034,0x00000003},
+ {0x0f007038,0x170a0200},
+ {0x0f00703c,0x02101012},
+ {0x0f007040,0x45161200},
+ {0x0f007044,0x11250c00},
+ {0x0f007048,0x04da0307},
+ {0x0f00704c,0x00000000},
+ {0x0f007050,0x0000001c},
+ {0x0f007054,0x00000000},
+ {0x0f007058,0x00000000},
+ {0x0f00705c,0x00000000},
+ {0x0f007060,0x00142bb6},
+ {0x0f007064,0x20430014},
+ {0x0f007068,0x00000000},
+ {0x0f00706c,0x00000001},
+ {0x0f007070,0x00009000},
+ {0x0f007074,0x00000000},
+ {0x0f007078,0x00000000},
+ {0x0f00707c,0x00000000},
+ {0x0f007080,0x00000000},
+ {0x0f007084,0x00000000},
+ {0x0f007088,0x01000001},
+ {0x0f00708c,0x00000101},
+ {0x0f007090,0x00000000},
+ {0x0f007094,0x00040000},
+ {0x0f007098,0x00000000},
+ {0x0F0070C8,0x00000104},
+ {0x0F007018,0x01010000}
+};
+
+
+#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ 7 //index for 0x0F007000
+static DDR_SET_NODE asT3LPB_DDRSetting133MHz[]= {// # DPLL Clock Setting
+ {0x0f000820,0x03F1365B},
+ {0x0f000810,0x00002F95},
+ {0x0f000880,0x000003DD},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0f000840,0x0FFF0000},
+ {0x0f000860,0x00000000},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz
+ {0x0F00a084,0x1Cffffff},//dump from here in internal memory
+ {0x0F00a080,0x1C000000},
+ {0x0F00A000,0x00000016},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020001},// POP - 0x00020001 Normal 0x01020001
+ {0x0F007020,0x04030107}, //Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x02000007},
+ {0x0F007028,0x02020200},
+ {0x0F00702c,0x0206060a},//ROB- 0x0205050a,//0x0206060a
+ {0x0F007030,0x05000000},
+ {0x0F007034,0x00000003},
+ {0x0F007038,0x190a0200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200
+ {0x0F00703C,0x02101017},//ROB - 0x02101010,//0x02101018,
+ {0x0F007040,0x45171200},//ROB - 0x45751200,//0x450f1200,
+ {0x0F007044,0x11290D00},//ROB - 0x110a0d00//0x111f0d00
+ {0x0F007048,0x04080306},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0100001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x0010245F},
+ {0x0F007064,0x00000010},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00007000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ {0x0F007088,0x01000001},
+ {0x0F00708c,0x00000101},
+ {0x0F007090,0x00000000},
+ //# Enable BW improvement within memory controller
+ {0x0F007094,0x00040000},
+ {0x0F007098,0x00000000},
+ {0x0F0070c8,0x00000104},
+ //# Enable 2 ports within X-bar
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+};
+
+#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ 8 //index for 0x0F007000
+static DDR_SET_NODE asT3LPB_DDRSetting100MHz[]= {// # DPLL Clock Setting
+ {0x0f000810,0x00002F95},
+ {0x0f000820,0x03F1369B},
+ {0x0f000840,0x0fff0000},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ // Changed source for X-bar and MIPS clock to APLL
+ {0x0f000840,0x0FFF0000},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz
+ {0x0F00a084,0x1Cffffff}, //dump from here in internal memory
+ {0x0F00a080,0x1C000000},
+ //Memcontroller Default values
+ {0x0F007000,0x00010001},
+ {0x0F007004,0x01010100},
+ {0x0F007008,0x01000001},
+ {0x0F00700c,0x00000000},
+ {0x0F007010,0x01000000},
+ {0x0F007014,0x01000100},
+ {0x0F007018,0x01000000},
+ {0x0F00701c,0x01020000},// POP - 0x00020001 Normal 0x01020001
+ {0x0F007020,0x04020107}, //Normal - 0x04030107 POP - 0x05030107
+ {0x0F007024,0x00000007},
+ {0x0F007028,0x01020200},
+ {0x0F00702c,0x0204040a},//ROB- 0x0205050a,//0x0206060a
+ {0x0F007030,0x06000000},
+ {0x0F007034,0x00000004},
+ {0x0F007038,0x1F080200},//ROB - 0x110a0200,//0x180a0200,// 0x1f0a0200
+ {0x0F00703C,0x0203031F},//ROB - 0x02101010,//0x02101018,
+ {0x0F007040,0x6e001200},//ROB - 0x45751200,//0x450f1200,
+ {0x0F007044,0x011a0a00},//ROB - 0x110a0d00//0x111f0d00
+ {0x0F007048,0x03000305},
+ {0x0F00704c,0x00000000},
+ {0x0F007050,0x0100001c},
+ {0x0F007054,0x00000000},
+ {0x0F007058,0x00000000},
+ {0x0F00705c,0x00000000},
+ {0x0F007060,0x00082ED6},
+ {0x0F007064,0x0000000A},
+ {0x0F007068,0x00000000},
+ {0x0F00706c,0x00000001},
+ {0x0F007070,0x00005000},
+ {0x0F007074,0x00000000},
+ {0x0F007078,0x00000000},
+ {0x0F00707C,0x00000000},
+ {0x0F007080,0x00000000},
+ {0x0F007084,0x00000000},
+ {0x0F007088,0x01000001},
+ {0x0F00708c,0x00000101},
+ {0x0F007090,0x00000000},
+ {0x0F007094,0x00010000},
+ {0x0F007098,0x00000000},
+ {0x0F0070C8,0x00000104},
+ //# Enable 2 ports within X-bar
+ {0x0F00A000,0x00000016},
+ //# Enable start bit within memory controller
+ {0x0F007018,0x01010000}
+};
+
+#define T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ 7 //index for 0x0F007000
+static DDR_SET_NODE asT3LPB_DDRSetting80MHz[]= {// # DPLL Clock Setting
+ {0x0f000820,0x07F13FFF},
+ {0x0f000810,0x00002F95},
+ {0x0f000860,0x00000000},
+ {0x0f000880,0x000003DD},
+ {0x0f000840,0x0FFF1F00},
+ {0x0F00a044,0x1fffffff},
+ {0x0F00a040,0x1f000000},
+ {0x0f003050,0x00000021},//flash/eeprom clock divisor which set the flash clock to 20 MHz
+ {0x0F00a084,0x1Cffffff},// dump from here in internal memory
+ {0x0F00a080,0x1C000000},
+ {0x0F00A000,0x00000016},
+ {0x0f007000,0x00010001},
+ {0x0f007004,0x01000000},
+ {0x0f007008,0x01000001},
+ {0x0f00700c,0x00000000},
+ {0x0f007010,0x01000000},
+ {0x0f007014,0x01000100},
+ {0x0f007018,0x01000000},
+ {0x0f00701c,0x01020000},
+ {0x0f007020,0x04020107},
+ {0x0f007024,0x00000007},
+ {0x0f007028,0x02020200},
+ {0x0f00702c,0x0204040a},
+ {0x0f007030,0x04000000},
+ {0x0f007034,0x00000002},
+ {0x0f007038,0x1d060200},
+ {0x0f00703c,0x1c22221d},
+ {0x0f007040,0x8A116600},
+ {0x0f007044,0x222d0800},
+ {0x0f007048,0x02690204},
+ {0x0f00704c,0x00000000},
+ {0x0f007050,0x0100001c},
+ {0x0f007054,0x00000000},
+ {0x0f007058,0x00000000},
+ {0x0f00705c,0x00000000},
+ {0x0f007060,0x000A15D6},
+ {0x0f007064,0x0000000A},
+ {0x0f007068,0x00000000},
+ {0x0f00706c,0x00000001},
+ {0x0f007070,0x00004000},
+ {0x0f007074,0x00000000},
+ {0x0f007078,0x00000000},
+ {0x0f00707c,0x00000000},
+ {0x0f007080,0x00000000},
+ {0x0f007084,0x00000000},
+ {0x0f007088,0x01000001},
+ {0x0f00708c,0x00000101},
+ {0x0f007090,0x00000000},
+ {0x0f007094,0x00010000},
+ {0x0f007098,0x00000000},
+ {0x0F0070C8,0x00000104},
+ {0x0F007018,0x01010000}
+};
+
+
+int ddr_init(MINI_ADAPTER *Adapter)
+{
+ PDDR_SETTING psDDRSetting=NULL;
+ ULONG RegCount=0;
+ ULONG value = 0;
+ UINT uiResetValue = 0;
+ UINT uiClockSetting = 0;
+ int retval = STATUS_SUCCESS;
+
+ switch (Adapter->chip_id)
+ {
+ case 0xbece3200:
+ switch (Adapter->DDRSetting)
+ {
+ case DDR_80_MHZ:
+ psDDRSetting=asT3LP_DDRSetting80MHz;
+ RegCount=(sizeof(asT3LP_DDRSetting80MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting=asT3LP_DDRSetting100MHz;
+ RegCount=(sizeof(asT3LP_DDRSetting100MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_133_MHZ:
+ psDDRSetting=asT3LP_DDRSetting133MHz;
+ RegCount=(sizeof(asT3LP_DDRSetting133MHz)/
+ sizeof(DDR_SETTING));
+ if(Adapter->bMipsConfig == MIPS_200_MHZ)
+ {
+ uiClockSetting = 0x03F13652;
+ }
+ else
+ {
+ uiClockSetting = 0x03F1365B;
+ }
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ break;
+ case T3LPB:
+ case BCS220_2:
+ case BCS220_2BC:
+ case BCS250_BC:
+ case BCS220_3 :
+ /* Set bit 2 and bit 6 to 1 for BBIC 2mA drive
+ * (please check current value and additionally set these bits)
+ */
+ if( (Adapter->chip_id != BCS220_2) &&
+ (Adapter->chip_id != BCS220_2BC) &&
+ (Adapter->chip_id != BCS220_3) )
+ {
+ retval= rdmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue |= 0x44;
+ retval = wrmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, WRM, DBG_LVL_ALL, "%s:%d WRM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ }
+ switch(Adapter->DDRSetting)
+ {
+
+
+
+ case DDR_80_MHZ:
+ psDDRSetting = asT3LPB_DDRSetting80MHz;
+ RegCount=(sizeof(asT3B_DDRSetting80MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting=asT3LPB_DDRSetting100MHz;
+ RegCount=(sizeof(asT3B_DDRSetting100MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_133_MHZ:
+ psDDRSetting = asT3LPB_DDRSetting133MHz;
+ RegCount=(sizeof(asT3B_DDRSetting133MHz)/
+ sizeof(DDR_SETTING));
+
+ if(Adapter->bMipsConfig == MIPS_200_MHZ)
+ {
+ uiClockSetting = 0x03F13652;
+ }
+ else
+ {
+ uiClockSetting = 0x03F1365B;
+ }
+ break;
+
+ case DDR_160_MHZ:
+ psDDRSetting = asT3LPB_DDRSetting160MHz;
+ RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SETTING);
+
+ if(Adapter->bMipsConfig == MIPS_200_MHZ)
+ {
+ uiClockSetting = 0x03F137D2;
+ }
+ else
+ {
+ uiClockSetting = 0x03F137DB;
+ }
+ }
+ break;
+
+ case 0xbece0110:
+ case 0xbece0120:
+ case 0xbece0121:
+ case 0xbece0130:
+ case 0xbece0300:
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting);
+ switch (Adapter->DDRSetting)
+ {
+ case DDR_80_MHZ:
+ psDDRSetting = asT3_DDRSetting80MHz;
+ RegCount = (sizeof(asT3_DDRSetting80MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting = asT3_DDRSetting100MHz;
+ RegCount = (sizeof(asT3_DDRSetting100MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_133_MHZ:
+ psDDRSetting = asT3_DDRSetting133MHz;
+ RegCount = (sizeof(asT3_DDRSetting133MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ default:
+ return -EINVAL;
+ }
+ case 0xbece0310:
+ {
+ switch (Adapter->DDRSetting)
+ {
+ case DDR_80_MHZ:
+ psDDRSetting = asT3B_DDRSetting80MHz;
+ RegCount=(sizeof(asT3B_DDRSetting80MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting=asT3B_DDRSetting100MHz;
+ RegCount=(sizeof(asT3B_DDRSetting100MHz)/
+ sizeof(DDR_SETTING));
+ break;
+ case DDR_133_MHZ:
+
+ if(Adapter->bDPLLConfig == PLL_266_MHZ)//266Mhz PLL selected.
+ {
+ memcpy(asT3B_DDRSetting133MHz, asDPLL_266MHZ,
+ sizeof(asDPLL_266MHZ));
+ psDDRSetting = asT3B_DDRSetting133MHz;
+ RegCount=(sizeof(asT3B_DDRSetting133MHz)/
+ sizeof(DDR_SETTING));
+ }
+ else
+ {
+ psDDRSetting = asT3B_DDRSetting133MHz;
+ RegCount=(sizeof(asT3B_DDRSetting133MHz)/
+ sizeof(DDR_SETTING));
+ if(Adapter->bMipsConfig == MIPS_200_MHZ)
+ {
+ uiClockSetting = 0x07F13652;
+ }
+ else
+ {
+ uiClockSetting = 0x07F1365B;
+ }
+ }
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+
+ }
+ default:
+ return -EINVAL;
+ }
+
+ value=0;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register Count is =%lu\n", RegCount);
+ while(RegCount && !retval)
+ {
+ if(uiClockSetting && psDDRSetting->ulRegAddress == MIPS_CLOCK_REG)
+ {
+ value = uiClockSetting;
+ }
+ else
+ {
+ value = psDDRSetting->ulRegValue;
+ }
+ retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, (PUINT)&value, sizeof(value));
+ if(STATUS_SUCCESS != retval) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__);
+ break;
+ }
+
+ RegCount--;
+ psDDRSetting++;
+ }
+
+ if(Adapter->chip_id >= 0xbece3300 )
+ {
+
+ mdelay(3);
+ if( (Adapter->chip_id != BCS220_2)&&
+ (Adapter->chip_id != BCS220_2BC)&&
+ (Adapter->chip_id != BCS220_3))
+ {
+ /* drive MDDR to half in case of UMA-B: */
+ uiResetValue = 0x01010001;
+ retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue = 0x00040020;
+ retval = wrmalt(Adapter, (UINT)0x0F007094, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue = 0x01020101;
+ retval = wrmalt(Adapter, (UINT)0x0F00701c, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue = 0x01010000;
+ retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ }
+ mdelay(3);
+
+ /* DC/DC standby change...
+ * This is to be done only for Hybrid PMU mode.
+ * with the current h/w there is no way to detect this.
+ * and since we dont have internal PMU lets do it under UMA-B chip id.
+ * we will change this when we will have internal PMU.
+ */
+ if(Adapter->PmuMode == HYBRID_MODE_7C)
+ {
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue = 0x1322a8;
+ retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue = 0x132296;
+ retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ }
+ else if(Adapter->PmuMode == HYBRID_MODE_6 )
+ {
+
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue = 0x6003229a;
+ retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ uiResetValue = 0x1322a8;
+ retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+ }
+
+ }
+ Adapter->bDDRInitDone = TRUE;
+ return retval;
+}
+
+int download_ddr_settings(PMINI_ADAPTER Adapter)
+{
+ PDDR_SET_NODE psDDRSetting=NULL;
+ ULONG RegCount=0;
+ unsigned long ul_ddr_setting_load_addr = DDR_DUMP_INTERNAL_DEVICE_MEMORY;
+ UINT value = 0;
+ int retval = STATUS_SUCCESS;
+ BOOLEAN bOverrideSelfRefresh = FALSE;
+
+ switch (Adapter->chip_id)
+ {
+ case 0xbece3200:
+ switch (Adapter->DDRSetting)
+ {
+ case DDR_80_MHZ:
+ psDDRSetting = asT3LP_DDRSetting80MHz;
+ RegCount = (sizeof(asT3LP_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
+ psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting = asT3LP_DDRSetting100MHz;
+ RegCount = (sizeof(asT3LP_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
+ psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
+ break;
+ case DDR_133_MHZ:
+ bOverrideSelfRefresh = TRUE;
+ psDDRSetting = asT3LP_DDRSetting133MHz;
+ RegCount = (sizeof(asT3LP_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
+ psDDRSetting += T3LP_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+
+ case T3LPB:
+ case BCS220_2:
+ case BCS220_2BC:
+ case BCS250_BC:
+ case BCS220_3 :
+ switch (Adapter->DDRSetting)
+ {
+ case DDR_80_MHZ:
+ psDDRSetting = asT3LPB_DDRSetting80MHz;
+ RegCount=(sizeof(asT3LPB_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
+ psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting = asT3LPB_DDRSetting100MHz;
+ RegCount = (sizeof(asT3LPB_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
+ psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
+ break;
+ case DDR_133_MHZ:
+ bOverrideSelfRefresh = TRUE;
+ psDDRSetting = asT3LPB_DDRSetting133MHz;
+ RegCount = (sizeof(asT3LPB_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
+ psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
+ break;
+
+ case DDR_160_MHZ:
+ bOverrideSelfRefresh = TRUE;
+ psDDRSetting = asT3LPB_DDRSetting160MHz;
+ RegCount = sizeof(asT3LPB_DDRSetting160MHz)/sizeof(DDR_SET_NODE);
+ RegCount -= T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
+ psDDRSetting += T3LPB_SKIP_CLOCK_PROGRAM_DUMP_160MHZ;
+
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+ case 0xbece0300:
+ switch (Adapter->DDRSetting)
+ {
+ case DDR_80_MHZ:
+ psDDRSetting = asT3_DDRSetting80MHz;
+ RegCount = (sizeof(asT3_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
+ psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting = asT3_DDRSetting100MHz;
+ RegCount = (sizeof(asT3_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
+ psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
+ break;
+ case DDR_133_MHZ:
+ psDDRSetting = asT3_DDRSetting133MHz;
+ RegCount = (sizeof(asT3_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount-=T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
+ psDDRSetting += T3_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
+ break;
+ default:
+ return -EINVAL;
+ }
+ break;
+ case 0xbece0310:
+ {
+ switch (Adapter->DDRSetting)
+ {
+ case DDR_80_MHZ:
+ psDDRSetting = asT3B_DDRSetting80MHz;
+ RegCount = (sizeof(asT3B_DDRSetting80MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ ;
+ psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_80MHZ;
+ break;
+ case DDR_100_MHZ:
+ psDDRSetting = asT3B_DDRSetting100MHz;
+ RegCount = (sizeof(asT3B_DDRSetting100MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ ;
+ psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_100MHZ;
+ break;
+ case DDR_133_MHZ:
+ bOverrideSelfRefresh = TRUE;
+ psDDRSetting = asT3B_DDRSetting133MHz;
+ RegCount = (sizeof(asT3B_DDRSetting133MHz)/sizeof(DDR_SET_NODE));
+ RegCount -= T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ ;
+ psDDRSetting += T3B_SKIP_CLOCK_PROGRAM_DUMP_133MHZ;
+ break;
+ }
+ break;
+ }
+ default:
+ return -EINVAL;
+ }
+ //total number of Register that has to be dumped
+ value =RegCount ;
+ retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value));
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__);
+
+ return retval;
+ }
+ ul_ddr_setting_load_addr+=sizeof(ULONG);
+ /*signature */
+ value =(0x1d1e0dd0);
+ retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value));
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__);
+ return retval;
+ }
+
+ ul_ddr_setting_load_addr+=sizeof(ULONG);
+ RegCount*=(sizeof(DDR_SETTING)/sizeof(ULONG));
+
+ while(RegCount && !retval)
+ {
+ value = psDDRSetting->ulRegAddress ;
+ retval = wrmalt( Adapter, ul_ddr_setting_load_addr, &value, sizeof(value));
+ ul_ddr_setting_load_addr+=sizeof(ULONG);
+ if(!retval)
+ {
+ if(bOverrideSelfRefresh && (psDDRSetting->ulRegAddress == 0x0F007018))
+ {
+ value = (psDDRSetting->ulRegValue |(1<<8));
+ if(STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr,
+ &value, sizeof(value))){
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__);
+ break;
+ }
+ }
+ else
+ {
+ value = psDDRSetting->ulRegValue;
+
+ if(STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr ,
+ &value, sizeof(value))){
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__);
+ break;
+ }
+ }
+ }
+ ul_ddr_setting_load_addr+=sizeof(ULONG);
+ RegCount--;
+ psDDRSetting++;
+ }
+ return retval;
+}
+
+#endif
+
diff --git a/drivers/staging/bcm/DDRInit.h b/drivers/staging/bcm/DDRInit.h
new file mode 100644
index 00000000000..550e260df53
--- /dev/null
+++ b/drivers/staging/bcm/DDRInit.h
@@ -0,0 +1,9 @@
+#ifndef _DDR_INIT_H_
+#define _DDR_INIT_H_
+
+
+
+int ddr_init(PMINI_ADAPTER psAdapter);
+int download_ddr_settings(PMINI_ADAPTER psAdapter);
+
+#endif
diff --git a/drivers/staging/bcm/Debug.c b/drivers/staging/bcm/Debug.c
new file mode 100644
index 00000000000..213f4bcc5df
--- /dev/null
+++ b/drivers/staging/bcm/Debug.c
@@ -0,0 +1,40 @@
+#include "headers.h"
+
+char *buff_dump_base[]={"DEC", "HEX", "OCT", "BIN" };
+
+static UINT current_debug_level=BCM_SCREAM;
+
+int bcm_print_buffer( UINT debug_level, const char *function_name,
+ char *file_name, int line_number, unsigned char *buffer, int bufferlen, unsigned int base)
+{
+ if(debug_level>=current_debug_level)
+ {
+ int i=0;
+ printk("\n%s:%s:%d:Buffer dump of size 0x%x in the %s:\n", file_name, function_name, line_number, bufferlen, buff_dump_base[1]);
+ for(;i<bufferlen;i++)
+ {
+ if(i && !(i%16) )
+ printk("\n");
+ switch(base)
+ {
+ case BCM_BASE_TYPE_DEC:
+ printk("%03d ", buffer[i]);
+ break;
+ case BCM_BASE_TYPE_OCT:
+ printk("%0x03o ", buffer[i]);
+ break;
+ case BCM_BASE_TYPE_BIN:
+ printk("%02x ", buffer[i]);
+ break;
+ case BCM_BASE_TYPE_HEX:
+ default:
+ printk("%02X ", buffer[i]);
+ break;
+ }
+ }
+ printk("\n");
+ }
+ return 0;
+}
+
+
diff --git a/drivers/staging/bcm/Debug.h b/drivers/staging/bcm/Debug.h
new file mode 100644
index 00000000000..3d788b59ab5
--- /dev/null
+++ b/drivers/staging/bcm/Debug.h
@@ -0,0 +1,297 @@
+/*
+ * Debug.h
+ *
+ * Dynamic (runtime) debug framework implementation.
+ * -kaiwan.
+ */
+#ifndef _DEBUG_H
+#define _DEBUG_H
+#include <linux/string.h>
+#define NONE 0xFFFF
+
+typedef enum _BASE_TYPE
+{
+ BCM_BASE_TYPE_DEC,
+ BCM_BASE_TYPE_OCT,
+ BCM_BASE_TYPE_BIN,
+ BCM_BASE_TYPE_HEX,
+ BCM_BASE_TYPE_NONE,
+} BASE_TYPE, *PBASE_TYPE;
+
+int bcm_print_buffer( UINT debug_level, const char *function_name,
+ char *file_name, int line_number, unsigned char *buffer, int bufferlen, BASE_TYPE base);
+
+#ifdef BCM_SHM_INTERFACE
+#define CPE_VIRTUAL_ERROR_CODE_BASE_ADDR (0xBFC02E00 + 0x4C)
+// ERROR codes for debugging
+extern unsigned char u32ErrorCounter ;
+#define ERROR_DEVICE_REMOVED 0x1
+#define ERROR_LEADER_LENGTH_ZERO 0x2
+#define ERROR_LEADER_LENGTH_CORRUPTED 0x3
+#define ERROR_NO_SKBUFF 0x4
+
+#define ERROR_DL_MODULE 0xaa000000
+extern void CPE_ERROR_LOG(unsigned int module,unsigned int code);
+
+#endif
+
+
+
+
+//--------------------------------------------------------------------------------
+
+/* TYPE and SUBTYPE
+ * Define valid TYPE (or category or code-path, however you like to think of it)
+ * and SUBTYPE s.
+ * Type and SubType are treated as bitmasks.
+ */
+/*-----------------BEGIN TYPEs------------------------------------------*/
+#define DBG_TYPE_INITEXIT (1 << 0) // 1
+#define DBG_TYPE_TX (1 << 1) // 2
+#define DBG_TYPE_RX (1 << 2) // 4
+#define DBG_TYPE_OTHERS (1 << 3) // 8
+/*-----------------END TYPEs------------------------------------------*/
+#define NUMTYPES 4 // careful!
+
+/*-----------------BEGIN SUBTYPEs---------------------------------------*/
+
+/*-SUBTYPEs for TX : TYPE is DBG_TYPE_TX -----//
+ Transmit.c ,Arp.c, LeakyBucket.c, And Qos.c
+ total 17 macros */
+// Transmit.c
+#define TX 1
+#define MP_SEND (TX<<0)
+#define NEXT_SEND (TX<<1)
+#define TX_FIFO (TX<<2)
+#define TX_CONTROL (TX<<3)
+
+// Arp.c
+#define IP_ADDR (TX<<4)
+#define ARP_REQ (TX<<5)
+#define ARP_RESP (TX<<6)
+
+// dhcp.c
+//#define DHCP TX
+//#define DHCP_REQ (DHCP<<7)
+
+// Leakybucket.c
+#define TOKEN_COUNTS (TX<<8)
+#define CHECK_TOKENS (TX<<9)
+#define TX_PACKETS (TX<<10)
+#define TIMER (TX<<11)
+
+// Qos.c
+#define QOS TX
+#define QUEUE_INDEX (QOS<<12)
+#define IPV4_DBG (QOS<<13)
+#define IPV6_DBG (QOS<<14)
+#define PRUNE_QUEUE (QOS<<15)
+#define SEND_QUEUE (QOS<<16)
+
+//TX_Misc
+#define TX_OSAL_DBG (TX<<17)
+
+
+//--SUBTYPEs for ------INIT & EXIT---------------------
+/*------------ TYPE is DBG_TYPE_INITEXIT -----//
+DriverEntry.c, bcmfwup.c, ChipDetectTask.c, HaltnReset.c, InterfaceDDR.c */
+#define MP 1
+#define DRV_ENTRY (MP<<0)
+#define MP_INIT (MP<<1)
+#define READ_REG (MP<<3)
+#define DISPATCH (MP<<2)
+#define CLAIM_ADAP (MP<<4)
+#define REG_IO_PORT (MP<<5)
+#define INIT_DISP (MP<<6)
+#define RX_INIT (MP<<7)
+
+
+//-SUBTYPEs for --RX----------------------------------
+//------------RX : TYPE is DBG_TYPE_RX -----//
+// Receive.c
+#define RX 1
+#define RX_DPC (RX<<0)
+#define RX_CTRL (RX<<3)
+#define RX_DATA (RX<<4)
+#define MP_RETURN (RX<<1)
+#define LINK_MSG (RX<<2)
+
+
+//-SUBTYPEs for ----OTHER ROUTINES------------------
+//------------OTHERS : TYPE is DBG_TYPE_OTHER -----//
+// HaltnReset,CheckForHang,PnP,Misc,CmHost
+// total 12 macros
+#define OTHERS 1
+// ??ISR.C
+
+#define ISR OTHERS
+#define MP_DPC (ISR<<0)
+
+// HaltnReset.c
+#define HALT OTHERS
+#define MP_HALT (HALT<<1)
+#define CHECK_HANG (HALT<<2)
+#define MP_RESET (HALT<<3)
+#define MP_SHUTDOWN (HALT<<4)
+
+// pnp.c
+#define PNP OTHERS
+#define MP_PNP (PNP<<5)
+
+// Misc.c
+#define MISC OTHERS
+#define DUMP_INFO (MISC<<6)
+#define CLASSIFY (MISC<<7)
+#define LINK_UP_MSG (MISC<<8)
+#define CP_CTRL_PKT (MISC<<9)
+#define DUMP_CONTROL (MISC<<10)
+#define LED_DUMP_INFO (MISC<<11)
+
+// CmHost.c
+#define CMHOST OTHERS
+
+
+#define SERIAL (OTHERS<<12)
+#define IDLE_MODE (OTHERS<<13)
+
+#define WRM (OTHERS<<14)
+#define RDM (OTHERS<<15)
+
+// TODO - put PHS_SEND in Tx PHS_RECEIVE in Rx path ?
+#define PHS_SEND (OTHERS<<16)
+#define PHS_RECIEVE (OTHERS<<17)
+#define PHS_MODULE (OTHERS<<18)
+
+#define INTF_INIT (OTHERS<<19)
+#define INTF_ERR (OTHERS<<20)
+#define INTF_WARN (OTHERS<<21)
+#define INTF_NORM (OTHERS<<22)
+
+#define IRP_COMPLETION (OTHERS<<23)
+#define SF_DESCRIPTOR_CNTS (OTHERS<<24)
+#define PHS_DISPATCH (OTHERS << 25)
+#define OSAL_DBG (OTHERS << 26)
+#define NVM_RW (OTHERS << 27)
+
+#define HOST_MIBS (OTHERS << 28)
+#define CONN_MSG (CMHOST << 29)
+//#define OTHERS_MISC (OTHERS << 29) // ProcSupport.c
+/*-----------------END SUBTYPEs------------------------------------------*/
+
+
+/* Debug level
+ * We have 8 debug levels, in (numerical) increasing order of verbosity.
+ * IMP: Currently implementing ONLY DBG_LVL_ALL , i.e. , all debug prints will
+ * appear (of course, iff global debug flag is ON and we match the Type and SubType).
+ * Finer granularity debug levels are currently not in use, although the feature exists.
+ *
+ * Another way to say this:
+ * All the debug prints currently have 'debug_level' set to DBG_LVL_ALL .
+ * You can compile-time change that to any of the below, if you wish to. However, as of now, there's
+ * no dynamic facility to have the userspace 'TestApp' set debug_level. Slated for future expansion.
+ */
+#define BCM_ALL 7
+#define BCM_LOW 6
+#define BCM_PRINT 5
+#define BCM_NORMAL 4
+#define BCM_MEDIUM 3
+#define BCM_SCREAM 2
+#define BCM_ERR 1
+/* Not meant for developer in debug prints.
+ * To be used to disable all prints by setting the DBG_LVL_CURR to this value */
+#define BCM_NONE 0
+
+/* The current driver logging level.
+ * Everything at this level and (numerically) lower (meaning higher prio)
+ * is logged.
+* Replace 'BCM_ALL' in the DBG_LVL_CURR macro with the logging level desired.
+ * For eg. to set the logging level to 'errors only' use:
+ * #define DBG_LVL_CURR (BCM_ERR)
+ */
+
+#define DBG_LVL_CURR (BCM_ALL)
+#define DBG_LVL_ALL BCM_ALL
+
+/*---Userspace mapping of Debug State.
+ * Delibrately matches that of the Windows driver..
+ * The TestApp's ioctl passes this struct to us.
+ */
+typedef struct
+{
+ unsigned int Subtype, Type;
+ unsigned int OnOff;
+// unsigned int debug_level; /* future expansion */
+} __attribute__((packed)) USER_BCM_DBG_STATE;
+
+//---Kernel-space mapping of Debug State
+typedef struct _S_BCM_DEBUG_STATE {
+ UINT type;
+ /* A bitmap of 32 bits for Subtype per Type.
+ * Valid indexes in 'subtype' array are *only* 1,2,4 and 8,
+ * corresponding to valid Type values. Hence we use the 'Type' field
+ * as the index value, ignoring the array entries 0,3,5,6,7 !
+ */
+ UINT subtype[(NUMTYPES*2)+1];
+ UINT debug_level;
+} S_BCM_DEBUG_STATE;
+/* Instantiated in the Adapter structure */
+/* We'll reuse the debug level parameter to include a bit (the MSB) to indicate whether or not
+ * we want the function's name printed. */
+#define DBG_NO_FUNC_PRINT 1 << 31
+#define DBG_LVL_BITMASK 0xFF
+
+//--- Only for direct printk's; "hidden" to API.
+#define DBG_TYPE_PRINTK 3
+#define PRINTKS_ON 1 // "hidden" from API, set to 0 to turn off all printk's
+
+#define BCM_DEBUG_PRINT(Adapter, Type, SubType, dbg_level, string, args...) do { \
+ if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \
+ printk ("%s:" string, __FUNCTION__, ##args); \
+ printk("\n"); \
+ } else if (!Adapter) \
+ ; \
+ else { \
+ if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \
+ ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \
+ if (dbg_level & DBG_NO_FUNC_PRINT) \
+ printk (string, ##args); \
+ else \
+ { \
+ printk ("%s:" string, __FUNCTION__, ##args); \
+ printk("\n"); \
+ } \
+ } \
+ } \
+} while (0)
+
+#define BCM_DEBUG_PRINT_BUFFER(Adapter, Type, SubType, dbg_level, buffer, bufferlen) do { \
+ if ((DBG_TYPE_PRINTK == Type) && (PRINTKS_ON)) { \
+ bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \
+ } else if (!Adapter) \
+ ; \
+ else { \
+ if (((dbg_level & DBG_LVL_BITMASK) <= Adapter->stDebugState.debug_level) && \
+ ((Type & Adapter->stDebugState.type) && (SubType & Adapter->stDebugState.subtype[Type]))) { \
+ if (dbg_level & DBG_NO_FUNC_PRINT) \
+ bcm_print_buffer( dbg_level, NULL, NULL, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \
+ else \
+ bcm_print_buffer( dbg_level, __FUNCTION__, __FILE__, __LINE__, buffer, bufferlen, BCM_BASE_TYPE_HEX); \
+ } \
+ } \
+ } while (0)
+
+
+#define BCM_SHOW_DEBUG_BITMAP(Adapter) do { \
+ int i; \
+ for (i=0; i<(NUMTYPES*2)+1; i++) { \
+ if ((i == 1) || (i == 2) || (i == 4) || (i == 8)) { \
+ /* CAUTION! Forcefully turn on ALL debug paths and subpaths! \
+ Adapter->stDebugState.subtype[i] = 0xffffffff; */ \
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_PRINTK, 0, 0, "subtype[%d] = 0x%08x\n", \
+ i, Adapter->stDebugState.subtype[i]); \
+ } \
+ } \
+} while (0)
+
+#endif
+
diff --git a/drivers/staging/bcm/HandleControlPacket.c b/drivers/staging/bcm/HandleControlPacket.c
new file mode 100644
index 00000000000..849951345ab
--- /dev/null
+++ b/drivers/staging/bcm/HandleControlPacket.c
@@ -0,0 +1,247 @@
+/**
+@file HandleControlPacket.c
+This file contains the routines to deal with
+sending and receiving of control packets.
+*/
+#include "headers.h"
+
+/**
+When a control packet is received, analyze the
+"status" and call appropriate response function.
+Enqueue the control packet for Application.
+@return None
+*/
+VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/
+ struct sk_buff *skb) /**<Pointer to the socket buffer*/
+{
+ PPER_TARANG_DATA pTarang = NULL;
+ BOOLEAN HighPriorityMessage = FALSE;
+ struct sk_buff * newPacket = NULL;
+ CHAR cntrl_msg_mask_bit = 0;
+ BOOLEAN drop_pkt_flag = TRUE ;
+ USHORT usStatus = *(PUSHORT)(skb->data);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "=====>");
+ /* Get the Leader field */
+
+ switch(usStatus)
+ {
+ case CM_RESPONSES: // 0xA0
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "MAC Version Seems to be Non Multi-Classifier, rejected by Driver");
+ HighPriorityMessage = TRUE ;
+ break;
+ case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP:
+ HighPriorityMessage = TRUE ;
+ if(Adapter->LinkStatus==LINKUP_DONE)
+ {
+ CmControlResponseMessage(Adapter,(skb->data +sizeof(USHORT)));
+ }
+ break;
+ case LINK_CONTROL_RESP: //0xA2
+ case STATUS_RSP: //0xA1
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,"LINK_CONTROL_RESP");
+ HighPriorityMessage = TRUE ;
+ LinkControlResponseMessage(Adapter,(skb->data + sizeof(USHORT)));
+ break;
+ case STATS_POINTER_RESP: //0xA6
+ HighPriorityMessage = TRUE ;
+ StatisticsResponse(Adapter, (skb->data + sizeof(USHORT)));
+ break;
+ case IDLE_MODE_STATUS: //0xA3
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,"IDLE_MODE_STATUS Type Message Got from F/W");
+ InterfaceIdleModeRespond(Adapter, (PUINT)(skb->data +
+ sizeof(USHORT)));
+ HighPriorityMessage = TRUE ;
+ break;
+
+ case AUTH_SS_HOST_MSG:
+ HighPriorityMessage = TRUE ;
+ break;
+
+ default:
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL,"Got Default Response");
+ /* Let the Application Deal with This Packet */
+ break;
+ }
+
+ //Queue The Control Packet to The Application Queues
+ down(&Adapter->RxAppControlQueuelock);
+
+ for (pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next)
+ {
+ if(Adapter->device_removed)
+ {
+ break;
+ }
+
+ drop_pkt_flag = TRUE ;
+ /*
+ There are cntrl msg from A0 to AC. It has been mapped to 0 to C bit in the cntrl mask.
+ Also, by default AD to BF has been masked to the rest of the bits... which wil be ON by default.
+ if mask bit is enable to particular pkt status, send it out to app else stop it.
+ */
+ cntrl_msg_mask_bit = (usStatus & 0x1F);
+ //printk("\ninew msg mask bit which is disable in mask:%X", cntrl_msg_mask_bit);
+ if(pTarang->RxCntrlMsgBitMask & (1<<cntrl_msg_mask_bit))
+ drop_pkt_flag = FALSE;
+
+ if ((drop_pkt_flag == TRUE) || (pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN) ||
+ ((pTarang->AppCtrlQueueLen > MAX_APP_QUEUE_LEN/2) && (HighPriorityMessage == FALSE)))
+ {
+ /*
+ Assumption:-
+ 1. every tarang manages it own dropped pkt statitistics
+ 2. Total packet dropped per tarang will be equal to the sum of all types of dropped
+ pkt by that tarang only.
+
+ */
+ switch(*(PUSHORT)skb->data)
+ {
+ case CM_RESPONSES:
+ pTarang->stDroppedAppCntrlMsgs.cm_responses++;
+ break;
+ case CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP:
+ pTarang->stDroppedAppCntrlMsgs.cm_control_newdsx_multiclassifier_resp++;
+ break;
+ case LINK_CONTROL_RESP:
+ pTarang->stDroppedAppCntrlMsgs.link_control_resp++;
+ break;
+ case STATUS_RSP:
+ pTarang->stDroppedAppCntrlMsgs.status_rsp++;
+ break;
+ case STATS_POINTER_RESP:
+ pTarang->stDroppedAppCntrlMsgs.stats_pointer_resp++;
+ break;
+ case IDLE_MODE_STATUS:
+ pTarang->stDroppedAppCntrlMsgs.idle_mode_status++ ;
+ break;
+ case AUTH_SS_HOST_MSG:
+ pTarang->stDroppedAppCntrlMsgs.auth_ss_host_msg++ ;
+ break;
+ default:
+ pTarang->stDroppedAppCntrlMsgs.low_priority_message++ ;
+ break;
+ }
+
+ continue;
+ }
+
+ newPacket = skb_clone(skb, GFP_KERNEL);
+ if (!newPacket)
+ break;
+ ENQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail,
+ newPacket);
+ pTarang->AppCtrlQueueLen++;
+ }
+ up(&Adapter->RxAppControlQueuelock);
+ wake_up(&Adapter->process_read_wait_queue);
+ bcm_kfree_skb(skb);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "After wake_up_interruptible");
+}
+
+/**
+@ingroup ctrl_pkt_functions
+Thread to handle control pkt reception
+*/
+int control_packet_handler (PMINI_ADAPTER Adapter /**< pointer to adapter object*/
+ )
+{
+ struct sk_buff *ctrl_packet= NULL;
+ unsigned long flags = 0;
+ //struct timeval tv ;
+ //int *puiBuffer = NULL ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "Entering to make thread wait on control packet event!");
+ while(1)
+ {
+ wait_event_interruptible(Adapter->process_rx_cntrlpkt,
+ atomic_read(&Adapter->cntrlpktCnt) ||
+ Adapter->bWakeUpDevice ||
+ kthread_should_stop()
+ );
+
+
+ if(kthread_should_stop())
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "Exiting \n");
+ return 0;
+ }
+ if(TRUE == Adapter->bWakeUpDevice)
+ {
+ Adapter->bWakeUpDevice = FALSE;
+ if((FALSE == Adapter->bTriedToWakeUpFromlowPowerMode) &&
+ ((TRUE == Adapter->IdleMode)|| (TRUE == Adapter->bShutStatus)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "Calling InterfaceAbortIdlemode\n");
+ // Adapter->bTriedToWakeUpFromlowPowerMode = TRUE;
+ InterfaceIdleModeWakeup (Adapter);
+ }
+ continue;
+ }
+
+ while(atomic_read(&Adapter->cntrlpktCnt))
+ {
+ spin_lock_irqsave(&Adapter->control_queue_lock, flags);
+ ctrl_packet = Adapter->RxControlHead;
+ if(ctrl_packet)
+ {
+ DEQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail);
+// Adapter->RxControlHead=ctrl_packet->next;
+ ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.rx_packets++;
+ ((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats.rx_bytes+=
+ ((PLEADER)ctrl_packet->data)->PLength;
+ }
+ #if 0 //Idle mode debug profiling...
+ if(*(PUSHORT)ctrl_packet->data == IDLE_MODE_STATUS)
+ {
+ puiBuffer = (PUINT)(ctrl_packet->data +sizeof(USHORT));
+ if((ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD))
+ {
+ memset(&tv, 0, sizeof(tv));
+ do_gettimeofday(&tv);
+ if((ntohl(*(puiBuffer+1)) == 0))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "IdleMode Wake-up Msg from f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "IdleMode req Msg from f/w at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000);
+ }
+ }
+ else if((ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, CP_CTRL_PKT, DBG_LVL_ALL, "GOT IDLE_MODE_SF_UPDATE MSG at time :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000);
+ }
+ }
+ #endif
+
+ spin_unlock_irqrestore (&Adapter->control_queue_lock, flags);
+ handle_rx_control_packet(Adapter, ctrl_packet);
+ atomic_dec(&Adapter->cntrlpktCnt);
+ }
+
+ SetUpTargetDsxBuffers(Adapter);
+ }
+ return STATUS_SUCCESS;
+}
+
+INT flushAllAppQ()
+{
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ PPER_TARANG_DATA pTarang = NULL;
+ struct sk_buff *PacketToDrop = NULL;
+ for(pTarang = Adapter->pTarangs; pTarang; pTarang = pTarang->next)
+ {
+ while(pTarang->RxAppControlHead != NULL)
+ {
+ PacketToDrop=pTarang->RxAppControlHead;
+ DEQUEUEPACKET(pTarang->RxAppControlHead,pTarang->RxAppControlTail);
+ bcm_kfree_skb(PacketToDrop);
+ }
+ pTarang->AppCtrlQueueLen = 0;
+ //dropped contrl packet statistics also should be reset.
+ memset((PVOID)&pTarang->stDroppedAppCntrlMsgs, 0, sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES));
+
+ }
+ return STATUS_SUCCESS ;
+}
+
+
diff --git a/drivers/staging/bcm/HostMIBSInterface.h b/drivers/staging/bcm/HostMIBSInterface.h
new file mode 100644
index 00000000000..f17a4f13474
--- /dev/null
+++ b/drivers/staging/bcm/HostMIBSInterface.h
@@ -0,0 +1,230 @@
+
+
+#ifndef _HOST_MIBSINTERFACE_H
+#define _HOST_MIBSINTERFACE_H
+
+/*
+ * Copyright (c) 2007 Beceem Communications Pvt. Ltd
+ * File Name: HostMIBSInterface.h
+ * Abstract: This file contains DS used by the Host to update the Host
+ * statistics used for the MIBS.
+ */
+
+#define MIBS_MAX_CLASSIFIERS 100
+#define MIBS_MAX_PHSRULES 100
+#define MIBS_MAX_SERVICEFLOWS 17
+#define MIBS_MAX_IP_RANGE_LENGTH 4
+#define MIBS_MAX_PORT_RANGE 4
+#define MIBS_MAX_PROTOCOL_LENGTH 32
+#define MIBS_MAX_PHS_LENGTHS 255
+#define MIBS_IPV6_ADDRESS_SIZEINBYTES 0x10
+#define MIBS_IP_LENGTH_OF_ADDRESS 4
+#define MIBS_MAX_HIST_ENTRIES 12
+#define MIBS_PKTSIZEHIST_RANGE 128
+
+typedef union _U_MIBS_IP_ADDRESS
+{
+ struct
+ {
+ //Source Ip Address Range
+ ULONG ulIpv4Addr[MIBS_MAX_IP_RANGE_LENGTH];
+ //Source Ip Mask Address Range
+ ULONG ulIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH];
+ };
+ struct
+ {
+ //Source Ip Address Range
+ ULONG ulIpv6Addr[MIBS_MAX_IP_RANGE_LENGTH * 4];
+ //Source Ip Mask Address Range
+ ULONG ulIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * 4];
+
+ };
+ struct
+ {
+ UCHAR ucIpv4Address[MIBS_MAX_IP_RANGE_LENGTH *
+ MIBS_IP_LENGTH_OF_ADDRESS];
+ UCHAR ucIpv4Mask[MIBS_MAX_IP_RANGE_LENGTH *
+ MIBS_IP_LENGTH_OF_ADDRESS];
+ };
+ struct
+ {
+ UCHAR ucIpv6Address[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES];
+ UCHAR ucIpv6Mask[MIBS_MAX_IP_RANGE_LENGTH * MIBS_IPV6_ADDRESS_SIZEINBYTES];
+ };
+}U_MIBS_IP_ADDRESS;
+
+
+typedef struct _S_MIBS_HOST_INFO
+{
+ ULONG64 GoodTransmits;
+ ULONG64 GoodReceives;
+ // this to keep track of the Tx and Rx MailBox Registers.
+ ULONG NumDesUsed;
+ ULONG CurrNumFreeDesc;
+ ULONG PrevNumFreeDesc;
+ // to keep track the no of byte recieved
+ ULONG PrevNumRcevBytes;
+ ULONG CurrNumRcevBytes;
+
+ /* QOS Related */
+ ULONG BEBucketSize;
+ ULONG rtPSBucketSize;
+ ULONG LastTxQueueIndex;
+ BOOLEAN TxOutofDescriptors;
+ BOOLEAN TimerActive;
+ UINT32 u32TotalDSD;
+ UINT32 aTxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
+ UINT32 aRxPktSizeHist[MIBS_MAX_HIST_ENTRIES];
+}S_MIBS_HOST_INFO;
+
+typedef struct _S_MIBS_CLASSIFIER_RULE
+{
+ ULONG ulSFID;
+ UCHAR ucReserved[2];
+ B_UINT16 uiClassifierRuleIndex;
+ BOOLEAN bUsed;
+ USHORT usVCID_Value;
+ // This field detemines the Classifier Priority
+ B_UINT8 u8ClassifierRulePriority;
+ U_MIBS_IP_ADDRESS stSrcIpAddress;
+ /*IP Source Address Length*/
+ UCHAR ucIPSourceAddressLength;
+
+ U_MIBS_IP_ADDRESS stDestIpAddress;
+ /* IP Destination Address Length */
+ UCHAR ucIPDestinationAddressLength;
+ UCHAR ucIPTypeOfServiceLength;//Type of service Length
+ UCHAR ucTosLow;//Tos Low
+ UCHAR ucTosHigh;//Tos High
+ UCHAR ucTosMask;//Tos Mask
+ UCHAR ucProtocolLength;//protocol Length
+ UCHAR ucProtocol[MIBS_MAX_PROTOCOL_LENGTH];//protocol Length
+ USHORT usSrcPortRangeLo[MIBS_MAX_PORT_RANGE];
+ USHORT usSrcPortRangeHi[MIBS_MAX_PORT_RANGE];
+ UCHAR ucSrcPortRangeLength;
+ USHORT usDestPortRangeLo[MIBS_MAX_PORT_RANGE];
+ USHORT usDestPortRangeHi[MIBS_MAX_PORT_RANGE];
+ UCHAR ucDestPortRangeLength;
+ BOOLEAN bProtocolValid;
+ BOOLEAN bTOSValid;
+ BOOLEAN bDestIpValid;
+ BOOLEAN bSrcIpValid;
+ UCHAR ucDirection;
+ BOOLEAN bIpv6Protocol;
+ UINT32 u32PHSRuleID;
+}S_MIBS_CLASSIFIER_RULE;
+
+
+typedef struct _S_MIBS_PHS_RULE
+{
+ ULONG ulSFID;
+ /// brief 8bit PHSI Of The Service Flow
+ B_UINT8 u8PHSI;
+ /// brief PHSF Of The Service Flow
+ B_UINT8 u8PHSFLength;
+ B_UINT8 u8PHSF[MIBS_MAX_PHS_LENGTHS];
+ /// brief PHSM Of The Service Flow
+ B_UINT8 u8PHSMLength;
+ B_UINT8 u8PHSM[MIBS_MAX_PHS_LENGTHS];
+ /// brief 8bit PHSS Of The Service Flow
+ B_UINT8 u8PHSS;
+ /// brief 8bit PHSV Of The Service Flow
+ B_UINT8 u8PHSV;
+ // Reserved bytes are 5, so that it is similar to S_PHS_RULE structure.
+ B_UINT8 reserved[5];
+
+ LONG PHSModifiedBytes;
+ ULONG PHSModifiedNumPackets;
+ ULONG PHSErrorNumPackets;
+}S_MIBS_PHS_RULE;
+
+typedef struct _S_MIBS_EXTSERVICEFLOW_PARAMETERS
+{
+ UINT32 wmanIfSfid;
+ UINT32 wmanIfCmnCpsSfState;
+ UINT32 wmanIfCmnCpsMaxSustainedRate;
+ UINT32 wmanIfCmnCpsMaxTrafficBurst;
+ UINT32 wmanIfCmnCpsMinReservedRate;
+ UINT32 wmanIfCmnCpsToleratedJitter;
+ UINT32 wmanIfCmnCpsMaxLatency;
+ UINT32 wmanIfCmnCpsFixedVsVariableSduInd;
+ UINT32 wmanIfCmnCpsSduSize;
+ UINT32 wmanIfCmnCpsSfSchedulingType;
+ UINT32 wmanIfCmnCpsArqEnable;
+ UINT32 wmanIfCmnCpsArqWindowSize;
+ UINT32 wmanIfCmnCpsArqBlockLifetime;
+ UINT32 wmanIfCmnCpsArqSyncLossTimeout;
+ UINT32 wmanIfCmnCpsArqDeliverInOrder;
+ UINT32 wmanIfCmnCpsArqRxPurgeTimeout;
+ UINT32 wmanIfCmnCpsArqBlockSize;
+ UINT32 wmanIfCmnCpsMinRsvdTolerableRate;
+ UINT32 wmanIfCmnCpsReqTxPolicy;
+ UINT32 wmanIfCmnSfCsSpecification;
+ UINT32 wmanIfCmnCpsTargetSaid;
+
+}S_MIBS_EXTSERVICEFLOW_PARAMETERS;
+
+
+typedef struct _S_MIBS_SERVICEFLOW_TABLE
+{
+ //classification extension Rule
+ ULONG ulSFID;
+ USHORT usVCID_Value;
+ UINT uiThreshold;
+ // This field determines the priority of the SF Queues
+ B_UINT8 u8TrafficPriority;
+
+ BOOLEAN bValid;
+ BOOLEAN bActive;
+ BOOLEAN bActivateRequestSent;
+ //BE or rtPS
+ B_UINT8 u8QueueType;
+ //maximum size of the bucket for the queue
+ UINT uiMaxBucketSize;
+ UINT uiCurrentQueueDepthOnTarget;
+ UINT uiCurrentBytesOnHost;
+ UINT uiCurrentPacketsOnHost;
+ UINT uiDroppedCountBytes;
+ UINT uiDroppedCountPackets;
+ UINT uiSentBytes;
+ UINT uiSentPackets;
+ UINT uiCurrentDrainRate;
+ UINT uiThisPeriodSentBytes;
+ LARGE_INTEGER liDrainCalculated;
+ UINT uiCurrentTokenCount;
+ LARGE_INTEGER liLastUpdateTokenAt;
+ UINT uiMaxAllowedRate;
+ UINT NumOfPacketsSent;
+ UCHAR ucDirection;
+ USHORT usCID;
+ S_MIBS_EXTSERVICEFLOW_PARAMETERS stMibsExtServiceFlowTable;
+ UINT uiCurrentRxRate;
+ UINT uiThisPeriodRxBytes;
+ UINT uiTotalRxBytes;
+ UINT uiTotalTxBytes;
+}S_MIBS_SERVICEFLOW_TABLE;
+
+typedef struct _S_MIBS_DROPPED_APP_CNTRL_MESSAGES
+{
+ ULONG cm_responses;
+ ULONG cm_control_newdsx_multiclassifier_resp;
+ ULONG link_control_resp;
+ ULONG status_rsp;
+ ULONG stats_pointer_resp;
+ ULONG idle_mode_status;
+ ULONG auth_ss_host_msg;
+ ULONG low_priority_message;
+
+}S_MIBS_DROPPED_APP_CNTRL_MESSAGES;
+
+typedef struct _S_MIBS_HOST_STATS_MIBS
+{
+ S_MIBS_HOST_INFO stHostInfo;
+ S_MIBS_CLASSIFIER_RULE astClassifierTable[MIBS_MAX_CLASSIFIERS];
+ S_MIBS_SERVICEFLOW_TABLE astSFtable[MIBS_MAX_SERVICEFLOWS];
+ S_MIBS_PHS_RULE astPhsRulesTable[MIBS_MAX_PHSRULES];
+ S_MIBS_DROPPED_APP_CNTRL_MESSAGES stDroppedAppCntrlMsgs;
+}S_MIBS_HOST_STATS_MIBS;
+#endif
+
+
diff --git a/drivers/staging/bcm/HostMibs.h b/drivers/staging/bcm/HostMibs.h
new file mode 100644
index 00000000000..28a57831137
--- /dev/null
+++ b/drivers/staging/bcm/HostMibs.h
@@ -0,0 +1,7 @@
+#ifndef _HOST_MIBS_H
+#define _HOST_MIBS_H
+
+INT ProcessGetHostMibs(PMINI_ADAPTER Adapter,
+ PVOID ioBuffer,
+ ULONG inputBufferLength);
+#endif
diff --git a/drivers/staging/bcm/IPv6Protocol.c b/drivers/staging/bcm/IPv6Protocol.c
new file mode 100644
index 00000000000..cb4ca9a44c8
--- /dev/null
+++ b/drivers/staging/bcm/IPv6Protocol.c
@@ -0,0 +1,400 @@
+#include "headers.h"
+
+UCHAR * GetNextIPV6ChainedHeader(UCHAR **ppucPayload,UCHAR *pucNextHeader,BOOLEAN *bParseDone,USHORT *pusPayloadLength)
+{
+ UCHAR *pucRetHeaderPtr = NULL;
+ UCHAR *pucPayloadPtr = NULL;
+ USHORT usNextHeaderOffset = 0 ;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+ if((NULL == ppucPayload) || (*pusPayloadLength == 0) || (*bParseDone))
+ {
+ *bParseDone = TRUE;
+ return NULL;
+
+ }
+
+ pucRetHeaderPtr = *ppucPayload;
+ pucPayloadPtr = *ppucPayload;
+
+ if(!pucRetHeaderPtr || !pucPayloadPtr)
+ {
+ *bParseDone = TRUE;
+ return NULL;
+ }
+
+ //Get the Nextt Header Type
+ *bParseDone = FALSE;
+
+
+
+ switch(*pucNextHeader)
+ {
+ case IPV6HDR_TYPE_HOPBYHOP:
+ {
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 HopByHop Header");
+ usNextHeaderOffset+=sizeof(IPV6HopByHopOptionsHeader);
+ }
+ break;
+
+ case IPV6HDR_TYPE_ROUTING:
+ {
+ IPV6RoutingHeader *pstIpv6RoutingHeader;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Routing Header");
+ pstIpv6RoutingHeader = (IPV6RoutingHeader *)pucPayloadPtr;
+ usNextHeaderOffset += sizeof(IPV6RoutingHeader);
+ usNextHeaderOffset += pstIpv6RoutingHeader->ucNumAddresses * IPV6_ADDRESS_SIZEINBYTES;
+
+ }
+ break;
+ case IPV6HDR_TYPE_FRAGMENTATION:
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Fragmentation Header");
+ usNextHeaderOffset+= sizeof(IPV6FragmentHeader);
+
+ }
+ break;
+ case IPV6HDR_TYPE_DESTOPTS:
+ {
+ IPV6DestOptionsHeader *pstIpv6DestOptsHdr = (IPV6DestOptionsHeader *)pucPayloadPtr;
+ int nTotalOptions = pstIpv6DestOptsHdr->ucHdrExtLen;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 DestOpts Header Header");
+ usNextHeaderOffset+= sizeof(IPV6DestOptionsHeader);
+ usNextHeaderOffset+= nTotalOptions * IPV6_DESTOPTS_HDR_OPTIONSIZE ;
+
+ }
+ break;
+ case IPV6HDR_TYPE_AUTHENTICATION:
+ {
+ IPV6AuthenticationHeader *pstIpv6AuthHdr = (IPV6AuthenticationHeader *)pucPayloadPtr;
+ int nHdrLen = pstIpv6AuthHdr->ucLength;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Authentication Header");
+ usNextHeaderOffset+= nHdrLen * 4;
+ }
+ break;
+ case IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD:
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Encrypted Security Payload Header");
+ *bParseDone = TRUE;
+
+ }
+ break;
+ case IPV6_ICMP_HDR_TYPE:
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " ICMP Header");
+ *bParseDone = TRUE;
+ }
+ break;
+ case TCP_HEADER_TYPE:
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nTCP Header");
+ *bParseDone = TRUE;
+ }
+ break;
+ case UDP_HEADER_TYPE:
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nUDP Header");
+ *bParseDone = TRUE;
+ }
+ break;
+ default :
+ {
+ *bParseDone = TRUE;
+
+ }
+ break;
+
+
+ }
+
+ if(*bParseDone == FALSE)
+ {
+ if(*pusPayloadLength <= usNextHeaderOffset)
+ {
+ *bParseDone = TRUE;
+ }
+ else
+ {
+ *pucNextHeader = *pucPayloadPtr;
+ pucPayloadPtr+=usNextHeaderOffset;
+ (*pusPayloadLength)-=usNextHeaderOffset;
+ }
+
+ }
+
+
+
+ *ppucPayload = pucPayloadPtr;
+ return pucRetHeaderPtr;
+}
+
+
+UCHAR GetIpv6ProtocolPorts(UCHAR *pucPayload,USHORT *pusSrcPort,USHORT *pusDestPort,USHORT usPayloadLength,UCHAR ucNextHeader)
+{
+ UCHAR *pIpv6HdrScanContext = pucPayload;
+ BOOLEAN bDone = FALSE;
+ UCHAR ucHeaderType =0;
+ UCHAR *pucNextHeader = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+ if( !pucPayload || (usPayloadLength == 0))
+ {
+ return 0;
+ }
+
+ *pusSrcPort = *pusDestPort = 0;
+ ucHeaderType = ucNextHeader;
+ while(!bDone)
+ {
+ pucNextHeader = GetNextIPV6ChainedHeader(&pIpv6HdrScanContext,&ucHeaderType,&bDone,&usPayloadLength);
+ if(bDone)
+ {
+ if((ucHeaderType==TCP_HEADER_TYPE) || (ucHeaderType == UDP_HEADER_TYPE))
+ {
+ *pusSrcPort=*((PUSHORT)(pucNextHeader));
+ *pusDestPort=*((PUSHORT)(pucNextHeader+2));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, " \nProtocol Ports - Src Port :0x%x Dest Port : 0x%x",ntohs(*pusSrcPort),ntohs(*pusDestPort));
+ }
+ break;
+
+ }
+ }
+ return ucHeaderType;
+}
+
+
+
+USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */
+ PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/
+ S_CLASSIFIER_RULE *pstClassifierRule )
+{
+ USHORT ushDestPort = 0;
+ USHORT ushSrcPort = 0;
+ UCHAR ucNextProtocolAboveIP =0;
+ IPV6Header *pstIpv6Header = NULL;
+ BOOLEAN bClassificationSucceed = FALSE;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "IpVersion6 ==========>\n");
+
+ pstIpv6Header = (IPV6Header *)pcIpHeader;
+
+ DumpIpv6Header(pstIpv6Header);
+
+ //Try to get the next higher layer protocol and the Ports Nos if TCP or UDP
+ ucNextProtocolAboveIP = GetIpv6ProtocolPorts((UCHAR *)(pcIpHeader + sizeof(IPV6Header)),
+ &ushSrcPort,
+ &ushDestPort,
+ pstIpv6Header->usPayloadLength,
+ pstIpv6Header->ucNextHeader);
+
+ do
+ {
+ if(0 == pstClassifierRule->ucDirection)
+ {
+ //cannot be processed for classification.
+ // it is a down link connection
+ break;
+ }
+
+ if(!pstClassifierRule->bIpv6Protocol)
+ {
+ //We are looking for Ipv6 Classifiers . Lets ignore this classifier and try the next one.
+ break;
+ }
+
+ bClassificationSucceed=MatchSrcIpv6Address(pstClassifierRule,pstIpv6Header);
+ if(!bClassificationSucceed)
+ break;
+
+ bClassificationSucceed=MatchDestIpv6Address(pstClassifierRule,pstIpv6Header);
+ if(!bClassificationSucceed)
+ break;
+
+ //Match the protocol type.For IPv6 the next protocol at end of Chain of IPv6 prot headers
+ bClassificationSucceed=MatchProtocol(pstClassifierRule,ucNextProtocolAboveIP);
+ if(!bClassificationSucceed)
+ break;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Protocol Matched");
+
+ if((ucNextProtocolAboveIP == TCP_HEADER_TYPE) || (ucNextProtocolAboveIP == UDP_HEADER_TYPE))
+ {
+ //Match Src Port
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Source Port:%x\n",ntohs(ushSrcPort));
+ bClassificationSucceed=MatchSrcPort(pstClassifierRule,ntohs(ushSrcPort));
+ if(!bClassificationSucceed)
+ break;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Src Port Matched");
+
+ //Match Dest Port
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Destination Port:%x\n",ntohs(ushDestPort));
+ bClassificationSucceed=MatchDestPort(pstClassifierRule,ntohs(ushDestPort));
+ if(!bClassificationSucceed)
+ break;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\nIPv6 Dest Port Matched");
+ }
+ }while(0);
+
+ if(TRUE==bClassificationSucceed)
+ {
+ INT iMatchedSFQueueIndex = 0;
+ iMatchedSFQueueIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID);
+ if(iMatchedSFQueueIndex >= NO_OF_QUEUES)
+ {
+ bClassificationSucceed = FALSE;
+ }
+ else
+ {
+ if(FALSE == Adapter->PackInfo[iMatchedSFQueueIndex].bActive)
+ {
+ bClassificationSucceed = FALSE;
+ }
+ }
+ }
+
+ return bClassificationSucceed;
+}
+
+
+BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header)
+{
+ UINT uiLoopIndex=0;
+ UINT uiIpv6AddIndex=0;
+ UINT uiIpv6AddrNoLongWords = 4;
+ ULONG aulSrcIP[4];
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ /*
+ //This is the no. of Src Addresses ie Range of IP Addresses contained
+ //in the classifier rule for which we need to match
+ */
+ UINT uiCountIPSrcAddresses = (UINT)pstClassifierRule->ucIPSourceAddressLength;
+
+
+ if(0 == uiCountIPSrcAddresses)
+ return TRUE;
+
+
+ //First Convert the Ip Address in the packet to Host Endian order
+ for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
+ {
+ aulSrcIP[uiIpv6AddIndex]=ntohl(pstIpv6Header->ulSrcIpAddress[uiIpv6AddIndex]);
+ }
+
+ for(uiLoopIndex=0;uiLoopIndex<uiCountIPSrcAddresses;uiLoopIndex+=uiIpv6AddrNoLongWords)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Address In Recieved Packet : \n ");
+ DumpIpv6Address(aulSrcIP);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Mask In Classifier Rule: \n");
+ DumpIpv6Address(&pstClassifierRule->stSrcIpAddress.ulIpv6Mask[uiLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Src Ipv6 Address In Classifier Rule : \n");
+ DumpIpv6Address(&pstClassifierRule->stSrcIpAddress.ulIpv6Addr[uiLoopIndex]);
+
+ for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
+ {
+ if((pstClassifierRule->stSrcIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulSrcIP[uiIpv6AddIndex])
+ != pstClassifierRule->stSrcIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex])
+ {
+ //Match failed for current Ipv6 Address.Try next Ipv6 Address
+ break;
+ }
+
+ if(uiIpv6AddIndex == uiIpv6AddrNoLongWords-1)
+ {
+ //Match Found
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Ipv6 Src Ip Address Matched\n");
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header)
+{
+ UINT uiLoopIndex=0;
+ UINT uiIpv6AddIndex=0;
+ UINT uiIpv6AddrNoLongWords = 4;
+ ULONG aulDestIP[4];
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ /*
+ //This is the no. of Destination Addresses ie Range of IP Addresses contained
+ //in the classifier rule for which we need to match
+ */
+ UINT uiCountIPDestinationAddresses = (UINT)pstClassifierRule->ucIPDestinationAddressLength;
+
+
+ if(0 == uiCountIPDestinationAddresses)
+ return TRUE;
+
+
+ //First Convert the Ip Address in the packet to Host Endian order
+ for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
+ {
+ aulDestIP[uiIpv6AddIndex]=ntohl(pstIpv6Header->ulDestIpAddress[uiIpv6AddIndex]);
+ }
+
+ for(uiLoopIndex=0;uiLoopIndex<uiCountIPDestinationAddresses;uiLoopIndex+=uiIpv6AddrNoLongWords)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Address In Recieved Packet : \n ");
+ DumpIpv6Address(aulDestIP);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Mask In Classifier Rule: \n");
+ DumpIpv6Address(&pstClassifierRule->stDestIpAddress.ulIpv6Mask[uiLoopIndex]);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "\n Destination Ipv6 Address In Classifier Rule : \n");
+ DumpIpv6Address(&pstClassifierRule->stDestIpAddress.ulIpv6Addr[uiLoopIndex]);
+
+ for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
+ {
+ if((pstClassifierRule->stDestIpAddress.ulIpv6Mask[uiLoopIndex+uiIpv6AddIndex] & aulDestIP[uiIpv6AddIndex])
+ != pstClassifierRule->stDestIpAddress.ulIpv6Addr[uiLoopIndex+uiIpv6AddIndex])
+ {
+ //Match failed for current Ipv6 Address.Try next Ipv6 Address
+ break;
+ }
+
+ if(uiIpv6AddIndex == uiIpv6AddrNoLongWords-1)
+ {
+ //Match Found
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Ipv6 Destination Ip Address Matched\n");
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+
+}
+
+VOID DumpIpv6Address(ULONG *puIpv6Address)
+{
+ UINT uiIpv6AddrNoLongWords = 4;
+ UINT uiIpv6AddIndex=0;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ for(uiIpv6AddIndex=0;uiIpv6AddIndex<uiIpv6AddrNoLongWords;uiIpv6AddIndex++)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, ":%lx",puIpv6Address[uiIpv6AddIndex]);
+ }
+
+}
+
+VOID DumpIpv6Header(IPV6Header *pstIpv6Header)
+{
+ UCHAR ucVersion;
+ UCHAR ucPrio ;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "----Ipv6 Header---");
+ ucVersion = pstIpv6Header->ucVersionPrio & 0xf0;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Version : %x \n",ucVersion);
+ ucPrio = pstIpv6Header->ucVersionPrio & 0x0f;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Priority : %x \n",ucPrio);
+ //BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Flow Label : %x \n",(pstIpv6Header->ucVersionPrio &0xf0);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Payload Length : %x \n",ntohs(pstIpv6Header->usPayloadLength));
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Next Header : %x \n",pstIpv6Header->ucNextHeader);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Hop Limit : %x \n",pstIpv6Header->ucHopLimit);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Src Address :\n");
+ DumpIpv6Address(pstIpv6Header->ulSrcIpAddress);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "Dest Address :\n");
+ DumpIpv6Address(pstIpv6Header->ulDestIpAddress);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, IPV6_DBG, DBG_LVL_ALL, "----Ipv6 Header End---");
+
+
+}
diff --git a/drivers/staging/bcm/IPv6ProtocolHdr.h b/drivers/staging/bcm/IPv6ProtocolHdr.h
new file mode 100644
index 00000000000..b93f7902e28
--- /dev/null
+++ b/drivers/staging/bcm/IPv6ProtocolHdr.h
@@ -0,0 +1,119 @@
+#ifndef _IPV6_PROTOCOL_DEFINES_
+#define _IPV6_PROTOCOL_DEFINES_
+
+
+#define IPV6HDR_TYPE_HOPBYHOP 0x0
+#define IPV6HDR_TYPE_ROUTING 0x2B
+#define IPV6HDR_TYPE_FRAGMENTATION 0x2C
+#define IPV6HDR_TYPE_DESTOPTS 0x3c
+#define IPV6HDR_TYPE_AUTHENTICATION 0x33
+#define IPV6HDR_TYPE_ENCRYPTEDSECURITYPAYLOAD 0x34
+#define MASK_IPV6_CS_SPEC 0x2
+
+
+#define TCP_HEADER_TYPE 0x6
+#define UDP_HEADER_TYPE 0x11
+#define IPV6_ICMP_HDR_TYPE 0x2
+#define IPV6_FLOWLABEL_BITOFFSET 9
+
+#define IPV6_MAX_CHAINEDHDR_BUFFBYTES 0x64
+/*
+// Size of Dest Options field of Destinations Options Header
+// in bytes.
+*/
+#define IPV6_DESTOPTS_HDR_OPTIONSIZE 0x8
+
+//typedef unsigned char UCHAR;
+//typedef unsigned short USHORT;
+//typedef unsigned long int ULONG;
+
+typedef struct IPV6HeaderFormatTag
+{
+ UCHAR ucVersionPrio;
+ UCHAR aucFlowLabel[3];
+ USHORT usPayloadLength;
+ UCHAR ucNextHeader;
+ UCHAR ucHopLimit;
+ ULONG ulSrcIpAddress[4];
+ ULONG ulDestIpAddress[4];
+}IPV6Header;
+
+typedef struct IPV6RoutingHeaderFormatTag
+{
+ UCHAR ucNextHeader;
+ UCHAR ucRoutingType;
+ UCHAR ucNumAddresses;
+ UCHAR ucNextAddress;
+ ULONG ulReserved;
+ //UCHAR aucAddressList[0];
+
+}IPV6RoutingHeader;
+
+typedef struct IPV6FragmentHeaderFormatTag
+{
+ UCHAR ucNextHeader;
+ UCHAR ucReserved;
+ USHORT usFragmentOffset;
+ ULONG ulIdentification;
+}IPV6FragmentHeader;
+
+typedef struct IPV6DestOptionsHeaderFormatTag
+{
+ UCHAR ucNextHeader;
+ UCHAR ucHdrExtLen;
+ UCHAR ucDestOptions[6];
+ //UCHAR udExtDestOptions[0];
+}IPV6DestOptionsHeader;
+
+typedef struct IPV6HopByHopOptionsHeaderFormatTag
+{
+ UCHAR ucNextHeader;
+ UCHAR ucMisc[3];
+ ULONG ulJumboPayloadLen;
+}IPV6HopByHopOptionsHeader;
+
+typedef struct IPV6AuthenticationHeaderFormatTag
+{
+ UCHAR ucNextHeader;
+ UCHAR ucLength;
+ USHORT usReserved;
+ ULONG ulSecurityParametersIndex;
+ //UCHAR ucAuthenticationData[0];
+
+}IPV6AuthenticationHeader;
+
+typedef struct IPV6IcmpHeaderFormatTag
+{
+ UCHAR ucType;
+ UCHAR ucCode;
+ USHORT usChecksum;
+ //UCHAR ucIcmpMsg[0];
+
+}IPV6IcmpHeader;
+
+typedef enum _E_IPADDR_CONTEXT
+{
+ eSrcIpAddress,
+ eDestIpAddress
+
+}E_IPADDR_CONTEXT;
+
+
+
+//Function Prototypes
+BOOLEAN MatchSrcIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header);
+BOOLEAN MatchDestIpv6Address(S_CLASSIFIER_RULE *pstClassifierRule,IPV6Header *pstIpv6Header);
+
+USHORT IpVersion6(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */
+ PVOID pcIpHeader, /**<Pointer to the IP Hdr of the packet*/
+ S_CLASSIFIER_RULE *pstClassifierRule );
+
+VOID DumpIpv6Address(ULONG *puIpv6Address);
+VOID DumpIpv6Header(IPV6Header *pstIpv6Header);
+
+extern BOOLEAN MatchSrcPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
+extern BOOLEAN MatchDestPort(S_CLASSIFIER_RULE *pstClassifierRule,USHORT ushSrcPort);
+extern BOOLEAN MatchProtocol(S_CLASSIFIER_RULE *pstClassifierRule,UCHAR ucProtocol);
+
+
+#endif
diff --git a/drivers/staging/bcm/InterfaceAdapter.h b/drivers/staging/bcm/InterfaceAdapter.h
new file mode 100644
index 00000000000..6397c20f4f6
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceAdapter.h
@@ -0,0 +1,97 @@
+#ifndef _INTERFACE_ADAPTER_H
+#define _INTERFACE_ADAPTER_H
+
+typedef struct _BULK_ENDP_IN
+{
+ PCHAR bulk_in_buffer;
+ size_t bulk_in_size;
+ UCHAR bulk_in_endpointAddr;
+ UINT bulk_in_pipe;
+}BULK_ENDP_IN, *PBULK_ENDP_IN;
+
+
+typedef struct _BULK_ENDP_OUT
+{
+ UCHAR bulk_out_buffer;
+ size_t bulk_out_size;
+ UCHAR bulk_out_endpointAddr;
+ UINT bulk_out_pipe;
+ //this is used when int out endpoint is used as bulk out end point
+ UCHAR int_out_interval;
+}BULK_ENDP_OUT, *PBULK_ENDP_OUT;
+
+typedef struct _INTR_ENDP_IN
+{
+ PCHAR int_in_buffer;
+ size_t int_in_size;
+ UCHAR int_in_endpointAddr;
+ UCHAR int_in_interval;
+ UINT int_in_pipe;
+}INTR_ENDP_IN, *PINTR_ENDP_IN;
+
+typedef struct _INTR_ENDP_OUT
+{
+ PCHAR int_out_buffer;
+ size_t int_out_size;
+ UCHAR int_out_endpointAddr;
+ UCHAR int_out_interval;
+ UINT int_out_pipe;
+}INTR_ENDP_OUT, *PINTR_ENDP_OUT;
+
+
+typedef struct _USB_TCB
+{
+ struct urb *urb;
+ PVOID psIntfAdapter;
+ BOOLEAN bUsed;
+}USB_TCB, *PUSB_TCB;
+
+
+typedef struct _USB_RCB
+{
+ struct urb *urb;
+ PVOID psIntfAdapter;
+ BOOLEAN bUsed;
+}USB_RCB, *PUSB_RCB;
+
+/*
+//This is the interface specific Sub-Adapter
+//Structure.
+*/
+typedef struct _S_INTERFACE_ADAPTER
+{
+ struct usb_device * udev;
+ struct usb_interface * interface;
+
+ /* Bulk endpoint in info */
+ BULK_ENDP_IN sBulkIn;
+ /* Bulk endpoint out info */
+ BULK_ENDP_OUT sBulkOut;
+ /* Interrupt endpoint in info */
+ INTR_ENDP_IN sIntrIn;
+ /* Interrupt endpoint out info */
+ INTR_ENDP_OUT sIntrOut;
+
+
+
+ ULONG ulInterruptData[2];
+
+ struct urb *psInterruptUrb;
+
+ USB_TCB asUsbTcb[MAXIMUM_USB_TCB];
+ USB_RCB asUsbRcb[MAXIMUM_USB_RCB];
+ atomic_t uNumTcbUsed;
+ atomic_t uCurrTcb;
+ atomic_t uNumRcbUsed;
+ atomic_t uCurrRcb;
+
+ PMINI_ADAPTER psAdapter;
+ BOOLEAN bFlashBoot;
+ BOOLEAN bHighSpeedDevice ;
+
+ BOOLEAN bSuspended;
+ BOOLEAN bPreparingForBusSuspend;
+ struct work_struct usbSuspendWork;
+}S_INTERFACE_ADAPTER,*PS_INTERFACE_ADAPTER;
+
+#endif
diff --git a/drivers/staging/bcm/InterfaceDld.c b/drivers/staging/bcm/InterfaceDld.c
new file mode 100644
index 00000000000..f9761dbd5e4
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceDld.c
@@ -0,0 +1,509 @@
+#include "headers.h"
+
+#ifndef BCM_SHM_INTERFACE
+
+int InterfaceFileDownload( PVOID arg,
+ struct file *flp,
+ unsigned int on_chip_loc)
+{
+ char *buff=NULL;
+ // unsigned int reg=0;
+ mm_segment_t oldfs={0};
+ int errno=0, len=0 /*,is_config_file = 0*/;
+ loff_t pos=0;
+ PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg;
+ //PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;
+
+ buff=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
+ if(!buff)
+ {
+ return -ENOMEM;
+ }
+ while(1)
+ {
+ oldfs=get_fs(); set_fs(get_ds());
+ len=vfs_read(flp, buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos);
+ set_fs(oldfs);
+ if(len<=0)
+ {
+ if(len<0)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0");
+ errno=len;
+ }
+ else
+ {
+ errno = 0;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!");
+ }
+ break;
+ }
+ //BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, buff, MAX_TRANSFER_CTRL_BYTE_USB);
+ errno = InterfaceWRM(psIntfAdapter, on_chip_loc, buff, len) ;
+ if(errno)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "WRM Failed! status: %d", errno);
+ break;
+
+ }
+ on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB;
+ }/* End of for(;;)*/
+
+ bcm_kfree(buff);
+ return errno;
+}
+
+int InterfaceFileReadbackFromChip( PVOID arg,
+ struct file *flp,
+ unsigned int on_chip_loc)
+{
+ char *buff=NULL, *buff_readback=NULL;
+ unsigned int reg=0;
+ mm_segment_t oldfs={0};
+ int errno=0, len=0, is_config_file = 0;
+ loff_t pos=0;
+ static int fw_down = 0;
+ INT Status = STATUS_SUCCESS;
+ PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg;
+
+ buff=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_DMA);
+ buff_readback=(PCHAR)kmalloc(MAX_TRANSFER_CTRL_BYTE_USB , GFP_DMA);
+ if(!buff || !buff_readback)
+ {
+ bcm_kfree(buff);
+ bcm_kfree(buff_readback);
+
+ return -ENOMEM;
+ }
+
+ is_config_file = (on_chip_loc == CONFIG_BEGIN_ADDR)? 1:0;
+
+ memset(buff_readback, 0, MAX_TRANSFER_CTRL_BYTE_USB);
+ memset(buff, 0, MAX_TRANSFER_CTRL_BYTE_USB);
+ while(1)
+ {
+ oldfs=get_fs(); set_fs(get_ds());
+ len=vfs_read(flp, buff, MAX_TRANSFER_CTRL_BYTE_USB, &pos);
+ set_fs(oldfs);
+ fw_down++;
+ if(len<=0)
+ {
+ if(len<0)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len < 0");
+ errno=len;
+ }
+ else
+ {
+ errno = 0;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got end of file!");
+ }
+ break;
+ }
+
+
+ Status = InterfaceRDM(psIntfAdapter, on_chip_loc, buff_readback, len);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "RDM of len %d Failed! %d", len, reg);
+ goto exit;
+ }
+ reg++;
+ if((len-sizeof(unsigned int))<4)
+ {
+ if(memcmp(buff_readback, buff, len))
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down);
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL,"Length is: %d",len);
+ Status = -EIO;
+ goto exit;
+ }
+ }
+ else
+ {
+ len-=4;
+ while(len)
+ {
+ if(*(unsigned int*)&buff_readback[len] != *(unsigned int *)&buff[len])
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper %d", fw_down);
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&buff_readback[len]);
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len);
+ Status = -EIO;
+ goto exit;
+ }
+ len-=4;
+ }
+ }
+ on_chip_loc+=MAX_TRANSFER_CTRL_BYTE_USB;
+ }/* End of while(1)*/
+exit:
+ bcm_kfree(buff);
+ bcm_kfree(buff_readback);
+ return Status;
+}
+
+static int bcm_download_config_file(PMINI_ADAPTER Adapter,
+ FIRMWARE_INFO *psFwInfo)
+{
+ int retval = STATUS_SUCCESS;
+ B_UINT32 value = 0;
+
+ if(Adapter->pstargetparams == NULL)
+ {
+ if((Adapter->pstargetparams =
+ kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL)
+ {
+ return -ENOMEM;
+ }
+ }
+ if(psFwInfo->u32FirmwareLength != sizeof(STARGETPARAMS))
+ {
+ return -EIO;
+ }
+ retval = copy_from_user(Adapter->pstargetparams,
+ psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength);
+ if(retval)
+ {
+ bcm_kfree (Adapter->pstargetparams);
+ Adapter->pstargetparams = NULL;
+ return retval;
+ }
+ /* Parse the structure and then Download the Firmware */
+ beceem_parse_target_struct(Adapter);
+
+ //Initializing the NVM.
+ BcmInitNVM(Adapter);
+
+ retval = InitLedSettings (Adapter);
+
+ if(retval)
+ {
+ BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "INIT LED Failed\n");
+ return retval;
+ }
+
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ Adapter->LEDInfo.bLedInitDone = FALSE;
+ Adapter->DriverState = DRIVER_INIT;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ Adapter->DriverState = FW_DOWNLOAD;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+
+ /* Initialize the DDR Controller */
+ retval = ddr_init(Adapter);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT (Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Init Failed\n");
+ return retval;
+ }
+
+ value = 0;
+ wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
+ wrmalt(Adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
+
+ if(Adapter->eNVMType == NVM_FLASH)
+ {
+ retval = PropagateCalParamsFromFlashToMemory(Adapter);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"propagaion of cal param failed with status :%d", retval);
+ return retval;
+ }
+ }
+
+
+ retval =buffDnldVerify(Adapter,(PUCHAR)Adapter->pstargetparams,sizeof(STARGETPARAMS),CONFIG_BEGIN_ADDR);
+
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "configuration file not downloaded properly");
+ }
+ else
+ Adapter->bCfgDownloaded = TRUE;
+
+
+ return retval;
+}
+#if 0
+static int bcm_download_buffer(PMINI_ADAPTER Adapter,
+ unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
+ unsigned long u32StartingAddress)
+{
+ char *buff=NULL;
+ unsigned int len = 0;
+ int retval = STATUS_SUCCESS;
+ buff = kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
+
+ len = u32FirmwareLength;
+
+ while(u32FirmwareLength)
+ {
+ len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
+ if(STATUS_SUCCESS != (retval = copy_from_user(buff,
+ (unsigned char *)mappedbuffer, len)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copy_from_user failed\n");
+ break;
+ }
+ retval = wrm (Adapter, u32StartingAddress, buff, len);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed\n");
+ break;
+ }
+ u32StartingAddress += len;
+ u32FirmwareLength -= len;
+ mappedbuffer +=len;
+ }
+ bcm_kfree(buff);
+ return retval;
+}
+#endif
+static int bcm_compare_buff_contents(unsigned char *readbackbuff,
+ unsigned char *buff,unsigned int len)
+{
+ int retval = STATUS_SUCCESS;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ if((len-sizeof(unsigned int))<4)
+ {
+ if(memcmp(readbackbuff , buff, len))
+ {
+ retval=-EINVAL;
+ }
+ }
+ else
+ {
+ len-=4;
+ while(len)
+ {
+ if(*(unsigned int*)&readbackbuff[len] !=
+ *(unsigned int *)&buff[len])
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Firmware Download is not proper");
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Val from Binary %x, Val From Read Back %x ", *(unsigned int *)&buff[len], *(unsigned int*)&readbackbuff[len]);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "len =%x!!!", len);
+ retval=-EINVAL;
+ break;
+ }
+ len-=4;
+ }
+ }
+ return retval;
+}
+#if 0
+static int bcm_buffer_readback(PMINI_ADAPTER Adapter,
+ unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
+ unsigned long u32StartingAddress)
+{
+ unsigned char *buff = NULL;
+ unsigned char *readbackbuff = NULL;
+ unsigned int len = u32FirmwareLength;
+ int retval = STATUS_SUCCESS;
+
+ buff=(unsigned char *)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB, GFP_KERNEL);
+ if(NULL == buff)
+ return -ENOMEM;
+ readbackbuff = (unsigned char *)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB,
+ GFP_KERNEL);
+ if(NULL == readbackbuff)
+ {
+ bcm_kfree(buff);
+ return -ENOMEM;
+ }
+ while (u32FirmwareLength && !retval)
+ {
+ len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
+
+ /* read from the appl buff and then read from the target, compare */
+ if(STATUS_SUCCESS != (retval = copy_from_user(buff,
+ (unsigned char *)mappedbuffer, len)))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copy_from_user failed\n");
+ break;
+ }
+ retval = rdm (Adapter, u32StartingAddress, readbackbuff, len);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed\n");
+ break;
+ }
+
+ if (STATUS_SUCCESS !=
+ (retval = bcm_compare_buff_contents (readbackbuff, buff, len)))
+ {
+ break;
+ }
+ u32StartingAddress += len;
+ u32FirmwareLength -= len;
+ mappedbuffer +=len;
+ }/* end of while (u32FirmwareLength && !retval) */
+ bcm_kfree(buff);
+ bcm_kfree(readbackbuff);
+ return retval;
+}
+#endif
+int bcm_ioctl_fw_download(PMINI_ADAPTER Adapter, FIRMWARE_INFO *psFwInfo)
+{
+ int retval = STATUS_SUCCESS;
+ PUCHAR buff = NULL;
+
+ /* Config File is needed for the Driver to download the Config file and
+ Firmware. Check for the Config file to be first to be sent from the
+ Application
+ */
+ atomic_set (&Adapter->uiMBupdate, FALSE);
+ if(!Adapter->bCfgDownloaded &&
+ psFwInfo->u32StartingAddress != CONFIG_BEGIN_ADDR)
+ {
+ /*Can't Download Firmware.*/
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Download the config File first\n");
+ return -EINVAL;
+ }
+
+ /* If Config File, Finish the DDR Settings and then Download CFG File */
+ if(psFwInfo->u32StartingAddress == CONFIG_BEGIN_ADDR)
+ {
+ retval = bcm_download_config_file (Adapter, psFwInfo);
+ }
+ else
+ {
+
+ buff = (PUCHAR)kzalloc(psFwInfo->u32FirmwareLength,GFP_KERNEL);
+ if(buff==NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Failed in allocation memory");
+ return -ENOMEM;
+ }
+ retval = copy_from_user(buff,(PUCHAR)psFwInfo->pvMappedFirmwareAddress, psFwInfo->u32FirmwareLength);
+ if(retval != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "copying buffer from user space failed");
+ goto error ;
+ }
+
+ #if 0
+ retval = bcm_download_buffer(Adapter,
+ (unsigned char *)psFwInfo->pvMappedFirmwareAddress,
+ psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress);
+ if(retval != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "User space buffer download fails....");
+ }
+ retval = bcm_buffer_readback (Adapter,
+ (unsigned char *)psFwInfo->pvMappedFirmwareAddress,
+ psFwInfo->u32FirmwareLength, psFwInfo->u32StartingAddress);
+
+ if(retval != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "read back verifier failed ....");
+ }
+ #endif
+ retval = buffDnldVerify(Adapter,
+ buff,
+ psFwInfo->u32FirmwareLength,
+ psFwInfo->u32StartingAddress);
+ if(retval != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"f/w download failed status :%d", retval);
+ goto error;
+ }
+ }
+error:
+ bcm_kfree(buff);
+ return retval;
+}
+
+static INT buffDnld(PMINI_ADAPTER Adapter, PUCHAR mappedbuffer, UINT u32FirmwareLength,
+ ULONG u32StartingAddress)
+{
+
+ unsigned int len = 0;
+ int retval = STATUS_SUCCESS;
+ len = u32FirmwareLength;
+
+ while(u32FirmwareLength)
+ {
+ len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
+ retval = wrm (Adapter, u32StartingAddress, mappedbuffer, len);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "wrm failed with status :%d", retval);
+ break;
+ }
+ u32StartingAddress += len;
+ u32FirmwareLength -= len;
+ mappedbuffer +=len;
+ }
+ return retval;
+
+}
+
+static INT buffRdbkVerify(PMINI_ADAPTER Adapter,
+ PUCHAR mappedbuffer, UINT u32FirmwareLength,
+ ULONG u32StartingAddress)
+{
+ PUCHAR readbackbuff = NULL;
+ UINT len = u32FirmwareLength;
+ INT retval = STATUS_SUCCESS;
+
+ readbackbuff = (PUCHAR)kzalloc(MAX_TRANSFER_CTRL_BYTE_USB,GFP_KERNEL);
+ if(NULL == readbackbuff)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "MEMORY ALLOCATION FAILED");
+ return -ENOMEM;
+ }
+ while (u32FirmwareLength && !retval)
+ {
+
+ len = MIN_VAL (u32FirmwareLength, MAX_TRANSFER_CTRL_BYTE_USB);
+
+ retval = rdm (Adapter, u32StartingAddress, readbackbuff, len);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "rdm failed with status %d" ,retval);
+ break;
+ }
+
+ if (STATUS_SUCCESS != (retval = bcm_compare_buff_contents (readbackbuff, mappedbuffer, len)))
+ {
+ break;
+ }
+ u32StartingAddress += len;
+ u32FirmwareLength -= len;
+ mappedbuffer +=len;
+ }/* end of while (u32FirmwareLength && !retval) */
+ bcm_kfree(readbackbuff);
+ return retval;
+}
+
+INT buffDnldVerify(PMINI_ADAPTER Adapter, unsigned char *mappedbuffer, unsigned int u32FirmwareLength,
+ unsigned long u32StartingAddress)
+{
+ INT status = STATUS_SUCCESS;
+
+ status = buffDnld(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress);
+ if(status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer download failed");
+ goto error;
+ }
+
+ status= buffRdbkVerify(Adapter,mappedbuffer,u32FirmwareLength,u32StartingAddress);
+ if(status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Buffer readback verifier failed");
+ goto error;
+ }
+error:
+ return status;
+}
+
+#endif
+
diff --git a/drivers/staging/bcm/InterfaceIdleMode.c b/drivers/staging/bcm/InterfaceIdleMode.c
new file mode 100644
index 00000000000..d99fc7c31a1
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceIdleMode.c
@@ -0,0 +1,318 @@
+#include "headers.h"
+
+/*
+Function: InterfaceIdleModeWakeup
+
+Description: This is the hardware specific Function for waking up HW device from Idle mode.
+ A software abort pattern is written to the device to wake it and necessary power state
+ transitions from host are performed here.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+
+
+Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface was successful.
+ Other - If an error occured.
+*/
+
+
+/*
+Function: InterfaceIdleModeRespond
+
+Description: This is the hardware specific Function for responding to Idle mode request from target.
+ Necessary power state transitions from host for idle mode or other device specific
+ initializations are performed here.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+
+
+Return: BCM_STATUS_SUCCESS - If Idle mode response related HW configuration was successful.
+ Other - If an error occured.
+*/
+
+/*
+"dmem bfc02f00 100" tells how many time device went in Idle mode.
+this value will be at address bfc02fa4.just before value d0ea1dle.
+
+Set time value by writing at bfc02f98 7d0
+
+checking the Ack timer expire on kannon by running command
+d qcslog .. if it shows e means host has not send response to f/w with in 200 ms. Response should be
+send to f/w with in 200 ms after the Idle/Shutdown req issued
+
+*/
+
+
+int InterfaceIdleModeRespond(PMINI_ADAPTER Adapter,int* puiBuffer)
+{
+ int status = STATUS_SUCCESS;
+ unsigned int uiRegRead = 0;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"SubType of Message :0x%X", ntohl(*puiBuffer));
+
+ if(ntohl(*puiBuffer) == GO_TO_IDLE_MODE_PAYLOAD)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL," Got GO_TO_IDLE_MODE_PAYLOAD(210) Msg Subtype");
+ if(ntohl(*(puiBuffer+1)) == 0 )
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Got IDLE MODE WAKE UP Response From F/W");
+
+ status = wrmalt (Adapter,SW_ABORT_IDLEMODE_LOC, &uiRegRead, sizeof(uiRegRead));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg");
+ return status;
+ }
+
+ if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING)
+ {
+ uiRegRead = 0x00000000 ;
+ status = wrmalt (Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &uiRegRead, sizeof(uiRegRead));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg");
+ return status;
+ }
+ }
+ //Below Register should not br read in case of Manual and Protocol Idle mode.
+ else if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
+ {
+ //clear on read Register
+ status = rdmalt(Adapter, DEVICE_INT_OUT_EP_REG0, &uiRegRead, sizeof(uiRegRead));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed while clearing H/W Abort Reg0");
+ return status;
+ }
+ //clear on read Register
+ status = rdmalt (Adapter, DEVICE_INT_OUT_EP_REG1, &uiRegRead, sizeof(uiRegRead));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed while clearing H/W Abort Reg1");
+ return status;
+ }
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Device Up from Idle Mode");
+
+ // Set Idle Mode Flag to False and Clear IdleMode reg.
+ Adapter->IdleMode = FALSE;
+ Adapter->bTriedToWakeUpFromlowPowerMode = FALSE;
+
+ wake_up(&Adapter->lowpower_mode_wait_queue);
+ #if 0
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"LED Thread is Running. Hence Setting the LED Event as IDLEMODE_EXIT");
+ Adapter->DriverState = IDLEMODE_EXIT;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+ #endif
+
+ }
+ else
+ {
+ if(TRUE == Adapter->IdleMode)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Device is already in Idle mode....");
+ return status ;
+ }
+
+ uiRegRead = 0;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Got Req from F/W to go in IDLE mode \n");
+
+ if (Adapter->chip_id== BCS220_2 ||
+ Adapter->chip_id == BCS220_2BC ||
+ Adapter->chip_id== BCS250_BC ||
+ Adapter->chip_id== BCS220_3)
+ {
+
+ status = rdmalt(Adapter, HPM_CONFIG_MSW, &uiRegRead, sizeof(uiRegRead));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "rdm failed while Reading HPM_CONFIG_LDO145 Reg 0\n");
+ return status;
+ }
+
+
+ uiRegRead |= (1<<17);
+
+ status = wrmalt (Adapter,HPM_CONFIG_MSW, &uiRegRead, sizeof(uiRegRead));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm failed while clearing Idle Mode Reg\n");
+ return status;
+ }
+
+ }
+ SendIdleModeResponse(Adapter);
+ }
+ }
+ else if(ntohl(*puiBuffer) == IDLE_MODE_SF_UPDATE_MSG)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "OverRiding Service Flow Params");
+ OverrideServiceFlowParams(Adapter,puiBuffer);
+ }
+ return status;
+}
+
+
+VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter)
+{
+/* BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Low, 0x1d1e);
+ BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Low, 0x1d1e);
+ BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Upp, 0xd0ea);
+ BeceemWriteMemoryUshort(Adapter, Host2CPU_Mailbox_Upp, 0xd0ea);*/
+ return;
+}
+
+int InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern)
+{
+ int status = STATUS_SUCCESS;
+ unsigned int value;
+ unsigned int chip_id ;
+ unsigned long timeout = 0 ,itr = 0;
+
+ int lenwritten = 0;
+ unsigned char aucAbortPattern[8]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
+ PS_INTERFACE_ADAPTER psInterfaceAdapter = Adapter->pvInterfaceAdapter;
+
+ //Abort Bus suspend if its already suspended
+ if((TRUE == psInterfaceAdapter->bSuspended) && (TRUE == Adapter->bDoSuspend))
+ {
+ status = usb_autopm_get_interface(psInterfaceAdapter->interface);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Bus got wakeup..Aborting Idle mode... status:%d \n",status);
+
+ }
+
+ if((Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING)
+ ||
+ (Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE))
+ {
+ //write the SW abort pattern.
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Writing pattern<%d> to SW_ABORT_IDLEMODE_LOC\n", Pattern);
+ status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(Pattern));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to Register SW_ABORT_IDLEMODE_LOC failed..");
+ return status;
+ }
+ }
+
+ if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING)
+ {
+ value = 0x80000000;
+ status = wrmalt(Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &value, sizeof(value));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Register failed");
+ return status;
+ }
+ }
+ else if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
+ {
+ /*
+ * Get a Interrupt Out URB and send 8 Bytes Down
+ * To be Done in Thread Context.
+ * Not using Asynchronous Mechanism.
+ */
+ status = usb_interrupt_msg (psInterfaceAdapter->udev,
+ usb_sndintpipe(psInterfaceAdapter->udev,
+ psInterfaceAdapter->sIntrOut.int_out_endpointAddr),
+ aucAbortPattern,
+ 8,
+ &lenwritten,
+ 5000);
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Sending Abort pattern down fails with status:%d..\n",status);
+ return status;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "NOB Sent down :%d", lenwritten);
+ }
+
+ //mdelay(25);
+
+ timeout= jiffies + msecs_to_jiffies(50) ;
+ while( timeout > jiffies )
+ {
+ itr++ ;
+ rdmalt(Adapter, CHIP_ID_REG, &chip_id, sizeof(UINT));
+ if(0xbece3200==(chip_id&~(0xF0)))
+ {
+ chip_id = chip_id&~(0xF0);
+ }
+ if(chip_id == Adapter->chip_id)
+ break;
+ }
+ if(timeout < jiffies )
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Not able to read chip-id even after 25 msec");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Number of completed iteration to read chip-id :%lu", itr);
+ }
+
+ status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(status));
+ if(status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to Register SW_ABORT_IDLEMODE_LOC failed..");
+ return status;
+ }
+ }
+ return status;
+}
+int InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter)
+{
+ ULONG Status = 0;
+ if(Adapter->bTriedToWakeUpFromlowPowerMode)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Wake up already attempted.. ignoring\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL,"Writing Low Power Mode Abort pattern to the Device\n");
+ Adapter->bTriedToWakeUpFromlowPowerMode = TRUE;
+ InterfaceAbortIdlemode(Adapter, Adapter->usIdleModePattern);
+
+ }
+ return Status;
+}
+
+void InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter)
+{
+ unsigned int uiRegVal = 0;
+ INT Status = 0;
+ if(Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING)
+ {
+ // clear idlemode interrupt.
+ uiRegVal = 0;
+ Status =wrmalt(Adapter,DEBUG_INTERRUPT_GENERATOR_REGISTOR, &uiRegVal, sizeof(uiRegVal));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Failed with err :%d", Status);
+ return;
+ }
+ }
+
+ else
+ {
+
+ //clear Interrupt EP registers.
+ Status = rdmalt(Adapter,DEVICE_INT_OUT_EP_REG0, &uiRegVal, sizeof(uiRegVal));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM of DEVICE_INT_OUT_EP_REG0 failed with Err :%d", Status);
+ return;
+ }
+
+ Status = rdmalt(Adapter,DEVICE_INT_OUT_EP_REG1, &uiRegVal, sizeof(uiRegVal));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RDM of DEVICE_INT_OUT_EP_REG1 failed with Err :%d", Status);
+ return;
+ }
+ }
+}
+
diff --git a/drivers/staging/bcm/InterfaceIdleMode.h b/drivers/staging/bcm/InterfaceIdleMode.h
new file mode 100644
index 00000000000..f87c132989f
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceIdleMode.h
@@ -0,0 +1,16 @@
+#ifndef _INTERFACE_IDLEMODE_H
+#define _INTERFACE_IDLEMODE_H
+
+INT InterfaceIdleModeWakeup(PMINI_ADAPTER Adapter);
+
+INT InterfaceIdleModeRespond(PMINI_ADAPTER Adapter,PINT puiBuffer);
+
+VOID InterfaceWriteIdleModeWakePattern(PMINI_ADAPTER Adapter);
+
+INT InterfaceAbortIdlemode(PMINI_ADAPTER Adapter, unsigned int Pattern);
+
+INT InterfaceWakeUp(PMINI_ADAPTER Adapter);
+
+VOID InterfaceHandleShutdownModeWakeup(PMINI_ADAPTER Adapter);
+#endif
+
diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c
new file mode 100644
index 00000000000..e06f168a52b
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceInit.c
@@ -0,0 +1,868 @@
+#include "headers.h"
+
+static struct usb_device_id InterfaceUsbtable[] = {
+ { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3) },
+ { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3B) },
+ { USB_DEVICE(BCM_USB_VENDOR_ID_T3, BCM_USB_PRODUCT_ID_T3L) },
+ { USB_DEVICE(BCM_USB_VENDOR_ID_ZTE, BCM_USB_PRODUCT_ID_226) },
+ { USB_DEVICE(BCM_USB_VENDOR_ID_FOXCONN, BCM_USB_PRODUCT_ID_1901) },
+ {}
+};
+
+VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ INT i = 0;
+ // Wake up the wait_queue...
+ if(psIntfAdapter->psAdapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ psIntfAdapter->psAdapter->DriverState = DRIVER_HALT;
+ wake_up(&psIntfAdapter->psAdapter->LEDInfo.notify_led_event);
+ }
+ reset_card_proc(psIntfAdapter->psAdapter);
+
+ //worst case time taken by the RDM/WRM will be 5 sec. will check after every 100 ms
+ //to accertain the device is not being accessed. After this No RDM/WRM should be made.
+ while(psIntfAdapter->psAdapter->DeviceAccess)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Device is being Accessed \n");
+ msleep(100);
+ }
+ /* Free interrupt URB */
+ //psIntfAdapter->psAdapter->device_removed = TRUE;
+ if(psIntfAdapter->psInterruptUrb)
+ {
+ usb_free_urb(psIntfAdapter->psInterruptUrb);
+ }
+
+ /* Free transmit URBs */
+ for(i = 0; i < MAXIMUM_USB_TCB; i++)
+ {
+ if(psIntfAdapter->asUsbTcb[i].urb != NULL)
+ {
+ usb_free_urb(psIntfAdapter->asUsbTcb[i].urb);
+ psIntfAdapter->asUsbTcb[i].urb = NULL;
+ }
+ }
+ /* Free receive URB and buffers */
+ for(i = 0; i < MAXIMUM_USB_RCB; i++)
+ {
+ if (psIntfAdapter->asUsbRcb[i].urb != NULL)
+ {
+ bcm_kfree(psIntfAdapter->asUsbRcb[i].urb->transfer_buffer);
+ usb_free_urb(psIntfAdapter->asUsbRcb[i].urb);
+ psIntfAdapter->asUsbRcb[i].urb = NULL;
+ }
+ }
+ AdapterFree(psIntfAdapter->psAdapter);
+}
+
+
+
+static int usbbcm_open(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+static int usbbcm_release(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+static ssize_t usbbcm_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
+{
+ return 0;
+}
+
+static ssize_t usbbcm_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos)
+{
+ return 0;
+}
+
+
+VOID ConfigureEndPointTypesThroughEEPROM(PMINI_ADAPTER Adapter)
+{
+ ULONG ulReg = 0;
+
+// Program EP2 MAX_PKT_SIZE
+ ulReg = ntohl(EP2_MPS_REG);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x128,4,TRUE);
+ ulReg = ntohl(EP2_MPS);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x12C,4,TRUE);
+
+ ulReg = ntohl(EP2_CFG_REG);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x132,4,TRUE);
+ if(((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter))->bHighSpeedDevice == TRUE)
+ {
+ ulReg = ntohl(EP2_CFG_INT);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE);
+ }
+ else
+ {
+// USE BULK EP as TX in FS mode.
+ ulReg = ntohl(EP2_CFG_BULK);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x136,4,TRUE);
+ }
+
+
+// Program EP4 MAX_PKT_SIZE.
+ ulReg = ntohl(EP4_MPS_REG);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x13C,4,TRUE);
+ ulReg = ntohl(EP4_MPS);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x140,4,TRUE);
+
+// Program TX EP as interrupt (Alternate Setting)
+ if( rdmalt(Adapter,0x0F0110F8, (PUINT)&ulReg,4))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reading of Tx EP is failing");
+ return ;
+ }
+ ulReg |= 0x6;
+
+ ulReg = ntohl(ulReg);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1CC,4,TRUE);
+
+ ulReg = ntohl(EP4_CFG_REG);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C8,4,TRUE);
+// Program ISOCHRONOUS EP size to zero.
+ ulReg = ntohl(ISO_MPS_REG);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D2,4,TRUE);
+ ulReg = ntohl(ISO_MPS);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1D6,4,TRUE);
+
+// Update EEPROM Version.
+// Read 4 bytes from 508 and modify 511 and 510.
+//
+ ReadBeceemEEPROM(Adapter,0x1FC,(PUINT)&ulReg);
+ ulReg &= 0x0101FFFF;
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1FC,4,TRUE);
+//
+//Update length field if required. Also make the string NULL terminated.
+//
+ ReadBeceemEEPROM(Adapter,0xA8,(PUINT)&ulReg);
+ if((ulReg&0x00FF0000)>>16 > 0x30)
+ {
+ ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0xA8,4,TRUE);
+ }
+ ReadBeceemEEPROM(Adapter,0x148,(PUINT)&ulReg);
+ if((ulReg&0x00FF0000)>>16 > 0x30)
+ {
+ ulReg = (ulReg&0xFF00FFFF)|(0x30<<16);
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x148,4,TRUE);
+ }
+ ulReg = 0;
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x122,4,TRUE);
+ ulReg = 0;
+ BeceemEEPROMBulkWrite(Adapter,(PUCHAR)&ulReg,0x1C2,4,TRUE);
+
+}
+
+static struct file_operations usbbcm_fops = {
+ .open = usbbcm_open,
+ .release = usbbcm_release,
+ .read = usbbcm_read,
+ .write = usbbcm_write,
+ .owner = THIS_MODULE,
+};
+
+static struct usb_class_driver usbbcm_class = {
+ .name = "usbbcm",
+ .fops = &usbbcm_fops,
+ .minor_base = BCM_USB_MINOR_BASE,
+};
+
+static int
+usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+ int retval =0 ;
+ PMINI_ADAPTER psAdapter = NULL;
+ PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
+ struct usb_device *udev = NULL;
+
+// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usbbcm probe!!");
+ if((intf == NULL) || (id == NULL))
+ {
+ // BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf or id is NULL");
+ return -EINVAL;
+ }
+
+ /* Allocate Adapter structure */
+ if((psAdapter = kmalloc(sizeof(MINI_ADAPTER), GFP_KERNEL)) == NULL)
+ {
+ //BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
+ return -ENOMEM;
+ }
+
+ memset(psAdapter, 0, sizeof(MINI_ADAPTER));
+
+ /* Init default driver debug state */
+
+ psAdapter->stDebugState.debug_level = DBG_LVL_CURR;
+ psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
+ memset (psAdapter->stDebugState.subtype, 0, sizeof (psAdapter->stDebugState.subtype));
+
+ /* Technically, one can start using BCM_DEBUG_PRINT after this point.
+ * However, realize that by default the Type/Subtype bitmaps are all zero now;
+ * so no prints will actually appear until the TestApp turns on debug paths via
+ * the ioctl(); so practically speaking, in early init, no logging happens.
+ *
+ * A solution (used below): we explicitly set the bitmaps to 1 for Type=DBG_TYPE_INITEXIT
+ * and ALL subtype's of the same. Now all bcm debug statements get logged, enabling debug
+ * during early init.
+ * Further, we turn this OFF once init_module() completes.
+ */
+
+ psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0xff;
+ BCM_SHOW_DEBUG_BITMAP(psAdapter);
+
+ retval = InitAdapter(psAdapter);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT (psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InitAdapter Failed\n");
+ AdapterFree(psAdapter);
+ return retval;
+ }
+
+ /* Allocate interface adapter structure */
+ if((psAdapter->pvInterfaceAdapter =
+ kmalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL)) == NULL)
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
+ AdapterFree (psAdapter);
+ return -ENOMEM;
+ }
+ memset(psAdapter->pvInterfaceAdapter, 0, sizeof(S_INTERFACE_ADAPTER));
+
+ psIntfAdapter = InterfaceAdapterGet(psAdapter);
+ psIntfAdapter->psAdapter = psAdapter;
+
+ /* Store usb interface in Interface Adapter */
+ psIntfAdapter->interface = intf;
+ usb_set_intfdata(intf, psIntfAdapter);
+
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%x",(unsigned int)psIntfAdapter);
+ retval = InterfaceAdapterInit(psIntfAdapter);
+ if(retval)
+ {
+ /* If the Firmware/Cfg File is not present
+ * then return success, let the application
+ * download the files.
+ */
+ if(-ENOENT == retval){
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "File Not Found, Use App to Download\n");
+ return STATUS_SUCCESS;
+ }
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapterInit Failed \n");
+ usb_set_intfdata(intf, NULL);
+ udev = interface_to_usbdev (intf);
+ usb_put_dev(udev);
+ if(psAdapter->bUsbClassDriverRegistered == TRUE)
+ usb_deregister_dev (intf, &usbbcm_class);
+ InterfaceAdapterFree(psIntfAdapter);
+ return retval ;
+ }
+ if(psAdapter->chip_id > T3)
+ {
+ uint32_t uiNackZeroLengthInt=4;
+ if(wrmalt(psAdapter, DISABLE_USB_ZERO_LEN_INT, &uiNackZeroLengthInt, sizeof(uiNackZeroLengthInt)))
+ {
+ return -EIO;;
+ }
+ }
+
+ udev = interface_to_usbdev (intf);
+ /* Check whether the USB-Device Supports remote Wake-Up */
+ if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes)
+ {
+ /* If Suspend then only support dynamic suspend */
+ if(psAdapter->bDoSuspend)
+ {
+ udev->autosuspend_delay = 0;
+ intf->needs_remote_wakeup = 1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
+ udev->autosuspend_disabled = 0;
+#else
+ usb_enable_autosuspend(udev);
+#endif
+ device_init_wakeup(&intf->dev,1);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
+ usb_autopm_disable(intf);
+#endif
+ INIT_WORK(&psIntfAdapter->usbSuspendWork, putUsbSuspend);
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Enabling USB Auto-Suspend\n");
+ }
+ else
+ {
+ intf->needs_remote_wakeup = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
+ udev->autosuspend_disabled = 1;
+#else
+ usb_disable_autosuspend(udev);
+#endif
+ }
+ }
+
+ psAdapter->stDebugState.subtype[DBG_TYPE_INITEXIT] = 0x0;
+ return retval;
+}
+
+static void usbbcm_disconnect (struct usb_interface *intf)
+{
+ PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
+ PMINI_ADAPTER psAdapter = NULL;
+ struct usb_device *udev = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usb disconnected");
+ if(intf == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf pointer is NULL");
+ return;
+ }
+ psIntfAdapter = usb_get_intfdata(intf);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%x",(unsigned int)psIntfAdapter);
+ if(psIntfAdapter == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapter pointer is NULL");
+ return;
+ }
+ psAdapter = psIntfAdapter->psAdapter;
+ if(psAdapter->bDoSuspend)
+ intf->needs_remote_wakeup = 0;
+
+ psAdapter->device_removed = TRUE ;
+ usb_set_intfdata(intf, NULL);
+ InterfaceAdapterFree(psIntfAdapter);
+ udev = interface_to_usbdev (intf);
+ usb_put_dev(udev);
+ usb_deregister_dev (intf, &usbbcm_class);
+}
+
+
+static __inline int AllocUsbCb(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ int i = 0;
+ for(i = 0; i < MAXIMUM_USB_TCB; i++)
+ {
+ if((psIntfAdapter->asUsbTcb[i].urb =
+ usb_alloc_urb(0, GFP_KERNEL)) == NULL)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Tx urb for index %d", i);
+ return -ENOMEM;
+ }
+ }
+
+ for(i = 0; i < MAXIMUM_USB_RCB; i++)
+ {
+ if ((psIntfAdapter->asUsbRcb[i].urb =
+ usb_alloc_urb(0, GFP_KERNEL)) == NULL)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx urb for index %d", i);
+ return -ENOMEM;
+ }
+ if((psIntfAdapter->asUsbRcb[i].urb->transfer_buffer =
+ kmalloc(MAX_DATA_BUFFER_SIZE, GFP_KERNEL)) == NULL)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cant allocate Rx buffer for index %d", i);
+ return -ENOMEM;
+ }
+ psIntfAdapter->asUsbRcb[i].urb->transfer_buffer_length = MAX_DATA_BUFFER_SIZE;
+ }
+ return 0;
+}
+
+
+
+static int device_run(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ INT value = 0;
+ UINT status = STATUS_SUCCESS;
+
+ status = InitCardAndDownloadFirmware(psIntfAdapter->psAdapter);
+ if(status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "InitCardAndDownloadFirmware failed.\n");
+ return status;
+ }
+ if(TRUE == psIntfAdapter->psAdapter->fw_download_done)
+ {
+
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Sending first interrupt URB down......");
+ if(StartInterruptUrb(psIntfAdapter))
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Cannot send interrupt in URB");
+ }
+ //now register the cntrl interface.
+ //after downloading the f/w waiting for 5 sec to get the mailbox interrupt.
+
+ psIntfAdapter->psAdapter->waiting_to_fw_download_done = FALSE;
+ value = wait_event_timeout(psIntfAdapter->psAdapter->ioctl_fw_dnld_wait_queue,
+ psIntfAdapter->psAdapter->waiting_to_fw_download_done, 5*HZ);
+
+ if(value == 0)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Mailbox Interrupt has not reached to Driver..");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Got the mailbox interrupt ...Registering control interface...\n ");
+ }
+ if(register_control_device_interface(psIntfAdapter->psAdapter) < 0)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Register Control Device failed...");
+ return -EIO;
+ }
+ }
+ return 0;
+}
+
+#if 0
+static void print_usb_interface_desc(struct usb_interface_descriptor *usb_intf_desc)
+{
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "**************** INTERFACE DESCRIPTOR *********************");
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bLength: %x", usb_intf_desc->bLength);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bDescriptorType: %x", usb_intf_desc->bDescriptorType);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceNumber: %x", usb_intf_desc->bInterfaceNumber);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bAlternateSetting: %x", usb_intf_desc->bAlternateSetting);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bNumEndpoints: %x", usb_intf_desc->bNumEndpoints);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceClass: %x", usb_intf_desc->bInterfaceClass);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceSubClass: %x", usb_intf_desc->bInterfaceSubClass);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterfaceProtocol: %x", usb_intf_desc->bInterfaceProtocol);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "iInterface :%x\n",usb_intf_desc->iInterface);
+}
+static void print_usb_endpoint_descriptor(struct usb_endpoint_descriptor *usb_ep_desc)
+{
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "**************** ENDPOINT DESCRIPTOR *********************");
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bLength :%x ", usb_ep_desc->bLength);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bDescriptorType :%x ", usb_ep_desc->bDescriptorType);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bEndpointAddress :%x ", usb_ep_desc->bEndpointAddress);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bmAttributes :%x ", usb_ep_desc->bmAttributes);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "wMaxPacketSize :%x ",usb_ep_desc->wMaxPacketSize);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "bInterval :%x ",usb_ep_desc->bInterval);
+}
+
+#endif
+
+static inline int bcm_usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
+{
+ return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+}
+
+static inline int bcm_usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
+{
+ return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+}
+
+static inline int bcm_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
+{
+ return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
+}
+
+static inline int bcm_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
+{
+ return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
+}
+
+static inline int bcm_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
+{
+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
+ USB_ENDPOINT_XFER_BULK);
+}
+
+static inline int bcm_usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd)
+{
+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
+ USB_ENDPOINT_XFER_CONTROL);
+}
+
+static inline int bcm_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
+{
+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
+ USB_ENDPOINT_XFER_INT);
+}
+
+static inline int bcm_usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
+{
+ return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
+ USB_ENDPOINT_XFER_ISOC);
+}
+
+static inline int bcm_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
+{
+ return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_in(epd));
+}
+
+static inline int bcm_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
+{
+ return (bcm_usb_endpoint_xfer_bulk(epd) && bcm_usb_endpoint_dir_out(epd));
+}
+
+static inline int bcm_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
+{
+ return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_in(epd));
+}
+
+static inline int bcm_usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
+{
+ return (bcm_usb_endpoint_xfer_int(epd) && bcm_usb_endpoint_dir_out(epd));
+}
+
+static inline int bcm_usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
+{
+ return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_in(epd));
+}
+
+static inline int bcm_usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
+{
+ return (bcm_usb_endpoint_xfer_isoc(epd) && bcm_usb_endpoint_dir_out(epd));
+}
+
+INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ struct usb_host_interface *iface_desc;
+ struct usb_endpoint_descriptor *endpoint;
+ size_t buffer_size;
+ ULONG value;
+ INT retval = 0;
+ INT usedIntOutForBulkTransfer = 0 ;
+ BOOLEAN bBcm16 = FALSE;
+ UINT uiData = 0;
+
+ if(psIntfAdapter == NULL)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Interface Adapter is NULL");
+ return -EINVAL;
+ }
+ /* Store the usb dev into interface adapter */
+ psIntfAdapter->udev = usb_get_dev(interface_to_usbdev(
+ psIntfAdapter->interface));
+
+ if((psIntfAdapter->udev->speed == USB_SPEED_HIGH))
+ {
+ psIntfAdapter->bHighSpeedDevice = TRUE ;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO HIGH_SPEED ");
+ }
+ else
+ {
+ psIntfAdapter->bHighSpeedDevice = FALSE ;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "MODEM IS CONFIGURED TO FULL_SPEED ");
+ }
+
+ psIntfAdapter->psAdapter->interface_rdm = BcmRDM;
+ psIntfAdapter->psAdapter->interface_wrm = BcmWRM;
+
+ if(rdmalt(psIntfAdapter->psAdapter, CHIP_ID_REG, (PUINT)&(psIntfAdapter->psAdapter->chip_id), sizeof(UINT)) < 0)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "CHIP ID Read Failed\n");
+ return STATUS_FAILURE;
+ }
+ if(0xbece3200==(psIntfAdapter->psAdapter->chip_id&~(0xF0)))
+ {
+ psIntfAdapter->psAdapter->chip_id=(psIntfAdapter->psAdapter->chip_id&~(0xF0));
+ }
+
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "First RDM Chip ID 0x%lx\n", psIntfAdapter->psAdapter->chip_id);
+
+ iface_desc = psIntfAdapter->interface->cur_altsetting;
+ //print_usb_interface_desc(&(iface_desc->desc));
+
+ if(psIntfAdapter->psAdapter->chip_id == T3B)
+ {
+
+ //
+ //T3B device will have EEPROM,check if EEPROM is proper and BCM16 can be done or not.
+ //
+ BeceemEEPROMBulkRead(psIntfAdapter->psAdapter,&uiData,0x0,4);
+ if(uiData == BECM)
+ {
+ bBcm16 = TRUE;
+ }
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Number of Altsetting aviailable for This Modem 0x%x\n", psIntfAdapter->interface->num_altsetting);
+ if(bBcm16 == TRUE)
+ {
+ //selecting alternate setting one as a default setting for High Speed modem.
+ if(psIntfAdapter->bHighSpeedDevice)
+ retval= usb_set_interface(psIntfAdapter->udev,DEFAULT_SETTING_0,ALTERNATE_SETTING_1);
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "BCM16 is Applicable on this dongle");
+ if(retval || (psIntfAdapter->bHighSpeedDevice == FALSE))
+ {
+ usedIntOutForBulkTransfer = EP2 ;
+ endpoint = &iface_desc->endpoint[EP2].desc;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Interface altsetting got failed or Moemd is configured to FS.hence will work on default setting 0 \n");
+ /*
+ If Modem is high speed device EP2 should be INT OUT End point
+ If Mode is FS then EP2 should be bulk end point
+ */
+ if(((psIntfAdapter->bHighSpeedDevice ==TRUE ) && (bcm_usb_endpoint_is_int_out(endpoint)== FALSE))
+ ||((psIntfAdapter->bHighSpeedDevice == FALSE)&& (bcm_usb_endpoint_is_bulk_out(endpoint)== FALSE)))
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Configuring the EEPROM ");
+ //change the EP2, EP4 to INT OUT end point
+ ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter);
+
+ /*
+ It resets the device and if any thing gets changed in USB descriptor it will show fail and
+ re-enumerate the device
+ */
+ retval = usb_reset_device(psIntfAdapter->udev);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n");
+ return retval ;
+ }
+
+ }
+ if((psIntfAdapter->bHighSpeedDevice == FALSE) && bcm_usb_endpoint_is_bulk_out(endpoint))
+ {
+ // Once BULK is selected in FS mode. Revert it back to INT. Else USB_IF will fail.
+ UINT uiData = ntohl(EP2_CFG_INT);
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"Reverting Bulk to INT as it is FS MODE");
+ BeceemEEPROMBulkWrite(psIntfAdapter->psAdapter,(PUCHAR)&uiData,0x136,4,TRUE);
+ }
+ }
+ else
+ {
+ usedIntOutForBulkTransfer = EP4 ;
+ endpoint = &iface_desc->endpoint[EP4].desc;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Choosing AltSetting as a default setting");
+ if( bcm_usb_endpoint_is_int_out(endpoint) == FALSE)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, " Dongle does not have BCM16 Fix");
+ //change the EP2, EP4 to INT OUT end point and use EP4 in altsetting
+ ConfigureEndPointTypesThroughEEPROM(psIntfAdapter->psAdapter);
+
+ /*
+ It resets the device and if any thing gets changed in USB descriptor it will show fail and
+ re-enumerate the device
+ */
+ retval = usb_reset_device(psIntfAdapter->udev);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "reset got failed. hence Re-enumerating the device \n");
+ return retval ;
+ }
+
+ }
+ }
+ }
+ }
+
+ iface_desc = psIntfAdapter->interface->cur_altsetting;
+ //print_usb_interface_desc(&(iface_desc->desc));
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Current number of endpoints :%x \n", iface_desc->desc.bNumEndpoints);
+ for (value = 0; value < iface_desc->desc.bNumEndpoints; ++value)
+ {
+ endpoint = &iface_desc->endpoint[value].desc;
+ //print_usb_endpoint_descriptor(endpoint);
+
+ if (!psIntfAdapter->sBulkIn.bulk_in_endpointAddr && bcm_usb_endpoint_is_bulk_in(endpoint))
+ {
+ buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+ psIntfAdapter->sBulkIn.bulk_in_size = buffer_size;
+ psIntfAdapter->sBulkIn.bulk_in_endpointAddr =
+ endpoint->bEndpointAddress;
+ psIntfAdapter->sBulkIn.bulk_in_pipe =
+ usb_rcvbulkpipe(psIntfAdapter->udev,
+ psIntfAdapter->sBulkIn.bulk_in_endpointAddr);
+ }
+
+ if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr && bcm_usb_endpoint_is_bulk_out(endpoint))
+ {
+
+ psIntfAdapter->sBulkOut.bulk_out_endpointAddr =
+ endpoint->bEndpointAddress;
+ psIntfAdapter->sBulkOut.bulk_out_pipe =
+ usb_sndbulkpipe(psIntfAdapter->udev,
+ psIntfAdapter->sBulkOut.bulk_out_endpointAddr);
+ }
+
+ if (!psIntfAdapter->sIntrIn.int_in_endpointAddr && bcm_usb_endpoint_is_int_in(endpoint))
+ {
+ buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+ psIntfAdapter->sIntrIn.int_in_size = buffer_size;
+ psIntfAdapter->sIntrIn.int_in_endpointAddr =
+ endpoint->bEndpointAddress;
+ psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval;
+ psIntfAdapter->sIntrIn.int_in_buffer =
+ kmalloc(buffer_size, GFP_KERNEL);
+ if (!psIntfAdapter->sIntrIn.int_in_buffer) {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_in_buffer");
+ return -EINVAL;
+ }
+ //psIntfAdapter->sIntrIn.int_in_pipe =
+ }
+
+ if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint))
+ {
+
+ if( !psIntfAdapter->sBulkOut.bulk_out_endpointAddr &&
+ (psIntfAdapter->psAdapter->chip_id == T3B) && (value == usedIntOutForBulkTransfer))
+ {
+ //use first intout end point as a bulk out end point
+ buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+ psIntfAdapter->sBulkOut.bulk_out_size = buffer_size;
+ //printk("\nINT OUT Endpoing buffer size :%x endpoint :%x\n", buffer_size, value +1);
+ psIntfAdapter->sBulkOut.bulk_out_endpointAddr =
+ endpoint->bEndpointAddress;
+ psIntfAdapter->sBulkOut.bulk_out_pipe =
+ usb_sndintpipe(psIntfAdapter->udev,
+ psIntfAdapter->sBulkOut.bulk_out_endpointAddr);
+ psIntfAdapter->sBulkOut.int_out_interval = endpoint->bInterval;
+
+ }
+ else if(value == EP6)
+ {
+ buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
+ psIntfAdapter->sIntrOut.int_out_size = buffer_size;
+ psIntfAdapter->sIntrOut.int_out_endpointAddr =
+ endpoint->bEndpointAddress;
+ psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval;
+ psIntfAdapter->sIntrOut.int_out_buffer= kmalloc(buffer_size,
+ GFP_KERNEL);
+ if (!psIntfAdapter->sIntrOut.int_out_buffer)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Could not allocate interrupt_out_buffer");
+ return -EINVAL;
+ }
+ }
+ }
+ }
+ usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter);
+ retval = usb_register_dev(psIntfAdapter->interface, &usbbcm_class);
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "usb register dev failed = %d", retval);
+ psIntfAdapter->psAdapter->bUsbClassDriverRegistered = FALSE;
+ return retval;
+ }
+ else
+ {
+ psIntfAdapter->psAdapter->bUsbClassDriverRegistered = TRUE;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "usb dev registered");
+ }
+
+ psIntfAdapter->psAdapter->bcm_file_download = InterfaceFileDownload;
+ psIntfAdapter->psAdapter->bcm_file_readback_from_chip =
+ InterfaceFileReadbackFromChip;
+ psIntfAdapter->psAdapter->interface_transmit = InterfaceTransmitPacket;
+
+ retval = CreateInterruptUrb(psIntfAdapter);
+
+ if(retval)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cannot create interrupt urb");
+ return retval;
+ }
+
+ retval = AllocUsbCb(psIntfAdapter);
+ if(retval)
+ {
+ return retval;
+ }
+
+
+ retval = device_run(psIntfAdapter);
+ if(retval)
+ {
+ return retval;
+ }
+
+
+ return 0;
+}
+int InterfaceSuspend (struct usb_interface *intf, pm_message_t message)
+{
+ PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=================================\n");
+ //Bcm_kill_all_URBs(psIntfAdapter);
+ psIntfAdapter->bSuspended = TRUE;
+
+ if(TRUE == psIntfAdapter->bPreparingForBusSuspend)
+ {
+ psIntfAdapter->bPreparingForBusSuspend = FALSE;
+
+ if(psIntfAdapter->psAdapter->LinkStatus == LINKUP_DONE)
+ {
+ psIntfAdapter->psAdapter->IdleMode = TRUE ;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Idle Mode..");
+ }
+ else
+ {
+ psIntfAdapter->psAdapter->bShutStatus = TRUE;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Host Entered in PMU Shutdown Mode..");
+ }
+ }
+ psIntfAdapter->psAdapter->bPreparingForLowPowerMode = FALSE;
+
+ //Signaling the control pkt path
+ wake_up(&psIntfAdapter->psAdapter->lowpower_mode_wait_queue);
+
+ return 0;
+}
+int InterfaceResume (struct usb_interface *intf)
+{
+ PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf);
+ printk("=================================\n");
+ mdelay(100);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
+ intf->pm_usage_cnt =1 ;
+#endif
+ psIntfAdapter->bSuspended = FALSE;
+
+ StartInterruptUrb(psIntfAdapter);
+ InterfaceRx(psIntfAdapter);
+ return 0;
+}
+int InterfacePreReset(struct usb_interface *intf)
+{
+ printk("====================>");
+ return STATUS_SUCCESS;
+}
+int InterfacePostReset(struct usb_interface *intf)
+{
+ printk("Do Post chip reset setting here if it is required");
+ return STATUS_SUCCESS;
+}
+static struct usb_driver usbbcm_driver = {
+ .name = "usbbcm",
+ .probe = usbbcm_device_probe,
+ .disconnect = usbbcm_disconnect,
+ .suspend = InterfaceSuspend,
+ .resume = InterfaceResume,
+ .pre_reset=InterfacePreReset,
+ .post_reset=InterfacePostReset,
+ .id_table = InterfaceUsbtable,
+ .supports_autosuspend = 1,
+};
+
+
+/*
+Function: InterfaceInitialize
+
+Description: This is the hardware specific initialization Function.
+ Registering the driver with NDIS , other device specific NDIS
+ and hardware initializations are done here.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+
+
+Return: BCM_STATUS_SUCCESS - If Initialization of the
+ HW Interface was successful.
+ Other - If an error occured.
+*/
+INT InterfaceInitialize(void)
+{
+// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Registering Usb driver!!");
+ return usb_register(&usbbcm_driver);
+}
+
+INT InterfaceExit(void)
+{
+ //PMINI_ADAPTER psAdapter = NULL;
+ int status = 0;
+
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Deregistering Usb driver!!");
+ usb_deregister(&usbbcm_driver);
+ return status;
+}
+MODULE_LICENSE ("GPL");
diff --git a/drivers/staging/bcm/InterfaceInit.h b/drivers/staging/bcm/InterfaceInit.h
new file mode 100644
index 00000000000..e7a96e5c5c5
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceInit.h
@@ -0,0 +1,51 @@
+#ifndef _INTERFACE_INIT_H
+#define _INTERFACE_INIT_H
+
+#define BCM_USB_VENDOR_ID_T3 0x198f
+#define BCM_USB_VENDOR_ID_FOXCONN 0x0489
+#define BCM_USB_VENDOR_ID_ZTE 0x19d2
+
+#define BCM_USB_PRODUCT_ID_T3 0x0300
+#define BCM_USB_PRODUCT_ID_T3B 0x0210
+#define BCM_USB_PRODUCT_ID_T3L 0x0220
+#define BCM_USB_PRODUCT_ID_SYM 0x15E
+#define BCM_USB_PRODUCT_ID_1901 0xe017
+#define BCM_USB_PRODUCT_ID_226 0x0132
+
+#define BCM_USB_MINOR_BASE 192
+
+
+INT InterfaceInitialize(void);
+
+INT InterfaceExit(void);
+
+#ifndef BCM_SHM_INTERFACE
+INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter);
+
+INT usbbcm_worker_thread(PS_INTERFACE_ADAPTER psIntfAdapter);
+
+VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter);
+
+#else
+INT InterfaceAdapterInit(PMINI_ADAPTER Adapter);
+#endif
+
+
+#if 0
+
+ULONG InterfaceClaimAdapter(PMINI_ADAPTER Adapter);
+
+VOID InterfaceDDRControllerInit(PMINI_ADAPTER Adapter);
+
+ULONG InterfaceReset(PMINI_ADAPTER Adapter);
+
+ULONG InterfaceRegisterResources(PMINI_ADAPTER Adapter);
+
+VOID InterfaceUnRegisterResources(PMINI_ADAPTER Adapter);
+
+ULONG InterfaceFirmwareDownload(PMINI_ADAPTER Adapter);
+
+#endif
+
+#endif
+
diff --git a/drivers/staging/bcm/InterfaceIsr.c b/drivers/staging/bcm/InterfaceIsr.c
new file mode 100644
index 00000000000..f928fe4d564
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceIsr.c
@@ -0,0 +1,203 @@
+#include "headers.h"
+
+#ifndef BCM_SHM_INTERFACE
+
+static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)
+{
+ int status = urb->status;
+ PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context;
+ PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ;
+
+ if(Adapter->device_removed == TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed.");
+ return ;
+ }
+
+ if(((Adapter->bPreparingForLowPowerMode == TRUE) && (Adapter->bDoSuspend == TRUE)) ||
+ psIntfAdapter->bSuspended ||
+ psIntfAdapter->bPreparingForBusSuspend)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt call back is called while suspending the device");
+ return ;
+ }
+
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "interrupt urb status %d", status);
+ switch (status) {
+ /* success */
+ case STATUS_SUCCESS:
+ if ( urb->actual_length )
+ {
+
+ if(psIntfAdapter->ulInterruptData[1] & 0xFF)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Got USIM interrupt");
+ }
+
+ if(psIntfAdapter->ulInterruptData[1] & 0xFF00)
+ {
+ atomic_set(&Adapter->CurrNumFreeTxDesc,
+ (psIntfAdapter->ulInterruptData[1] & 0xFF00) >> 8);
+ atomic_set (&Adapter->uiMBupdate, TRUE);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "TX mailbox contains %d",
+ atomic_read(&Adapter->CurrNumFreeTxDesc));
+ }
+ if(psIntfAdapter->ulInterruptData[1] >> 16)
+ {
+ Adapter->CurrNumRecvDescs=
+ (psIntfAdapter->ulInterruptData[1] >> 16);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"RX mailbox contains %d",
+ Adapter->CurrNumRecvDescs);
+ InterfaceRx(psIntfAdapter);
+ }
+ if(Adapter->fw_download_done &&
+ !Adapter->downloadDDR &&
+ atomic_read(&Adapter->CurrNumFreeTxDesc))
+ {
+ psIntfAdapter->psAdapter->downloadDDR +=1;
+ wake_up(&Adapter->tx_packet_wait_queue);
+ }
+ if(FALSE == Adapter->waiting_to_fw_download_done)
+ {
+ Adapter->waiting_to_fw_download_done = TRUE;
+ wake_up(&Adapter->ioctl_fw_dnld_wait_queue);
+ }
+ if(!atomic_read(&Adapter->TxPktAvail))
+ {
+ atomic_set(&Adapter->TxPktAvail, 1);
+ wake_up(&Adapter->tx_packet_wait_queue);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Firing interrupt in URB");
+ }
+ break;
+ case -ENOENT :
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"URB has got disconnected ....");
+ return ;
+ }
+ case -EINPROGRESS:
+ {
+ //This situation may happend when URBunlink is used. for detail check usb_unlink_urb documentation.
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Impossibe condition has occured... something very bad is going on");
+ break ;
+ //return;
+ }
+ case -EPIPE:
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt IN endPoint has got halted/stalled...need to clear this");
+ Adapter->bEndPointHalted = TRUE ;
+ wake_up(&Adapter->tx_packet_wait_queue);
+ urb->status = STATUS_SUCCESS ;;
+ return;
+ }
+ /* software-driven interface shutdown */
+ case -ECONNRESET: //URB got unlinked.
+ case -ESHUTDOWN: // hardware gone. this is the serious problem.
+ //Occurs only when something happens with the host controller device
+ case -ENODEV : //Device got removed
+ case -EINVAL : //Some thing very bad happened with the URB. No description is available.
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"interrupt urb error %d", status);
+ urb->status = STATUS_SUCCESS ;
+ break ;
+ //return;
+ default:
+ //This is required to check what is the defaults conditions when it occurs..
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", status);
+ break;
+ }
+
+ StartInterruptUrb(psIntfAdapter);
+
+
+}
+
+int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!psIntfAdapter->psInterruptUrb)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot allocate interrupt urb");
+ return -ENOMEM;
+ }
+ psIntfAdapter->psInterruptUrb->transfer_buffer =
+ psIntfAdapter->ulInterruptData;
+ psIntfAdapter->psInterruptUrb->transfer_buffer_length =
+ sizeof(psIntfAdapter->ulInterruptData);
+
+ psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev,
+ psIntfAdapter->sIntrIn.int_in_endpointAddr);
+
+ usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev,
+ psIntfAdapter->sIntrIn.int_in_pipe,
+ psIntfAdapter->psInterruptUrb->transfer_buffer,
+ psIntfAdapter->psInterruptUrb->transfer_buffer_length,
+ read_int_callback, psIntfAdapter,
+ psIntfAdapter->sIntrIn.int_in_interval);
+
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt Interval: %d\n",
+ psIntfAdapter->sIntrIn.int_in_interval);
+ return 0;
+}
+
+
+INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ INT status = 0;
+
+ if( FALSE == psIntfAdapter->psAdapter->device_removed &&
+ FALSE == psIntfAdapter->psAdapter->bEndPointHalted &&
+ FALSE == psIntfAdapter->bSuspended &&
+ FALSE == psIntfAdapter->bPreparingForBusSuspend &&
+ FALSE == psIntfAdapter->psAdapter->StopAllXaction)
+ {
+ status = usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC);
+ if (status)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot send int urb %d\n", status);
+ if(status == -EPIPE)
+ {
+ psIntfAdapter->psAdapter->bEndPointHalted = TRUE ;
+ wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
+ }
+ }
+ }
+ return status;
+}
+
+/*
+Function: InterfaceEnableInterrupt
+
+Description: This is the hardware specific Function for configuring
+ and enabling the interrupts on the device.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+
+
+Return: BCM_STATUS_SUCCESS - If configuring the interrupts was successful.
+ Other - If an error occured.
+*/
+
+void InterfaceEnableInterrupt(PMINI_ADAPTER Adapter)
+{
+
+}
+
+/*
+Function: InterfaceDisableInterrupt
+
+Description: This is the hardware specific Function for disabling the interrupts on the device.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+
+
+Return: BCM_STATUS_SUCCESS - If disabling the interrupts was successful.
+ Other - If an error occured.
+*/
+
+void InterfaceDisableInterrupt(PMINI_ADAPTER Adapter)
+{
+
+}
+
+#endif
+
diff --git a/drivers/staging/bcm/InterfaceIsr.h b/drivers/staging/bcm/InterfaceIsr.h
new file mode 100644
index 00000000000..6065a7141bc
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceIsr.h
@@ -0,0 +1,15 @@
+#ifndef _INTERFACE_ISR_H
+#define _INTERFACE_ISR_H
+
+int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter);
+
+
+INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter);
+
+
+VOID InterfaceEnableInterrupt(PMINI_ADAPTER Adapter);
+
+VOID InterfaceDisableInterrupt(PMINI_ADAPTER Adapter);
+
+#endif
+
diff --git a/drivers/staging/bcm/InterfaceMacros.h b/drivers/staging/bcm/InterfaceMacros.h
new file mode 100644
index 00000000000..7001caff9e2
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceMacros.h
@@ -0,0 +1,18 @@
+#ifndef _INTERFACE_MACROS_H
+#define _INTERFACE_MACROS_H
+
+#define BCM_USB_MAX_READ_LENGTH 2048
+
+#define MAXIMUM_USB_TCB 128
+#define MAXIMUM_USB_RCB 128
+
+#define MAX_BUFFERS_PER_QUEUE 256
+
+#define MAX_DATA_BUFFER_SIZE 2048
+
+//Num of Asynchronous reads pending
+#define NUM_RX_DESC 64
+
+#define SYS_CFG 0x0F000C00
+
+#endif
diff --git a/drivers/staging/bcm/InterfaceMisc.c b/drivers/staging/bcm/InterfaceMisc.c
new file mode 100644
index 00000000000..8fc893b37fe
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceMisc.c
@@ -0,0 +1,290 @@
+#include "headers.h"
+
+#ifndef BCM_SHM_INTERFACE
+
+PS_INTERFACE_ADAPTER
+InterfaceAdapterGet(PMINI_ADAPTER psAdapter)
+{
+ if(psAdapter == NULL)
+ {
+ return NULL;
+ }
+ return (PS_INTERFACE_ADAPTER)(psAdapter->pvInterfaceAdapter);
+}
+
+INT
+InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
+ UINT addr,
+ PVOID buff,
+ INT len)
+{
+ int retval = 0;
+ USHORT usRetries = 0 ;
+ if(psIntfAdapter == NULL )
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Interface Adapter is NULL");
+ return -EINVAL ;
+ }
+
+ if(psIntfAdapter->psAdapter->device_removed == TRUE)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Device got removed");
+ return -ENODEV;
+ }
+
+ if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB))
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus");
+ return -EACCES;
+ }
+
+ if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL,"Bus is in suspended states hence RDM not allowed..");
+ return -EACCES;
+ }
+ psIntfAdapter->psAdapter->DeviceAccess = TRUE ;
+ do {
+ retval = usb_control_msg(psIntfAdapter->udev,
+ usb_rcvctrlpipe(psIntfAdapter->udev,0),
+ 0x02,
+ 0xC2,
+ (addr & 0xFFFF),
+ ((addr >> 16) & 0xFFFF),
+ buff,
+ len,
+ 5000);
+
+ usRetries++ ;
+ if(-ENODEV == retval)
+ {
+ psIntfAdapter->psAdapter->device_removed =TRUE;
+ break;
+ }
+
+ }while((retval < 0) && (usRetries < MAX_RDM_WRM_RETIRES ) );
+
+ if(retval < 0)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM failed status :%d, retires :%d", retval,usRetries);
+ psIntfAdapter->psAdapter->DeviceAccess = FALSE ;
+ return retval;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, RDM, DBG_LVL_ALL, "RDM sent %d", retval);
+ psIntfAdapter->psAdapter->DeviceAccess = FALSE ;
+ return STATUS_SUCCESS;
+ }
+}
+
+INT
+InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter,
+ UINT addr,
+ PVOID buff,
+ INT len)
+{
+ int retval = 0;
+ USHORT usRetries = 0 ;
+
+ if(psIntfAdapter == NULL )
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Interface Adapter is NULL");
+ return -EINVAL;
+ }
+ if(psIntfAdapter->psAdapter->device_removed == TRUE)
+ {
+
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0,"Device got removed");
+ return -ENODEV;
+ }
+
+ if((psIntfAdapter->psAdapter->StopAllXaction == TRUE) && (psIntfAdapter->psAdapter->chip_id >= T3LPB))
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Currently Xaction is not allowed on the bus...");
+ return EACCES;
+ }
+
+ if(psIntfAdapter->bSuspended ==TRUE || psIntfAdapter->bPreparingForBusSuspend == TRUE)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL,"Bus is in suspended states hence RDM not allowed..");
+ return -EACCES;
+ }
+ psIntfAdapter->psAdapter->DeviceAccess = TRUE ;
+ do{
+ retval = usb_control_msg(psIntfAdapter->udev,
+ usb_sndctrlpipe(psIntfAdapter->udev,0),
+ 0x01,
+ 0x42,
+ (addr & 0xFFFF),
+ ((addr >> 16) & 0xFFFF),
+ buff,
+ len,
+ 5000);
+
+ usRetries++ ;
+ if(-ENODEV == retval)
+ {
+ psIntfAdapter->psAdapter->device_removed = TRUE ;
+ break;
+ }
+
+ }while((retval < 0) && ( usRetries < MAX_RDM_WRM_RETIRES));
+
+ if(retval < 0)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM failed status :%d, retires :%d", retval, usRetries);
+ psIntfAdapter->psAdapter->DeviceAccess = FALSE ;
+ return retval;
+ }
+ else
+ {
+ psIntfAdapter->psAdapter->DeviceAccess = FALSE ;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, WRM, DBG_LVL_ALL, "WRM sent %d", retval);
+ return STATUS_SUCCESS;
+
+ }
+
+}
+
+INT
+BcmRDM(PVOID arg,
+ UINT addr,
+ PVOID buff,
+ INT len)
+{
+ return InterfaceRDM((PS_INTERFACE_ADAPTER)arg, addr, buff, len);
+}
+
+INT
+BcmWRM(PVOID arg,
+ UINT addr,
+ PVOID buff,
+ INT len)
+{
+ return InterfaceWRM((PS_INTERFACE_ADAPTER)arg, addr, buff, len);
+}
+
+
+
+INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter)
+{
+ PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter);
+ INT status = STATUS_SUCCESS ;
+
+ /*
+ usb_clear_halt - tells device to clear endpoint halt/stall condition
+ @dev: device whose endpoint is halted
+ @pipe: endpoint "pipe" being cleared
+ @ Context: !in_interrupt ()
+
+ usb_clear_halt is the synchrnous call and returns 0 on success else returns with error code.
+ This is used to clear halt conditions for bulk and interrupt endpoints only.
+ Control and isochronous endpoints never halts.
+
+ Any URBs queued for such an endpoint should normally be unlinked by the driver
+ before clearing the halt condition.
+
+ */
+
+ //Killing all the submitted urbs to different end points.
+ Bcm_kill_all_URBs(psIntfAdapter);
+
+
+ //clear the halted/stalled state for every end point
+ status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sIntrIn.int_in_pipe);
+ if(status != STATUS_SUCCESS)
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Interrupt IN end point. :%d ", status);
+
+ status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkIn.bulk_in_pipe);
+ if(status != STATUS_SUCCESS)
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk IN end point. :%d ", status);
+
+ status = usb_clear_halt(psIntfAdapter->udev,psIntfAdapter->sBulkOut.bulk_out_pipe);
+ if(status != STATUS_SUCCESS)
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Unable to Clear Halt of Bulk OUT end point. :%d ", status);
+
+ return status ;
+}
+
+
+VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ struct urb *tempUrb = NULL;
+ UINT i;
+
+ /**
+ * usb_kill_urb - cancel a transfer request and wait for it to finish
+ * @urb: pointer to URB describing a previously submitted request,
+ * returns nothing as it is void returned API.
+ *
+ * This routine cancels an in-progress request. It is guaranteed that
+ * upon return all completion handlers will have finished and the URB
+ * will be totally idle and available for reuse
+
+ * This routine may not be used in an interrupt context (such as a bottom
+ * half or a completion handler), or when holding a spinlock, or in other
+ * situations where the caller can't schedule().
+ *
+ **/
+
+ /* Cancel submitted Interrupt-URB's */
+ if(psIntfAdapter->psInterruptUrb != NULL)
+ {
+ if(psIntfAdapter->psInterruptUrb->status == -EINPROGRESS)
+ usb_kill_urb(psIntfAdapter->psInterruptUrb);
+ }
+
+ /* Cancel All submitted TX URB's */
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cancelling All Submitted TX Urbs \n");
+
+ for(i = 0; i < MAXIMUM_USB_TCB; i++)
+ {
+ tempUrb = psIntfAdapter->asUsbTcb[i].urb;
+ if(tempUrb)
+ {
+ if(tempUrb->status == -EINPROGRESS)
+ usb_kill_urb(tempUrb);
+ }
+ }
+
+
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Cancelling All submitted Rx Urbs \n");
+
+ for(i = 0; i < MAXIMUM_USB_RCB; i++)
+ {
+ tempUrb = psIntfAdapter->asUsbRcb[i].urb;
+ if(tempUrb)
+ {
+ if(tempUrb->status == -EINPROGRESS)
+ usb_kill_urb(tempUrb);
+ }
+ }
+
+
+ atomic_set(&psIntfAdapter->uNumTcbUsed, 0);
+ atomic_set(&psIntfAdapter->uCurrTcb, 0);
+
+ atomic_set(&psIntfAdapter->uNumRcbUsed, 0);
+ atomic_set(&psIntfAdapter->uCurrRcb, 0);
+
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "TCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter->uNumTcbUsed), atomic_read(&psIntfAdapter->uCurrTcb));
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "RCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter->uNumRcbUsed), atomic_read(&psIntfAdapter->uCurrRcb));
+
+}
+
+VOID putUsbSuspend(struct work_struct *work)
+{
+ PS_INTERFACE_ADAPTER psIntfAdapter = NULL ;
+ struct usb_interface *intf = NULL ;
+ psIntfAdapter = container_of(work, S_INTERFACE_ADAPTER,usbSuspendWork);
+ intf=psIntfAdapter->interface ;
+
+ if(psIntfAdapter->bSuspended == FALSE)
+ usb_autopm_put_interface(intf);
+ else
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Interface Resumed Completely\n");
+
+}
+
+#endif
diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h
new file mode 100644
index 00000000000..74c81d45cff
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceMisc.h
@@ -0,0 +1,45 @@
+#ifndef __INTERFACE_MISC_H
+#define __INTERFACE_MISC_H
+
+PS_INTERFACE_ADAPTER
+InterfaceAdapterGet(PMINI_ADAPTER psAdapter);
+
+INT
+InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
+ UINT addr,
+ PVOID buff,
+ INT len);
+
+INT
+InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter,
+ UINT addr,
+ PVOID buff,
+ INT len);
+
+
+int InterfaceFileDownload( PVOID psIntfAdapter,
+ struct file *flp,
+ unsigned int on_chip_loc);
+
+int InterfaceFileReadbackFromChip( PVOID psIntfAdapter,
+ struct file *flp,
+ unsigned int on_chip_loc);
+
+
+int BcmRDM(PVOID arg,
+ UINT addr,
+ PVOID buff,
+ INT len);
+
+int BcmWRM(PVOID arg,
+ UINT addr,
+ PVOID buff,
+ INT len);
+
+INT Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter);
+
+VOID Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter);
+
+#define DISABLE_USB_ZERO_LEN_INT 0x0F011878
+
+#endif // __INTERFACE_MISC_H
diff --git a/drivers/staging/bcm/InterfaceRx.c b/drivers/staging/bcm/InterfaceRx.c
new file mode 100644
index 00000000000..6fee9684f2e
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceRx.c
@@ -0,0 +1,256 @@
+#include "headers.h"
+extern int SearchVcid(PMINI_ADAPTER , unsigned short);
+
+
+static PUSB_RCB
+GetBulkInRcb(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ PUSB_RCB pRcb = NULL;
+ UINT index = 0;
+
+ if((atomic_read(&psIntfAdapter->uNumRcbUsed) < MAXIMUM_USB_RCB) &&
+ (psIntfAdapter->psAdapter->StopAllXaction == FALSE))
+ {
+ index = atomic_read(&psIntfAdapter->uCurrRcb);
+ pRcb = &psIntfAdapter->asUsbRcb[index];
+ pRcb->bUsed = TRUE;
+ pRcb->psIntfAdapter= psIntfAdapter;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Got Rx desc %d used %d",
+ index, atomic_read(&psIntfAdapter->uNumRcbUsed));
+ index = (index + 1) % MAXIMUM_USB_RCB;
+ atomic_set(&psIntfAdapter->uCurrRcb, index);
+ atomic_inc(&psIntfAdapter->uNumRcbUsed);
+ }
+ return pRcb;
+}
+
+/*this is receive call back - when pkt avilable for receive (BULK IN- end point)*/
+static void read_bulk_callback(struct urb *urb)
+{
+ struct sk_buff *skb = NULL;
+ BOOLEAN bHeaderSupressionEnabled = FALSE;
+ int QueueIndex = NO_OF_QUEUES + 1;
+ UINT uiIndex=0;
+ int process_done = 1;
+ //int idleflag = 0 ;
+ PUSB_RCB pRcb = (PUSB_RCB)urb->context;
+ PS_INTERFACE_ADAPTER psIntfAdapter = pRcb->psIntfAdapter;
+ PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter;
+ PLEADER pLeader = urb->transfer_buffer;
+
+
+ #if 0
+ int *puiBuffer = NULL;
+ struct timeval tv;
+ memset(&tv, 0, sizeof(tv));
+ do_gettimeofday(&tv);
+ #endif
+
+ if((Adapter->device_removed == TRUE) ||
+ (TRUE == Adapter->bEndPointHalted) ||
+ (0 == urb->actual_length)
+ )
+ {
+ pRcb->bUsed = FALSE;
+ atomic_dec(&psIntfAdapter->uNumRcbUsed);
+ return;
+ }
+
+ if(urb->status != STATUS_SUCCESS)
+ {
+ if(urb->status == -EPIPE)
+ {
+ Adapter->bEndPointHalted = TRUE ;
+ wake_up(&Adapter->tx_packet_wait_queue);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"Rx URB has got cancelled. status :%d", urb->status);
+ }
+ pRcb->bUsed = FALSE;
+ atomic_dec(&psIntfAdapter->uNumRcbUsed);
+ urb->status = STATUS_SUCCESS ;
+ return ;
+ }
+
+ if(Adapter->bDoSuspend && (Adapter->bPreparingForLowPowerMode))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"device is going in low power mode while PMU option selected..hence rx packet should not be process");
+ return ;
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Read back done len %d\n", pLeader->PLength);
+ if(!pLeader->PLength)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Length 0");
+ atomic_dec(&psIntfAdapter->uNumRcbUsed);
+ return;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "Leader Status:0x%hX, Length:0x%hX, VCID:0x%hX", pLeader->Status,pLeader->PLength,pLeader->Vcid);
+ if(MAX_CNTL_PKT_SIZE < pLeader->PLength)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Corrupted leader length...%d\n",
+ pLeader->PLength);
+ atomic_inc(&Adapter->RxPacketDroppedCount);
+ atomic_add(pLeader->PLength, &Adapter->BadRxByteCount);
+ atomic_dec(&psIntfAdapter->uNumRcbUsed);
+ return;
+ }
+
+ QueueIndex = SearchVcid( Adapter,pLeader->Vcid);
+ if(QueueIndex < NO_OF_QUEUES)
+ {
+ bHeaderSupressionEnabled =
+ Adapter->PackInfo[QueueIndex].bHeaderSuppressionEnabled;
+ bHeaderSupressionEnabled =
+ bHeaderSupressionEnabled & Adapter->bPHSEnabled;
+ }
+
+ skb = dev_alloc_skb (pLeader->PLength + SKB_RESERVE_PHS_BYTES + SKB_RESERVE_ETHERNET_HEADER);//2 //2 for allignment
+ if(!skb)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "NO SKBUFF!!! Dropping the Packet");
+ atomic_dec(&psIntfAdapter->uNumRcbUsed);
+ return;
+ }
+ /* If it is a control Packet, then call handle_bcm_packet ()*/
+ if((ntohs(pLeader->Vcid) == VCID_CONTROL_PACKET) ||
+ (!(pLeader->Status >= 0x20 && pLeader->Status <= 0x3F)))
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_CTRL, DBG_LVL_ALL, "Recived control pkt...");
+ *(PUSHORT)skb->data = pLeader->Status;
+ memcpy(skb->data+sizeof(USHORT), urb->transfer_buffer +
+ (sizeof(LEADER)), pLeader->PLength);
+ skb->len = pLeader->PLength + sizeof(USHORT);
+
+ spin_lock(&Adapter->control_queue_lock);
+ ENQUEUEPACKET(Adapter->RxControlHead,Adapter->RxControlTail,skb);
+ spin_unlock(&Adapter->control_queue_lock);
+
+ atomic_inc(&Adapter->cntrlpktCnt);
+ wake_up(&Adapter->process_rx_cntrlpkt);
+ }
+ else
+ {
+ /*
+ * Data Packet, Format a proper Ethernet Header
+ * and give it to the stack
+ */
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Recived Data pkt...");
+ skb_reserve(skb, 2 + SKB_RESERVE_PHS_BYTES);
+ memcpy(skb->data+ETH_HLEN, (PUCHAR)urb->transfer_buffer + sizeof(LEADER), pLeader->PLength);
+ skb->dev = Adapter->dev;
+
+ /* currently skb->len has extra ETH_HLEN bytes in the beginning */
+ skb_put (skb, pLeader->PLength + ETH_HLEN);
+ Adapter->PackInfo[QueueIndex].uiTotalRxBytes+=pLeader->PLength;
+ Adapter->PackInfo[QueueIndex].uiThisPeriodRxBytes+= pLeader->PLength;
+ atomic_add(pLeader->PLength, &Adapter->GoodRxByteCount);
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "Recived Data pkt of len :0x%X", pLeader->PLength);
+
+ if(Adapter->if_up)
+ {
+ /* Moving ahead by ETH_HLEN to the data ptr as received from FW */
+ skb_pull(skb, ETH_HLEN);
+ PHSRecieve(Adapter, pLeader->Vcid, skb, &skb->len,
+ NULL,bHeaderSupressionEnabled);
+
+ if(!Adapter->PackInfo[QueueIndex].bEthCSSupport)
+ {
+ skb_push(skb, ETH_HLEN);
+
+ memcpy(skb->data, skb->dev->dev_addr, 6);
+ memcpy(skb->data+6, skb->dev->dev_addr, 6);
+ (*(skb->data+11))++;
+ *(skb->data+12) = 0x08;
+ *(skb->data+13) = 0x00;
+ pLeader->PLength+=ETH_HLEN;
+ }
+
+ skb->protocol = eth_type_trans(skb, Adapter->dev);
+ process_done = netif_rx(skb);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DATA, DBG_LVL_ALL, "i/f not up hance freeing SKB...");
+ bcm_kfree_skb(skb);
+ }
+ atomic_inc(&Adapter->GoodRxPktCount);
+ for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++)
+ {
+ if((pLeader->PLength <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1))
+ && (pLeader->PLength > MIBS_PKTSIZEHIST_RANGE*(uiIndex)))
+ Adapter->aRxPktSizeHist[uiIndex]++;
+ }
+ }
+ Adapter->PrevNumRecvDescs++;
+ pRcb->bUsed = FALSE;
+ atomic_dec(&psIntfAdapter->uNumRcbUsed);
+}
+
+static int ReceiveRcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_RCB pRcb)
+{
+ struct urb *urb = pRcb->urb;
+ int retval = 0;
+
+ usb_fill_bulk_urb(urb, psIntfAdapter->udev, usb_rcvbulkpipe(
+ psIntfAdapter->udev, psIntfAdapter->sBulkIn.bulk_in_endpointAddr),
+ urb->transfer_buffer, BCM_USB_MAX_READ_LENGTH, read_bulk_callback,
+ pRcb);
+ if(FALSE == psIntfAdapter->psAdapter->device_removed &&
+ FALSE == psIntfAdapter->psAdapter->bEndPointHalted &&
+ FALSE == psIntfAdapter->bSuspended &&
+ FALSE == psIntfAdapter->bPreparingForBusSuspend)
+ {
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+ if (retval)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "failed submitting read urb, error %d", retval);
+ //if this return value is because of pipe halt. need to clear this.
+ if(retval == -EPIPE)
+ {
+ psIntfAdapter->psAdapter->bEndPointHalted = TRUE ;
+ wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
+ }
+
+ }
+ }
+ return retval;
+}
+
+/*
+Function: InterfaceRx
+
+Description: This is the hardware specific Function for Recieveing
+ data packet/control packets from the device.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+
+
+
+Return: TRUE - If Rx was successful.
+ Other - If an error occured.
+*/
+
+BOOLEAN InterfaceRx (PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ USHORT RxDescCount = NUM_RX_DESC - atomic_read(&psIntfAdapter->uNumRcbUsed);
+ PUSB_RCB pRcb = NULL;
+
+// RxDescCount = psIntfAdapter->psAdapter->CurrNumRecvDescs -
+// psIntfAdapter->psAdapter->PrevNumRecvDescs;
+ while(RxDescCount)
+ {
+ pRcb = GetBulkInRcb(psIntfAdapter);
+ if(pRcb == NULL)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Unable to get Rcb pointer");
+ return FALSE;
+ }
+ //atomic_inc(&psIntfAdapter->uNumRcbUsed);
+ ReceiveRcb(psIntfAdapter, pRcb);
+ RxDescCount--;
+ }
+ return TRUE;
+}
+
diff --git a/drivers/staging/bcm/InterfaceRx.h b/drivers/staging/bcm/InterfaceRx.h
new file mode 100644
index 00000000000..96e81a1d37b
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceRx.h
@@ -0,0 +1,7 @@
+#ifndef _INTERFACE_RX_H
+#define _INTERFACE_RX_H
+
+BOOLEAN InterfaceRx(PS_INTERFACE_ADAPTER Adapter);
+
+#endif
+
diff --git a/drivers/staging/bcm/InterfaceTx.c b/drivers/staging/bcm/InterfaceTx.c
new file mode 100644
index 00000000000..771f7b34d2e
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceTx.c
@@ -0,0 +1,259 @@
+#include "headers.h"
+
+#ifndef BCM_SHM_INTERFACE
+
+/*
+Function: InterfaceTxDataPacket
+
+Description: This is the hardware specific Function for Transmitting
+ data packet to the device.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+ PVOID Packet - Packet Containing the data to be transmitted
+ USHORT usVcid - VCID on which data packet is to be sent
+
+
+Return: BCM_STATUS_SUCCESS - If Tx was successful.
+ Other - If an error occured.
+*/
+
+ULONG InterfaceTxDataPacket(PMINI_ADAPTER Adapter,PVOID Packet,USHORT usVcid)
+{
+ ULONG Status = 0;
+ return Status;
+}
+
+/*
+Function: InterfaceTxControlPacket
+
+Description: This is the hardware specific Function for Transmitting
+ control packet to the device.
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+ PVOID pvBuffer - Buffer containg control packet
+ UINT uiBufferLength - Buffer Length
+
+Return: BCM_STATUS_SUCCESS - If control packet transmit was successful.
+ Other - If an error occured.
+*/
+
+ULONG InterfaceTxControlPacket(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT uiBufferLength)
+{
+ ULONG Status = 0;
+
+
+
+ return Status;
+}
+/*this is transmit call-back(BULK OUT)*/
+static void write_bulk_callback(struct urb *urb/*, struct pt_regs *regs*/)
+{
+ PUSB_TCB pTcb= (PUSB_TCB)urb->context;
+ PS_INTERFACE_ADAPTER psIntfAdapter = pTcb->psIntfAdapter;
+ CONTROL_MESSAGE *pControlMsg = (CONTROL_MESSAGE *)urb->transfer_buffer;
+ PMINI_ADAPTER psAdapter = psIntfAdapter->psAdapter ;
+ BOOLEAN bpowerDownMsg = FALSE ;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+#if 0
+ struct timeval tv;
+ UINT time_ms = 0;
+#endif
+ if(urb->status != STATUS_SUCCESS)
+ {
+ if(urb->status == -EPIPE)
+ {
+ psIntfAdapter->psAdapter->bEndPointHalted = TRUE ;
+ wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Tx URB has got cancelled. status :%d", urb->status);
+ }
+ }
+
+ pTcb->bUsed = FALSE;
+ atomic_dec(&psIntfAdapter->uNumTcbUsed);
+
+
+
+ if(TRUE == psAdapter->bPreparingForLowPowerMode)
+ {
+ #if 0
+ do_gettimeofday(&tv);
+ time_ms = tv.tv_sec *1000 + tv.tv_usec/1000;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, " %s Idle Mode ACK_Sent got from device at time :0x%x", __FUNCTION__, time_ms);
+ #endif
+
+ if(((pControlMsg->szData[0] == GO_TO_IDLE_MODE_PAYLOAD) &&
+ (pControlMsg->szData[1] == TARGET_CAN_GO_TO_IDLE_MODE)))
+
+ {
+ bpowerDownMsg = TRUE ;
+ //This covers the bus err while Idle Request msg sent down.
+ if(urb->status != STATUS_SUCCESS)
+ {
+ psAdapter->bPreparingForLowPowerMode = FALSE ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Idle Mode Request msg failed to reach to Modem");
+ //Signalling the cntrl pkt path in Ioctl
+ wake_up(&psAdapter->lowpower_mode_wait_queue);
+ StartInterruptUrb(psIntfAdapter);
+ goto err_exit;
+ }
+
+ if(psAdapter->bDoSuspend == FALSE)
+ {
+ psAdapter->IdleMode = TRUE;
+ //since going in Idle mode completed hence making this var false;
+ psAdapter->bPreparingForLowPowerMode = FALSE ;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Host Entered in Idle Mode State...");
+ //Signalling the cntrl pkt path in Ioctl
+ wake_up(&psAdapter->lowpower_mode_wait_queue);
+ }
+
+ }
+ else if((pControlMsg->Leader.Status == LINK_UP_CONTROL_REQ) &&
+ (pControlMsg->szData[0] == LINK_UP_ACK) &&
+ (pControlMsg->szData[1] == LINK_SHUTDOWN_REQ_FROM_FIRMWARE) &&
+ (pControlMsg->szData[2] == SHUTDOWN_ACK_FROM_DRIVER))
+ {
+ //This covers the bus err while shutdown Request msg sent down.
+ if(urb->status != STATUS_SUCCESS)
+ {
+ psAdapter->bPreparingForLowPowerMode = FALSE ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Shutdown Request Msg failed to reach to Modem");
+ //Signalling the cntrl pkt path in Ioctl
+ wake_up(&psAdapter->lowpower_mode_wait_queue);
+ StartInterruptUrb(psIntfAdapter);
+ goto err_exit;
+ }
+
+ bpowerDownMsg = TRUE ;
+ if(psAdapter->bDoSuspend == FALSE)
+ {
+ psAdapter->bShutStatus = TRUE;
+ //since going in shutdown mode completed hence making this var false;
+ psAdapter->bPreparingForLowPowerMode = FALSE ;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Host Entered in shutdown Mode State...");
+ //Signalling the cntrl pkt path in Ioctl
+ wake_up(&psAdapter->lowpower_mode_wait_queue);
+ }
+ }
+
+ if(psAdapter->bDoSuspend && bpowerDownMsg)
+ {
+ //issuing bus suspend request
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"Issuing the Bus suspend request to USB stack");
+ psIntfAdapter->bPreparingForBusSuspend = TRUE;
+ schedule_work(&psIntfAdapter->usbSuspendWork);
+
+ }
+
+ }
+
+err_exit :
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
+ usb_buffer_free(urb->dev, urb->transfer_buffer_length,
+ urb->transfer_buffer, urb->transfer_dma);
+#else
+ usb_free_coherent(urb->dev, urb->transfer_buffer_length,
+ urb->transfer_buffer, urb->transfer_dma);
+#endif
+}
+
+
+static __inline PUSB_TCB GetBulkOutTcb(PS_INTERFACE_ADAPTER psIntfAdapter)
+{
+ PUSB_TCB pTcb = NULL;
+ UINT index = 0;
+
+ if((atomic_read(&psIntfAdapter->uNumTcbUsed) < MAXIMUM_USB_TCB) &&
+ (psIntfAdapter->psAdapter->StopAllXaction ==FALSE))
+ {
+ index = atomic_read(&psIntfAdapter->uCurrTcb);
+ pTcb = &psIntfAdapter->asUsbTcb[index];
+ pTcb->bUsed = TRUE;
+ pTcb->psIntfAdapter= psIntfAdapter;
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Got Tx desc %d used %d",
+ index, atomic_read(&psIntfAdapter->uNumTcbUsed));
+ index = (index + 1) % MAXIMUM_USB_TCB;
+ atomic_set(&psIntfAdapter->uCurrTcb, index);
+ atomic_inc(&psIntfAdapter->uNumTcbUsed);
+ }
+ return pTcb;
+}
+
+static __inline int TransmitTcb(PS_INTERFACE_ADAPTER psIntfAdapter, PUSB_TCB pTcb, PVOID data, int len)
+{
+
+ struct urb *urb = pTcb->urb;
+ int retval = 0;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
+ urb->transfer_buffer = usb_buffer_alloc(psIntfAdapter->udev, len,
+ GFP_ATOMIC, &urb->transfer_dma);
+#else
+ urb->transfer_buffer = usb_alloc_coherent(psIntfAdapter->udev, len,
+ GFP_ATOMIC, &urb->transfer_dma);
+#endif
+
+ if (!urb->transfer_buffer)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "Error allocating memory\n");
+ return -ENOMEM;
+ }
+ memcpy(urb->transfer_buffer, data, len);
+ urb->transfer_buffer_length = len;
+
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Sending Bulk out packet\n");
+ //For T3B,INT OUT end point will be used as bulk out end point
+ if((psIntfAdapter->psAdapter->chip_id == T3B) && (psIntfAdapter->bHighSpeedDevice == TRUE))
+ {
+ usb_fill_int_urb(urb, psIntfAdapter->udev,
+ psIntfAdapter->sBulkOut.bulk_out_pipe,
+ urb->transfer_buffer, len, write_bulk_callback, pTcb,
+ psIntfAdapter->sBulkOut.int_out_interval);
+ }
+ else
+ {
+ usb_fill_bulk_urb(urb, psIntfAdapter->udev,
+ psIntfAdapter->sBulkOut.bulk_out_pipe,
+ urb->transfer_buffer, len, write_bulk_callback, pTcb);
+ }
+ urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; /* For DMA transfer */
+
+ if(FALSE == psIntfAdapter->psAdapter->device_removed &&
+ FALSE == psIntfAdapter->psAdapter->bEndPointHalted &&
+ FALSE == psIntfAdapter->bSuspended &&
+ FALSE == psIntfAdapter->bPreparingForBusSuspend)
+ {
+ retval = usb_submit_urb(urb, GFP_ATOMIC);
+ if (retval)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "failed submitting write urb, error %d", retval);
+ if(retval == -EPIPE)
+ {
+ psIntfAdapter->psAdapter->bEndPointHalted = TRUE ;
+ wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
+ }
+ }
+ }
+ return retval;
+}
+
+int InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len)
+{
+ PUSB_TCB pTcb= NULL;
+
+ PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)arg;
+ pTcb= GetBulkOutTcb(psIntfAdapter);
+ if(pTcb == NULL)
+ {
+ BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_PRINTK, 0, 0, "No URB to transmit packet, dropping packet");
+ return -EFAULT;
+ }
+ return TransmitTcb(psIntfAdapter, pTcb, data, len);
+}
+
+#endif
+
diff --git a/drivers/staging/bcm/InterfaceTx.h b/drivers/staging/bcm/InterfaceTx.h
new file mode 100644
index 00000000000..053f631e204
--- /dev/null
+++ b/drivers/staging/bcm/InterfaceTx.h
@@ -0,0 +1,13 @@
+#ifndef _INTERFACE_TX_H
+#define _INTERFACE_TX_H
+
+INT InterfaceTransmitPacket(PVOID arg, PVOID data, UINT len);
+
+
+ULONG InterfaceTxDataPacket(PMINI_ADAPTER Adapter,PVOID Packet,USHORT usVcid);
+
+ULONG InterfaceTxControlPacket(PMINI_ADAPTER Adapter,PVOID pvBuffer,UINT uiBufferLength);
+
+
+#endif
+
diff --git a/drivers/staging/bcm/Interfacemain.h b/drivers/staging/bcm/Interfacemain.h
new file mode 100644
index 00000000000..e0db563c5e0
--- /dev/null
+++ b/drivers/staging/bcm/Interfacemain.h
@@ -0,0 +1,10 @@
+#ifndef _MAIN_
+#define _MAIN_
+#if 0
+typedef struct _MINI_ADAPTER
+{
+ S_INTERFACE_ADAPTER stInterfaceAdapter;
+}MINI_ADAPTER,*PMINI_ADAPTER;
+
+#endif
+#endif
diff --git a/drivers/staging/bcm/Ioctl.h b/drivers/staging/bcm/Ioctl.h
new file mode 100644
index 00000000000..2651fc2432c
--- /dev/null
+++ b/drivers/staging/bcm/Ioctl.h
@@ -0,0 +1,360 @@
+#ifndef _IOCTL_H_
+#define _IOCTL_H_
+
+typedef struct rdmbuffer
+{
+ ULONG Register;
+ ULONG Length;
+}__attribute__((packed)) RDM_BUFFER, *PRDM_BUFFER;
+
+
+typedef struct wrmbuffer
+{
+ ULONG Register;
+ ULONG Length;
+ UCHAR Data[4];
+}__attribute__((packed)) WRM_BUFFER, *PWRM_BUFFER;
+
+
+typedef struct ioctlbuffer
+{
+ PVOID InputBuffer;
+ ULONG InputLength;
+ PVOID OutputBuffer;
+ ULONG OutputLength;
+}__attribute__((packed)) IOCTL_BUFFER, *PIOCTL_BUFFER;
+
+typedef struct stGPIOInfo
+{
+ UINT uiGpioNumber ; /* valid numbers 0-15 */
+ UINT uiGpioValue; /* 1 set ; 0 not set */
+}__attribute__((packed))GPIO_INFO,*PGPIO_INFO;
+typedef struct stUserThreadReq
+{
+ //0->Inactivate LED thread.
+ //1->Activate the LED thread
+ UINT ThreadState;
+}__attribute__((packed))USER_THREAD_REQ,*PUSER_THREAD_REQ;
+#define LED_THREAD_ACTIVATION_REQ 1
+
+
+////********** ioctl codes ***********////
+
+#define BCM_IOCTL 'k'
+
+//1.Control code for CONTROL MESSAGES
+
+#define IOCTL_SEND_CONTROL_MESSAGE _IOW(BCM_IOCTL, 0x801,int)
+
+//2.Control code to write a particular value to a particular register
+#define IOCTL_BCM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x802, int) //
+
+//3.
+#define IOCTL_BCM_REGISTER_READ _IOR(BCM_IOCTL, 0x803, int) //
+
+//4.Control code to write x number of bytes to common memory
+//starting from address y
+#define IOCTL_BCM_COMMON_MEMORY_WRITE _IOW(BCM_IOCTL, 0x804, int)//
+
+//5.Control code to write x number of bytes to common memory
+//starting from address y
+#define IOCTL_BCM_COMMON_MEMORY_READ _IOR(BCM_IOCTL, 0x805, int)//
+
+//6.Control code for CONTROL MESSAGES
+#define IOCTL_GET_CONTROL_MESSAGE _IOR(BCM_IOCTL, 0x806, int)//
+
+//7.Control code for FIRMWARE DOWNLOAD
+#define IOCTL_BCM_FIRMWARE_DOWNLOAD _IOW(BCM_IOCTL, 0x807, int)//
+
+#define IOCTL_BCM_SET_SEND_VCID _IOW(BCM_IOCTL, 0x808, int)
+
+//9.Control code for TRANSFER MODE SWITCHING
+#define IOCTL_BCM_SWITCH_TRANSFER_MODE _IOW(BCM_IOCTL, 0x809, int)
+//10.Control code for LINK UP
+#define IOCTL_LINK_REQ _IOW(BCM_IOCTL, 0x80A, int)
+
+//11.Control code for RSSI Level Request
+#define IOCTL_RSSI_LEVEL_REQ _IOW(BCM_IOCTL, 0x80B, int)
+//12.Control code for IDLE MODE CONTROL
+#define IOCTL_IDLE_REQ _IOW(BCM_IOCTL, 0x80C, int)
+//13.Control code for SS/BS info
+#define IOCTL_SS_INFO_REQ _IOW(BCM_IOCTL, 0x80D, int)
+
+#define IOCTL_GET_STATISTICS_POINTER _IOW(BCM_IOCTL, 0x80E, int)
+
+#define IOCTL_CM_REQUEST _IOW(BCM_IOCTL, 0x80F, int)
+
+#define IOCTL_INIT_PARAM_REQ _IOW(BCM_IOCTL, 0x810, int)
+
+#define IOCTL_MAC_ADDR_REQ _IOW(BCM_IOCTL, 0x811, int)
+
+#define IOCTL_MAC_ADDR_RESP _IOWR(BCM_IOCTL, 0x812, int)
+
+#define IOCTL_CLASSIFICATION_RULE _IOW(BCM_IOCTL, 0x813, char)
+
+#define IOCTL_CLOSE_NOTIFICATION _IO(BCM_IOCTL, 0x814)
+
+#define IOCTL_LINK_UP _IO(BCM_IOCTL, 0x815)
+
+#define IOCTL_LINK_DOWN _IO(BCM_IOCTL, 0x816, IOCTL_BUFFER)
+
+#define IOCTL_CHIP_RESET _IO(BCM_IOCTL, 0x816)
+
+#define IOCTL_CINR_LEVEL_REQ _IOW(BCM_IOCTL, 0x817, char)
+
+#define IOCTL_WTM_CONTROL_REQ _IOW(BCM_IOCTL, 0x817,char)
+
+#define IOCTL_BE_BUCKET_SIZE _IOW(BCM_IOCTL, 0x818, unsigned long)
+
+#define IOCTL_RTPS_BUCKET_SIZE _IOW(BCM_IOCTL, 0x819, unsigned long)
+
+#define IOCTL_QOS_THRESHOLD _IOW(BCM_IOCTL, 0x820, unsigned long)
+
+#define IOCTL_DUMP_PACKET_INFO _IO(BCM_IOCTL, 0x821)
+
+#define IOCTL_GET_PACK_INFO _IOR(BCM_IOCTL, 0x823, int)
+
+#define IOCTL_BCM_GET_DRIVER_VERSION _IOR(BCM_IOCTL, 0x829, int)
+
+#define IOCTL_BCM_GET_CURRENT_STATUS _IOW(BCM_IOCTL, 0x828, int)
+
+#define IOCTL_BCM_GPIO_SET_REQUEST _IOW(BCM_IOCTL, 0x82A, int)
+
+#define IOCTL_BCM_GPIO_STATUS_REQUEST _IOW(BCM_IOCTL, 0x82b, int)
+
+#define IOCTL_BCM_GET_DSX_INDICATION _IOR(BCM_IOCTL, 0x854, int)
+
+#define IOCTL_BCM_BUFFER_DOWNLOAD_START _IOW(BCM_IOCTL, 0x855, int)
+
+#define IOCTL_BCM_BUFFER_DOWNLOAD _IOW(BCM_IOCTL, 0x856, int)
+
+#define IOCTL_BCM_BUFFER_DOWNLOAD_STOP _IOW(BCM_IOCTL, 0x857, int)
+
+#define IOCTL_BCM_REGISTER_WRITE_PRIVATE _IOW(BCM_IOCTL, 0x826, char)
+
+#define IOCTL_BCM_REGISTER_READ_PRIVATE _IOW(BCM_IOCTL, 0x827, char)
+
+#define IOCTL_BCM_SET_DEBUG _IOW(BCM_IOCTL, 0x824, IOCTL_BUFFER)
+
+#define IOCTL_BCM_EEPROM_REGISTER_WRITE _IOW(BCM_IOCTL, 0x858, int)
+
+#define IOCTL_BCM_EEPROM_REGISTER_READ _IOR(BCM_IOCTL, 0x859, int)
+
+#define IOCTL_BCM_WAKE_UP_DEVICE_FROM_IDLE _IOR(BCM_IOCTL, 0x860, int)
+
+#define IOCTL_BCM_SET_MAC_TRACING _IOW(BCM_IOCTL, 0x82c, int)
+
+#define IOCTL_BCM_GET_HOST_MIBS _IOW(BCM_IOCTL, 0x853, int)
+
+#define IOCTL_BCM_NVM_READ _IOR(BCM_IOCTL, 0x861, int)
+
+#define IOCTL_BCM_NVM_WRITE _IOW(BCM_IOCTL, 0x862, int)
+
+#define IOCTL_BCM_GET_NVM_SIZE _IOR(BCM_IOCTL, 0x863, int)
+
+#define IOCTL_BCM_CAL_INIT _IOR(BCM_IOCTL, 0x864, int)
+
+#define IOCTL_BCM_BULK_WRM _IOW(BCM_IOCTL, 0x90B, int)
+
+#define IOCTL_BCM_FLASH2X_SECTION_READ _IOR(BCM_IOCTL, 0x865, int)
+
+#define IOCTL_BCM_FLASH2X_SECTION_WRITE _IOW(BCM_IOCTL, 0x866, int)
+
+#define IOCTL_BCM_GET_FLASH2X_SECTION_BITMAP _IOR(BCM_IOCTL,0x867, int)
+
+#define IOCTL_BCM_SET_ACTIVE_SECTION _IOW(BCM_IOCTL,0x868, int)
+
+#define IOCTL_BCM_IDENTIFY_ACTIVE_SECTION _IO(BCM_IOCTL,0x869)
+
+#define IOCTL_BCM_COPY_SECTION _IOW(BCM_IOCTL, 0x870,int)
+
+#define IOCTL_BCM_GET_FLASH_CS_INFO _IOR(BCM_IOCTL, 0x871, int)
+
+#define IOCTL_BCM_SELECT_DSD _IOW(BCM_IOCTL, 0x872, int)
+
+#define IOCTL_BCM_NVM_RAW_READ _IOR(BCM_IOCTL, 0x875, int)
+
+#define IOCTL_BCM_CNTRLMSG_MASK _IOW(BCM_IOCTL, 0x874, int)
+
+#define IOCTL_BCM_GET_DEVICE_DRIVER_INFO _IOR(BCM_IOCTL, 0x877, int)
+
+#define IOCTL_BCM_TIME_SINCE_NET_ENTRY _IOR(BCM_IOCTL, 0x876, int)
+
+#define BCM_LED_THREAD_STATE_CHANGE_REQ _IOW(BCM_IOCTL, 0x878, int)
+
+#define IOCTL_BCM_GPIO_MULTI_REQUEST _IOW(BCM_IOCTL, 0x82D, IOCTL_BUFFER)
+#define IOCTL_BCM_GPIO_MODE_REQUEST _IOW(BCM_IOCTL, 0x82E, IOCTL_BUFFER)
+
+
+
+typedef enum _BCM_INTERFACE_TYPE
+{
+ BCM_MII,
+ BCM_CARDBUS,
+ BCM_USB,
+ BCM_SDIO,
+ BCM_PCMCIA
+}BCM_INTERFACE_TYPE;
+
+typedef struct _DEVICE_DRIVER_INFO
+{
+ NVM_TYPE u32NVMType;
+ UINT MaxRDMBufferSize;
+ BCM_INTERFACE_TYPE u32InterfaceType;
+ UINT u32DSDStartOffset;
+ UINT u32RxAlignmentCorrection;
+ UINT u32Reserved[10];
+} DEVICE_DRIVER_INFO;
+
+typedef struct _NVM_READWRITE
+{
+
+ void *pBuffer;
+// Data to be written from|read to. Memory should be allocated by the caller.
+
+ uint32_t uiOffset;
+// offset at which data should be written to or read from.
+
+ uint32_t uiNumBytes;
+// No. of bytes to be written or read.
+
+ bool bVerify;
+// Applicable only for write. If set verification of written data will be done.
+
+} NVM_READWRITE,*PNVM_READWRITE;
+typedef struct bulkwrmbuffer
+{
+ ULONG Register;
+ ULONG SwapEndian;
+ ULONG Values[1];
+
+}BULKWRM_BUFFER,*PBULKWRM_BUFFER;
+
+
+/***********Structure used for FlashMap2.x *******************************/
+
+/*
+* These are Sction present inside the Flash.
+* There is sectional RD/WR for flash Map 2.x.
+* hence these section will be used in read/write API.
+*/
+
+typedef enum _FLASH2X_SECTION_VAL
+{
+ NO_SECTION_VAL = 0, //no section is choosen when absolute offset is given for RD/WR
+ ISO_IMAGE1,
+ ISO_IMAGE2,
+ DSD0,
+ DSD1,
+ DSD2,
+ VSA0,
+ VSA1,
+ VSA2,
+ SCSI,
+ CONTROL_SECTION,
+ ISO_IMAGE1_PART2,
+ ISO_IMAGE1_PART3,
+ ISO_IMAGE2_PART2,
+ ISO_IMAGE2_PART3,
+ TOTAL_SECTIONS
+}FLASH2X_SECTION_VAL;
+
+/*
+* Structure used for READ/WRITE Flash Map2.x
+*/
+typedef struct _FLASH2X_READWRITE
+{
+
+ FLASH2X_SECTION_VAL Section; //which section has to be read/written
+ B_UINT32 offset; //Offset within Section.
+ B_UINT32 numOfBytes; //NOB from the offset
+ B_UINT32 bVerify;
+ PVOID pDataBuff; //Buffer for reading/writing
+
+}FLASH2X_READWRITE, *PFLASH2X_READWRITE;
+/*
+* This structure is used for coping one section to other.
+* there are two ways to copy one section to other.
+* it NOB =0, complete section will be copied on to other.
+* if NOB !=0, only NOB will be copied from the given offset.
+*/
+
+typedef struct _FLASH2X_COPY_SECTION
+{
+ //Src Section from which Data has to be copied to DstSection
+ FLASH2X_SECTION_VAL SrcSection;
+
+ //Destination Section from where Data has to be coppied.
+ FLASH2X_SECTION_VAL DstSection;
+
+ //Offset within Section. if NOB =0 it will be ignored and data will be coped from offset 0.
+ B_UINT32 offset;
+
+ //NOB from the offset. if NOB = 0 complete src section will be copied to Destination section.
+ B_UINT32 numOfBytes;
+} FLASH2X_COPY_SECTION, *PFLASH2X_COPY_SECTION;
+
+
+typedef enum _SECTION_TYPE
+{
+ ISO = 0,
+ VSA = 1,
+ DSD = 2
+} SECTION_TYPE, *PSECTION_TYPE;
+
+/*
+* This section provide the complete bitmap of the Flash.
+* using this map lib/APP will isssue read/write command.
+ Fields are defined as :
+ Bit [0] = section is present //1:present, 0: Not present
+* Bit [1] = section is valid //1: valid, 0: not valid
+* Bit [2] = Section is R/W //0: RW, 1: RO
+* Bit [3] = Section is Active or not 1 means Active, 0->inactive
+* Bit [7...3] = Reserved
+*/
+
+typedef struct _FLASH2X_BITMAP
+{
+ UCHAR ISO_IMAGE1;
+ UCHAR ISO_IMAGE2;
+ UCHAR DSD0;
+ UCHAR DSD1;
+ UCHAR DSD2;
+ UCHAR VSA0;
+ UCHAR VSA1;
+ UCHAR VSA2;
+ UCHAR SCSI;
+ UCHAR CONTROL_SECTION;
+ //Reserved for future use
+ UCHAR Reserved0;
+ UCHAR Reserved1;
+ UCHAR Reserved2;
+}FLASH2X_BITMAP, *PFLASH2X_BITMAP;
+
+//for net entry time check
+typedef struct _ST_TIME_ELAPSED_
+{
+ ULONG64 ul64TimeElapsedSinceNetEntry;
+ UINT32 uiReserved[4]; //By chance if required for future proofing
+}ST_TIME_ELAPSED,*PST_TIME_ELAPSED;
+
+enum {
+ WIMAX_IDX=0, /*To access WiMAX chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE*/
+ HOST_IDX, /*To access Host chip GPIO's for GPIO_MULTI_INFO or GPIO_MULTI_MODE*/
+ MAX_IDX
+};
+typedef struct stGPIOMultiInfo
+{
+ UINT uiGPIOCommand; /* 1 for set and 0 for get*/
+ UINT uiGPIOMask; /* set the correspondig bit to 1 to access GPIO*/
+ UINT uiGPIOValue; /* 0 or 1; value to be set when command is 1.*/
+}__attribute__((packed))GPIO_MULTI_INFO , *PGPIO_MULTI_INFO;
+
+typedef struct stGPIOMultiMode
+{
+ UINT uiGPIOMode; /* 1 for OUT mode, 0 for IN mode*/
+ UINT uiGPIOMask; /* GPIO mask to set mode*/
+}__attribute__((packed))GPIO_MULTI_MODE, *PGPIO_MULTI_MODE;
+
+
+#endif
diff --git a/drivers/staging/bcm/Kconfig b/drivers/staging/bcm/Kconfig
new file mode 100644
index 00000000000..96adb1026c4
--- /dev/null
+++ b/drivers/staging/bcm/Kconfig
@@ -0,0 +1,7 @@
+config BCM_WIMAX
+ tristate "Beceem BCS200/BCS220-3 and BCSM250 wimax support"
+ depends on USB && NET && EXPERIMENTAL
+ default N
+ help
+ This is an experimental driver for the Beceem WIMAX chipset used
+ by Sprint 4G.
diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c
new file mode 100644
index 00000000000..1875c828901
--- /dev/null
+++ b/drivers/staging/bcm/LeakyBucket.c
@@ -0,0 +1,399 @@
+/**********************************************************************
+* LEAKYBUCKET.C
+* This file contains the routines related to Leaky Bucket Algorithm.
+***********************************************************************/
+#include "headers.h"
+
+/*********************************************************************
+* Function - UpdateTokenCount()
+*
+* Description - This function calculates the token count for each
+* channel and updates the same in Adapter strucuture.
+*
+* Parameters - Adapter: Pointer to the Adapter structure.
+*
+* Returns - None
+**********************************************************************/
+
+VOID UpdateTokenCount(register PMINI_ADAPTER Adapter)
+{
+ ULONG liCurrentTime;
+ INT i = 0;
+ struct timeval tv;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "=====>\n");
+ if(NULL == Adapter)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Adapter found NULL!\n");
+ return;
+ }
+
+ do_gettimeofday(&tv);
+ for(i = 0; i < NO_OF_QUEUES; i++)
+ {
+ if(TRUE == Adapter->PackInfo[i].bValid &&
+ (1 == Adapter->PackInfo[i].ucDirection))
+ {
+ liCurrentTime = ((tv.tv_sec-
+ Adapter->PackInfo[i].stLastUpdateTokenAt.tv_sec)*1000 +
+ (tv.tv_usec-Adapter->PackInfo[i].stLastUpdateTokenAt.tv_usec)/
+ 1000);
+ if(0!=liCurrentTime)
+ {
+ Adapter->PackInfo[i].uiCurrentTokenCount += (ULONG)
+ ((Adapter->PackInfo[i].uiMaxAllowedRate) *
+ ((ULONG)((liCurrentTime)))/1000);
+ memcpy(&Adapter->PackInfo[i].stLastUpdateTokenAt,
+ &tv, sizeof(struct timeval));
+ Adapter->PackInfo[i].liLastUpdateTokenAt = liCurrentTime;
+ if((Adapter->PackInfo[i].uiCurrentTokenCount) >=
+ Adapter->PackInfo[i].uiMaxBucketSize)
+ {
+ Adapter->PackInfo[i].uiCurrentTokenCount =
+ Adapter->PackInfo[i].uiMaxBucketSize;
+ }
+ }
+ }
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "<=====\n");
+ return;
+
+}
+
+
+/*********************************************************************
+* Function - IsPacketAllowedForFlow()
+*
+* Description - This function checks whether the given packet from the
+* specified queue can be allowed for transmission by
+* checking the token count.
+*
+* Parameters - Adapter : Pointer to the Adpater structure.
+* - iQIndex : The queue Identifier.
+* - ulPacketLength: Number of bytes to be transmitted.
+*
+* Returns - The number of bytes allowed for transmission.
+*
+***********************************************************************/
+static __inline ULONG GetSFTokenCount(PMINI_ADAPTER Adapter, PacketInfo *psSF)
+{
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>");
+ /* Validate the parameters */
+ if(NULL == Adapter || (psSF < Adapter->PackInfo &&
+ (UINT)psSF > (UINT) &Adapter->PackInfo[HiPriority]))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %d\n", Adapter, (psSF-Adapter->PackInfo));
+ return 0;
+ }
+
+ if(FALSE != psSF->bValid && psSF->ucDirection)
+ {
+ if(0 != psSF->uiCurrentTokenCount)
+ {
+ return psSF->uiCurrentTokenCount;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %d Available %u\n",
+ psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount);
+ psSF->uiPendedLast = 1;
+ }
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %d not valid\n", psSF-Adapter->PackInfo);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <===");
+ return 0;
+}
+
+static __inline void RemovePacketFromQueue(PacketInfo *pPackInfo , struct sk_buff *Packet)
+{
+ struct sk_buff *psQueueCurrent=NULL, *psLastQueueNode=NULL;
+ psQueueCurrent = pPackInfo->FirstTxQueue;
+ while(psQueueCurrent)
+ {
+ if((UINT)Packet == (UINT)psQueueCurrent)
+ {
+ if((UINT)psQueueCurrent == (UINT)pPackInfo->FirstTxQueue)
+ {
+ pPackInfo->FirstTxQueue=psQueueCurrent->next;
+ if((UINT)psQueueCurrent==(UINT)pPackInfo->LastTxQueue)
+ pPackInfo->LastTxQueue=NULL;
+ }
+ else
+ {
+ psLastQueueNode->next=psQueueCurrent->next;
+ }
+ break;
+ }
+ psLastQueueNode = psQueueCurrent;
+ psQueueCurrent=psQueueCurrent->next;
+ }
+}
+/**
+@ingroup tx_functions
+This function despatches packet from the specified queue.
+@return Zero(success) or Negative value(failure)
+*/
+static __inline INT SendPacketFromQueue(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
+ PacketInfo *psSF, /**<Queue identifier*/
+ struct sk_buff* Packet) /**<Pointer to the packet to be sent*/
+{
+ INT Status=STATUS_FAILURE;
+ UINT uiIndex =0,PktLen = 0;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "=====>");
+ if(!Adapter || !Packet || !psSF)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "Got NULL Adapter or Packet");
+ return -EINVAL;
+ }
+
+ if(psSF->liDrainCalculated==0)
+ {
+ psSF->liDrainCalculated = jiffies;
+ }
+ ///send the packet to the fifo..
+ PktLen = Packet->len;
+ Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value);
+ if(Status == 0)
+ {
+ for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++)
+ { if((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex)))
+ Adapter->aTxPktSizeHist[uiIndex]++;
+ }
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "<=====");
+ return Status;
+}
+
+/************************************************************************
+* Function - CheckAndSendPacketFromIndex()
+*
+* Description - This function dequeues the data/control packet from the
+* specified queue for transmission.
+*
+* Parameters - Adapter : Pointer to the driver control structure.
+* - iQIndex : The queue Identifier.
+*
+* Returns - None.
+*
+****************************************************************************/
+static __inline VOID CheckAndSendPacketFromIndex
+(PMINI_ADAPTER Adapter, PacketInfo *psSF)
+{
+ struct sk_buff *QueuePacket=NULL;
+ char *pControlPacket = NULL;
+ INT Status=0;
+ int iPacketLen=0;
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%d ====>", (psSF-Adapter->PackInfo));
+ if(((UINT)psSF != (UINT)&Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet
+ {
+ if(!psSF->ucDirection )
+ return;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount ");
+ if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle Mode..Hence blocking Data Packets..\n");
+ return;
+ }
+ // Check for Free Descriptors
+ if(atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..",atomic_read(&Adapter->CurrNumFreeTxDesc));
+ return ;
+ }
+
+#if 0
+ PruneQueue(Adapter,(psSF-Adapter->PackInfo));
+#endif
+ spin_lock_bh(&psSF->SFQueueLock);
+ QueuePacket=psSF->FirstTxQueue;
+
+ if(QueuePacket)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Dequeuing Data Packet");
+
+ if(psSF->bEthCSSupport)
+ iPacketLen = QueuePacket->len;
+ else
+ iPacketLen = QueuePacket->len-ETH_HLEN;
+
+ iPacketLen<<=3;
+ if(iPacketLen <= GetSFTokenCount(Adapter, psSF))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Allowed bytes %d",
+ (iPacketLen >> 3));
+
+ DEQUEUEPACKET(psSF->FirstTxQueue,psSF->LastTxQueue);
+ psSF->uiCurrentBytesOnHost -= (QueuePacket->len);
+ psSF->uiCurrentPacketsOnHost--;
+ atomic_dec(&Adapter->TotalPacketCount);
+ spin_unlock_bh(&psSF->SFQueueLock);
+
+ Status = SendPacketFromQueue(Adapter, psSF, QueuePacket);
+ psSF->uiPendedLast = FALSE;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %d\n", psSF-Adapter->PackInfo);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n",
+ psSF->uiCurrentTokenCount, iPacketLen);
+ //this part indicates that becuase of non-availability of the tokens
+ //pkt has not been send out hence setting the pending flag indicating the host to send it out
+ //first next iteration .
+ psSF->uiPendedLast = TRUE;
+ spin_unlock_bh(&psSF->SFQueueLock);
+ }
+ }
+ else
+ {
+ spin_unlock_bh(&psSF->SFQueueLock);
+ }
+ }
+ else
+ {
+
+ if((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0 ) &&
+ (atomic_read(&Adapter->index_rd_txcntrlpkt) !=
+ atomic_read(&Adapter->index_wr_txcntrlpkt))
+ )
+ {
+ pControlPacket = Adapter->txctlpacket
+ [(atomic_read(&Adapter->index_rd_txcntrlpkt)%MAX_CNTRL_PKTS)];
+ if(pControlPacket)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Sending Control packet");
+ Status = SendControlPacket(Adapter, pControlPacket);
+ if(STATUS_SUCCESS==Status)
+ {
+ spin_lock_bh(&psSF->SFQueueLock);
+ psSF->NumOfPacketsSent++;
+ psSF->uiSentBytes+=((PLEADER)pControlPacket)->PLength;
+ psSF->uiSentPackets++;
+ atomic_dec(&Adapter->TotalPacketCount);
+ psSF->uiCurrentBytesOnHost -= ((PLEADER)pControlPacket)->PLength;
+ psSF->uiCurrentPacketsOnHost--;
+ atomic_inc(&Adapter->index_rd_txcntrlpkt);
+ spin_unlock_bh(&psSF->SFQueueLock);
+ }
+ else
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "SendControlPacket Failed\n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong....");
+ }
+ }
+ }
+
+ if(Status != STATUS_SUCCESS) //Tx of data packet to device Failed
+ {
+ if(Adapter->bcm_jiffies == 0)
+ Adapter->bcm_jiffies = jiffies;
+ }
+ else
+ {
+ Adapter->bcm_jiffies = 0;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<=====");
+}
+
+
+/*******************************************************************
+* Function - transmit_packets()
+*
+* Description - This function transmits the packets from different
+* queues, if free descriptors are available on target.
+*
+* Parameters - Adapter: Pointer to the Adapter structure.
+*
+* Returns - None.
+********************************************************************/
+VOID transmit_packets(PMINI_ADAPTER Adapter)
+{
+ UINT uiPrevTotalCount = 0;
+ int iIndex = 0;
+
+ BOOLEAN exit_flag = TRUE ;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "=====>");
+
+ if(NULL == Adapter)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX,TX_PACKETS, DBG_LVL_ALL, "Got NULL Adapter");
+ return;
+ }
+ if(Adapter->device_removed == TRUE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device removed");
+ return;
+ }
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nUpdateTokenCount ====>\n");
+
+ UpdateTokenCount(Adapter);
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nPruneQueueAllSF ====>\n");
+
+ PruneQueueAllSF(Adapter);
+
+ uiPrevTotalCount = atomic_read(&Adapter->TotalPacketCount);
+
+ for(iIndex=HiPriority;iIndex>=0;iIndex--)
+ {
+ if( !uiPrevTotalCount || (TRUE == Adapter->device_removed))
+ break;
+
+ if(Adapter->PackInfo[iIndex].bValid &&
+ Adapter->PackInfo[iIndex].uiPendedLast &&
+ Adapter->PackInfo[iIndex].uiCurrentBytesOnHost)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex..");
+ CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]);
+ uiPrevTotalCount--;
+ }
+ }
+
+ while(uiPrevTotalCount > 0 && !Adapter->device_removed)
+ {
+ exit_flag = TRUE ;
+ //second iteration to parse non-pending queues
+ for(iIndex=HiPriority;iIndex>=0;iIndex--)
+ {
+ if( !uiPrevTotalCount || (TRUE == Adapter->device_removed))
+ break;
+
+ if(Adapter->PackInfo[iIndex].bValid &&
+ Adapter->PackInfo[iIndex].uiCurrentBytesOnHost &&
+ !Adapter->PackInfo[iIndex].uiPendedLast )
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex..");
+ CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]);
+ uiPrevTotalCount--;
+ exit_flag = FALSE;
+ }
+ }
+
+ if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "In Idle Mode\n");
+ break;
+ }
+ if(exit_flag == TRUE )
+ break ;
+ }/* end of inner while loop */
+ if(Adapter->bcm_jiffies == 0 &&
+ atomic_read(&Adapter->TotalPacketCount) != 0 &&
+ uiPrevTotalCount == atomic_read(&Adapter->TotalPacketCount))
+ {
+ Adapter->bcm_jiffies = jiffies;
+ }
+ update_per_cid_rx (Adapter);
+ Adapter->txtransmit_running = 0;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======");
+}
diff --git a/drivers/staging/bcm/Macros.h b/drivers/staging/bcm/Macros.h
new file mode 100644
index 00000000000..f559b599bd2
--- /dev/null
+++ b/drivers/staging/bcm/Macros.h
@@ -0,0 +1,399 @@
+/*************************************
+* Macros.h
+**************************************/
+#ifndef __MACROS_H__
+#define __MACROS_H__
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#define kthread_run(threadfn,data,datafmt)(struct task_struct *)kernel_thread(threadfn,data,0)
+#endif
+
+#define TX_TIMER_PERIOD 10 //10 msec
+#define MAX_CLASSIFIERS 100
+//#define MAX_CLASSIFIERS_PER_SF 20
+#define MAX_TARGET_DSX_BUFFERS 24
+
+#define MAX_CNTRL_PKTS 100
+#define MAX_DATA_PKTS 200
+#define MAX_ETH_SIZE 1536
+#define MAX_CNTL_PKT_SIZE 2048
+/* TIMER RELATED */
+#define JIFFIES_2_QUADPART() (ULONG)(jiffies * 10000) // jiffies(1msec) to Quadpart(100nsec)
+
+#define MTU_SIZE 1400
+
+#define MAC_ADDR_REGISTER 0xbf60d000
+
+
+///////////Quality of Service///////////////////////////
+#define NO_OF_QUEUES 17
+#define HiPriority NO_OF_QUEUES-1
+#define LowPriority 0
+#define BE 2
+#define rtPS 4
+#define ERTPS 5
+#define UGS 6
+
+#define BE_BUCKET_SIZE 1024*1024*100 //32kb
+#define rtPS_BUCKET_SIZE 1024*1024*100 //8kb
+#define MAX_ALLOWED_RATE 1024*1024*100
+#define TX_PACKET_THRESHOLD 10
+#define XSECONDS 1*HZ
+#define DSC_ACTIVATE_REQUEST 248
+#define QUEUE_DEPTH_OFFSET 0x1fc01000
+#define MAX_DEVICE_DESC_SIZE 2040
+#define MAX_CTRL_QUEUE_LEN 100
+#define MAX_APP_QUEUE_LEN 200
+#define MAX_LATENCY_ALLOWED 0xFFFFFFFF
+#define DEFAULT_UG_INTERVAL 250
+#define DEFAULT_UGI_FACTOR 4
+
+#define DEFAULT_PERSFCOUNT 60
+#define MAX_CONNECTIONS 10
+#define MAX_CLASS_NAME_LENGTH 32
+
+#define ETH_LENGTH_OF_ADDRESS 6
+#define MAX_MULTICAST_ADDRESSES 32
+#define IP_LENGTH_OF_ADDRESS 4
+
+#define IP_PACKET_ONLY_MODE 0
+#define ETH_PACKET_TUNNELING_MODE 1
+
+////////////Link Request//////////////
+#define SET_MAC_ADDRESS_REQUEST 0
+#define SYNC_UP_REQUEST 1
+#define SYNCED_UP 2
+#define LINK_UP_REQUEST 3
+#define LINK_CONNECTED 4
+#define SYNC_UP_NOTIFICATION 2
+#define LINK_UP_NOTIFICATION 4
+
+
+#define LINK_NET_ENTRY 0x0002
+#define HMC_STATUS 0x0004
+#define LINK_UP_CONTROL_REQ 0x83
+
+#define STATS_POINTER_REQ_STATUS 0x86
+#define NETWORK_ENTRY_REQ_PAYLOAD 198
+#define LINK_DOWN_REQ_PAYLOAD 226
+#define SYNC_UP_REQ_PAYLOAD 228
+#define STATISTICS_POINTER_REQ 237
+#define LINK_UP_REQ_PAYLOAD 245
+#define LINK_UP_ACK 246
+
+#define STATS_MSG_SIZE 4
+#define INDEX_TO_DATA 4
+
+#define GO_TO_IDLE_MODE_PAYLOAD 210
+#define COME_UP_FROM_IDLE_MODE_PAYLOAD 211
+#define IDLE_MODE_SF_UPDATE_MSG 187
+
+#define SKB_RESERVE_ETHERNET_HEADER 16
+#define SKB_RESERVE_PHS_BYTES 32
+
+#define IP_PACKET_ONLY_MODE 0
+#define ETH_PACKET_TUNNELING_MODE 1
+
+#define ETH_CS_802_3 1
+#define ETH_CS_802_1Q_VLAN 3
+#define IPV4_CS 1
+#define IPV6_CS 2
+#define ETH_CS_MASK 0x3f
+
+/** \brief Validity bit maps for TLVs in packet classification rule */
+
+#define PKT_CLASSIFICATION_USER_PRIORITY_VALID 0
+#define PKT_CLASSIFICATION_VLANID_VALID 1
+
+#ifndef MIN
+#define MIN(_a, _b) ((_a) < (_b)? (_a): (_b))
+#endif
+
+
+/*Leader related terms */
+#define LEADER_STATUS 0x00
+#define LEADER_STATUS_TCP_ACK 0x1
+#define LEADER_SIZE sizeof(LEADER)
+#define MAC_ADDR_REQ_SIZE sizeof(PACKETTOSEND)
+#define SS_INFO_REQ_SIZE sizeof(PACKETTOSEND)
+#define CM_REQUEST_SIZE LEADER_SIZE + sizeof(stLocalSFChangeRequest)
+#define IDLE_REQ_SIZE sizeof(PACKETTOSEND)
+
+
+#define MAX_TRANSFER_CTRL_BYTE_USB 2 * 1024
+
+#define GET_MAILBOX1_REG_REQUEST 0x87
+#define GET_MAILBOX1_REG_RESPONSE 0x67
+#define VCID_CONTROL_PACKET 0x00
+
+#define TRANSMIT_NETWORK_DATA 0x00
+#define RECEIVED_NETWORK_DATA 0x20
+
+#define CM_RESPONSES 0xA0
+#define STATUS_RSP 0xA1
+#define LINK_CONTROL_RESP 0xA2
+#define IDLE_MODE_STATUS 0xA3
+#define STATS_POINTER_RESP 0xA6
+#define MGMT_MSG_INFO_SW_STATUS 0xA7
+#define AUTH_SS_HOST_MSG 0xA8
+
+#define CM_DSA_ACK_PAYLOAD 247
+#define CM_DSC_ACK_PAYLOAD 248
+#define CM_DSD_ACK_PAYLOAD 249
+#define CM_DSDEACTVATE 250
+#define TOTAL_MASKED_ADDRESS_IN_BYTES 32
+
+#define MAC_REQ 0
+#define LINK_RESP 1
+#define RSSI_INDICATION 2
+
+#define SS_INFO 4
+#define STATISTICS_INFO 5
+#define CM_INDICATION 6
+#define PARAM_RESP 7
+#define BUFFER_1K 1024
+#define BUFFER_2K BUFFER_1K*2
+#define BUFFER_4K BUFFER_2K*2
+#define BUFFER_8K BUFFER_4K*2
+#define BUFFER_16K BUFFER_8K*2
+#define DOWNLINK_DIR 0
+#define UPLINK_DIR 1
+
+#define BCM_SIGNATURE "BECEEM"
+
+
+#define GPIO_OUTPUT_REGISTER 0x0F00003C
+#define BCM_GPIO_OUTPUT_SET_REG 0x0F000040
+#define BCM_GPIO_OUTPUT_CLR_REG 0x0F000044
+#define GPIO_MODE_REGISTER 0x0F000034
+#define GPIO_PIN_STATE_REGISTER 0x0F000038
+
+
+typedef struct _LINK_STATE {
+ UCHAR ucLinkStatus;
+ UCHAR bIdleMode;
+ UCHAR bShutdownMode;
+}LINK_STATE, *PLINK_STATE;
+
+
+enum enLinkStatus {
+ WAIT_FOR_SYNC = 1,
+ PHY_SYNC_ACHIVED = 2,
+ LINKUP_IN_PROGRESS = 3,
+ LINKUP_DONE = 4,
+ DREG_RECIEVED = 5,
+ LINK_STATUS_RESET_RECIEVED = 6,
+ PERIODIC_WAKE_UP_NOTIFICATION_FRM_FW = 7,
+ LINK_SHUTDOWN_REQ_FROM_FIRMWARE = 8,
+ COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW =9
+};
+
+typedef enum _E_PHS_DSC_ACTION
+{
+ eAddPHSRule=0,
+ eSetPHSRule,
+ eDeletePHSRule,
+ eDeleteAllPHSRules
+}E_PHS_DSC_ACTION;
+
+
+#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ 0x89 // Host to Mac
+#define CM_CONTROL_NEWDSX_MULTICLASSIFIER_RESP 0xA9 // Mac to Host
+#define MASK_DISABLE_HEADER_SUPPRESSION 0x10 //0b000010000
+#define MINIMUM_PENDING_DESCRIPTORS 5
+
+#define SHUTDOWN_HOSTINITIATED_REQUESTPAYLOAD 0xCC
+#define SHUTDOWN_ACK_FROM_DRIVER 0x1
+#define SHUTDOWN_NACK_FROM_DRIVER 0x2
+
+#define LINK_SYNC_UP_SUBTYPE 0x0001
+#define LINK_SYNC_DOWN_SUBTYPE 0x0001
+
+
+
+#define CONT_MODE 1
+#define SINGLE_DESCRIPTOR 1
+
+
+#define DESCRIPTOR_LENGTH 0x30
+#define FIRMWARE_DESCS_ADDRESS 0x1F100000
+
+
+#define CLOCK_RESET_CNTRL_REG_1 0x0F00000C
+#define CLOCK_RESET_CNTRL_REG_2 0x0F000840
+
+
+
+#define TX_DESCRIPTOR_HEAD_REGISTER 0x0F010034
+#define RX_DESCRIPTOR_HEAD_REGISTER 0x0F010094
+
+#define STATISTICS_BEGIN_ADDR 0xbf60f02c
+
+#define MAX_PENDING_CTRL_PACKET (MAX_CTRL_QUEUE_LEN-10)
+
+#define WIMAX_MAX_MTU MTU_SIZE + ETH_HLEN
+#define AUTO_LINKUP_ENABLE 0x2
+#define AUTO_SYNC_DISABLE 0x1
+#define AUTO_FIRM_DOWNLOAD 0x1
+#define SETTLE_DOWN_TIME 50
+
+#define HOST_BUS_SUSPEND_BIT 16
+
+#define IDLE_MESSAGE 0x81
+
+#define MIPS_CLOCK_133MHz 1
+
+#define TARGET_CAN_GO_TO_IDLE_MODE 2
+#define TARGET_CAN_NOT_GO_TO_IDLE_MODE 3
+#define IDLE_MODE_PAYLOAD_LENGTH 8
+
+#define IP_HEADER(Buffer) ((IPHeaderFormat*)(Buffer))
+#define IPV4 4
+#define IP_VERSION(byte) (((byte&0xF0)>>4))
+
+#define SET_MAC_ADDRESS 193
+#define SET_MAC_ADDRESS_RESPONSE 236
+
+#define IDLE_MODE_WAKEUP_PATTERN 0xd0ea1d1e
+#define IDLE_MODE_WAKEUP_NOTIFIER_ADDRESS 0x1FC02FA8
+#define IDLE_MODE_MAX_RETRY_COUNT 1000
+
+#ifdef REL_4_1
+#define CONFIG_BEGIN_ADDR 0xBF60B004
+#else
+#define CONFIG_BEGIN_ADDR 0xBF60B000
+#endif
+
+#define FIRMWARE_BEGIN_ADDR 0xBFC00000
+
+#define INVALID_QUEUE_INDEX (USHORT)-1
+
+#define INVALID_PID (pid_t)-1
+#define DDR_80_MHZ 0
+#define DDR_100_MHZ 1
+#define DDR_120_MHZ 2 // Additional Frequency for T3LP
+#define DDR_133_MHZ 3
+#define DDR_140_MHZ 4 // Not Used (Reserved for future)
+#define DDR_160_MHZ 5 // Additional Frequency for T3LP
+#define DDR_180_MHZ 6 // Not Used (Reserved for future)
+#define DDR_200_MHZ 7 // Not Used (Reserved for future)
+
+#define MIPS_200_MHZ 0
+#define MIPS_160_MHZ 1
+
+#define PLL_800_MHZ 0
+#define PLL_266_MHZ 1
+
+#define DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING 0
+#define DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING 1
+#define DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN 2
+#define DEVICE_POWERSAVE_MODE_AS_RESERVED 3
+#define DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE 4
+
+
+#define EEPROM_REJECT_REG_1 0x0f003018
+#define EEPROM_REJECT_REG_2 0x0f00301c
+#define EEPROM_REJECT_REG_3 0x0f003008
+#define EEPROM_REJECT_REG_4 0x0f003020
+#define EEPROM_REJECT_MASK 0x0fffffff
+#define VSG_MODE 0x3
+
+/* Idle Mode Related Registers */
+#define DEBUG_INTERRUPT_GENERATOR_REGISTOR 0x0F00007C
+#ifdef BCM_SHM_INTERFACE
+#define SW_ABORT_IDLEMODE_LOC 0xbfc02f9c
+#define CPE_VIRTUAL_MAILBOX_REG 0xBFC02E58
+#else
+#define SW_ABORT_IDLEMODE_LOC 0x0FF01FFC
+#endif
+
+#define SW_ABORT_IDLEMODE_PATTERN 0xd0ea1d1e
+#define DEVICE_INT_OUT_EP_REG0 0x0F011870
+#define DEVICE_INT_OUT_EP_REG1 0x0F011874
+
+#define BIN_FILE "/lib/firmware/macxvi200.bin"
+#define CFG_FILE "/lib/firmware/macxvi.cfg"
+#define SF_MAX_ALLOWED_PACKETS_TO_BACKUP 128
+#define MIN_VAL(x,y) ((x)<(y)?(x):(y))
+#define MAC_ADDRESS_SIZE 6
+#define EEPROM_COMMAND_Q_REG 0x0F003018
+#define EEPROM_READ_DATA_Q_REG 0x0F003020
+#define CHIP_ID_REG 0x0F000000
+#define GPIO_MODE_REG 0x0F000034
+#define GPIO_OUTPUT_REG 0x0F00003C
+#define WIMAX_MAX_ALLOWED_RATE 1024*1024*50
+
+#define T3 0xbece0300
+#define TARGET_SFID_TXDESC_MAP_LOC 0xBFFFF400
+
+#define RWM_READ 0
+#define RWM_WRITE 1
+
+#define T3LPB 0xbece3300
+#define BCS220_2 0xbece3311
+#define BCS220_2BC 0xBECE3310
+#define BCS250_BC 0xbece3301
+#define BCS220_3 0xbece3321
+
+
+#define HPM_CONFIG_LDO145 0x0F000D54
+#define HPM_CONFIG_MSW 0x0F000D58
+
+#define T3B 0xbece0310
+typedef enum eNVM_TYPE
+{
+ NVM_AUTODETECT = 0,
+ NVM_EEPROM,
+ NVM_FLASH,
+ NVM_UNKNOWN
+}NVM_TYPE;
+
+typedef enum ePMU_MODES
+{
+ HYBRID_MODE_7C = 0,
+ INTERNAL_MODE_6 = 1,
+ HYBRID_MODE_6 = 2
+}PMU_MODE;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
+#define MAX_RDM_WRM_RETIRES 16
+#else
+#define MAX_RDM_WRM_RETIRES 1
+#endif
+
+
+enum eAbortPattern {
+ ABORT_SHUTDOWN_MODE = 1,
+ ABORT_IDLE_REG = 1,
+ ABORT_IDLE_MODE = 2,
+ ABORT_IDLE_SYNCDOWN = 3
+};
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+ #define GET_BCM_ADAPTER(net_dev) ({\
+ PMINI_ADAPTER __Adapter = NULL; \
+ if (net_dev) { \
+ __Adapter = (PMINI_ADAPTER)(net_dev->priv); \
+ } \
+ else { \
+ __Adapter = NULL; \
+ }__Adapter;} )
+#else
+ #define GET_BCM_ADAPTER(net_dev) ({\
+ PMINI_ADAPTER __Adapter = NULL; \
+ if (net_dev) { \
+ __Adapter = (PMINI_ADAPTER)(*((UINT *)netdev_priv(net_dev))); \
+ } \
+ else { \
+ __Adapter = NULL; \
+ }__Adapter;})
+
+
+#endif
+
+/* Offsets used by driver in skb cb variable */
+#define SKB_CB_CLASSIFICATION_OFFSET 0
+#define SKB_CB_LATENCY_OFFSET 1
+#define SKB_CB_TCPACK_OFFSET 2
+
+#endif //__MACROS_H__
diff --git a/drivers/staging/bcm/Makefile b/drivers/staging/bcm/Makefile
new file mode 100644
index 00000000000..3fdec2ea0c4
--- /dev/null
+++ b/drivers/staging/bcm/Makefile
@@ -0,0 +1,12 @@
+#
+# Makefile for Beceem USB Wimax card
+#
+
+obj-$(CONFIG_BCM_WIMAX) += bcm_wimax.o
+
+bcm_wimax-objs := InterfaceDld.o InterfaceIdleMode.o InterfaceInit.o InterfaceRx.o \
+ InterfaceIsr.o InterfaceMisc.o InterfaceTx.o \
+ Arp.o CmHost.o Debug.o IPv6Protocol.o Qos.o Transmit.o\
+ Bcmnet.o DDRInit.o HandleControlPacket.o\
+ LeakyBucket.o Misc.o sort.o Bcmchar.o hostmibs.o PHSModule.o\
+ Osal_Misc.o led_control.o nvm.o vendorspecificextn.o
diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c
new file mode 100644
index 00000000000..5ed58a863eb
--- /dev/null
+++ b/drivers/staging/bcm/Misc.c
@@ -0,0 +1,2239 @@
+#include "headers.h"
+
+static VOID default_wimax_protocol_initialize(PMINI_ADAPTER Adapter)
+{
+
+ UINT uiLoopIndex;
+
+ for(uiLoopIndex=0; uiLoopIndex < NO_OF_QUEUES-1; uiLoopIndex++)
+ {
+ Adapter->PackInfo[uiLoopIndex].uiThreshold=TX_PACKET_THRESHOLD;
+ Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate=MAX_ALLOWED_RATE;
+ Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize=20*1024*1024;
+ }
+
+ Adapter->BEBucketSize=BE_BUCKET_SIZE;
+ Adapter->rtPSBucketSize=rtPS_BUCKET_SIZE;
+ Adapter->LinkStatus=SYNC_UP_REQUEST;
+ Adapter->TransferMode=IP_PACKET_ONLY_MODE;
+ Adapter->usBestEffortQueueIndex=-1;
+ return;
+}
+
+
+INT
+InitAdapter(PMINI_ADAPTER psAdapter)
+{
+ int i = 0;
+ INT Status = STATUS_SUCCESS ;
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Initialising Adapter = 0x%x",(unsigned int) psAdapter);
+
+ if(psAdapter == NULL)
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter is NULL");
+ return -EINVAL;
+ }
+
+ sema_init(&psAdapter->NVMRdmWrmLock,1);
+// psAdapter->ulFlashCalStart = FLASH_AUTO_INIT_BASE_ADDR;
+
+ sema_init(&psAdapter->rdmwrmsync, 1);
+ spin_lock_init(&psAdapter->control_queue_lock);
+ spin_lock_init(&psAdapter->txtransmitlock);
+ sema_init(&psAdapter->RxAppControlQueuelock, 1);
+// sema_init(&psAdapter->data_packet_queue_lock, 1);
+ sema_init(&psAdapter->fw_download_sema, 1);
+ sema_init(&psAdapter->LowPowerModeSync,1);
+
+ // spin_lock_init(&psAdapter->sleeper_lock);
+
+ for(i=0;i<NO_OF_QUEUES; i++)
+ spin_lock_init(&psAdapter->PackInfo[i].SFQueueLock);
+ i=0;
+
+ init_waitqueue_head(&psAdapter->process_rx_cntrlpkt);
+ init_waitqueue_head(&psAdapter->tx_packet_wait_queue);
+ init_waitqueue_head(&psAdapter->process_read_wait_queue);
+ init_waitqueue_head(&psAdapter->ioctl_fw_dnld_wait_queue);
+ init_waitqueue_head(&psAdapter->lowpower_mode_wait_queue);
+ psAdapter->waiting_to_fw_download_done = TRUE;
+ //init_waitqueue_head(&psAdapter->device_wake_queue);
+ psAdapter->fw_download_done=FALSE;
+
+ psAdapter->pvOsDepData = (PLINUX_DEP_DATA) kmalloc(sizeof(LINUX_DEP_DATA),
+ GFP_KERNEL);
+
+ if(psAdapter->pvOsDepData == NULL)
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Linux Specific Data allocation failed");
+ return -ENOMEM;
+ }
+ memset(psAdapter->pvOsDepData, 0, sizeof(LINUX_DEP_DATA));
+
+ default_wimax_protocol_initialize(psAdapter);
+ for (i=0;i<MAX_CNTRL_PKTS;i++)
+ {
+ psAdapter->txctlpacket[i] = (char *)kmalloc(MAX_CNTL_PKT_SIZE,
+ GFP_KERNEL);
+ if(!psAdapter->txctlpacket[i])
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No More Cntl pkts got, max got is %d", i);
+ return -ENOMEM;
+ }
+ }
+ if(AllocAdapterDsxBuffer(psAdapter))
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to allocate DSX buffers");
+ return -EINVAL;
+ }
+
+ //Initialize PHS interface
+ if(phs_init(&psAdapter->stBCMPhsContext,psAdapter)!=0)
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%s:%d:Error PHS Init Failed=====>\n", __FILE__, __FUNCTION__, __LINE__);
+ return -ENOMEM;
+ }
+
+ Status = BcmAllocFlashCSStructure(psAdapter);
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Memory Allocation for Flash structure failed");
+ return Status ;
+ }
+
+ Status = vendorextnInit(psAdapter);
+
+ if(STATUS_SUCCESS != Status)
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Vendor Init Failed");
+ return Status ;
+ }
+
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Adapter initialised");
+
+
+ return STATUS_SUCCESS;
+}
+
+VOID AdapterFree(PMINI_ADAPTER Adapter)
+{
+ INT count = 0;
+
+ beceem_protocol_reset(Adapter);
+
+ vendorextnExit(Adapter);
+
+ if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler))
+ kthread_stop (Adapter->control_packet_handler);
+ if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread))
+ kthread_stop (Adapter->transmit_packet_thread);
+ wake_up(&Adapter->process_read_wait_queue);
+ if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY))
+ kthread_stop (Adapter->LEDInfo.led_cntrl_threadid);
+ bcm_unregister_networkdev(Adapter);
+ while(atomic_read(&Adapter->ApplicationRunning))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n",atomic_read(&Adapter->ApplicationRunning));
+ msleep(100);
+ }
+ unregister_control_device_interface(Adapter);
+ if(Adapter->dev && !IS_ERR(Adapter->dev))
+ free_netdev(Adapter->dev);
+ if(Adapter->pstargetparams != NULL)
+ {
+ bcm_kfree(Adapter->pstargetparams);
+ }
+ for (count =0;count < MAX_CNTRL_PKTS;count++)
+ {
+ if(Adapter->txctlpacket[count])
+ bcm_kfree(Adapter->txctlpacket[count]);
+ }
+ FreeAdapterDsxBuffer(Adapter);
+ if(Adapter->pvOsDepData)
+ bcm_kfree (Adapter->pvOsDepData);
+ if(Adapter->pvInterfaceAdapter)
+ bcm_kfree(Adapter->pvInterfaceAdapter);
+
+ //Free the PHS Interface
+ PhsCleanup(&Adapter->stBCMPhsContext);
+
+#ifndef BCM_SHM_INTERFACE
+ BcmDeAllocFlashCSStructure(Adapter);
+#endif
+
+ bcm_kfree (Adapter);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "<========\n");
+}
+
+
+int create_worker_threads(PMINI_ADAPTER psAdapter)
+{
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Init Threads...");
+ // Rx Control Packets Processing
+ psAdapter->control_packet_handler = kthread_run((int (*)(void *))
+ control_packet_handler, psAdapter, "CtrlPktHdlr");
+ if(IS_ERR(psAdapter->control_packet_handler))
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success\n");
+ return PTR_ERR(psAdapter->control_packet_handler);
+ }
+ // Tx Thread
+ psAdapter->transmit_packet_thread = kthread_run((int (*)(void *))
+ tx_pkt_handler, psAdapter, "TxPktThread");
+ if(IS_ERR (psAdapter->transmit_packet_thread))
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Kernel Thread, but still returning success");
+ kthread_stop(psAdapter->control_packet_handler);
+ return PTR_ERR(psAdapter->transmit_packet_thread);
+ }
+ return 0;
+}
+
+
+static inline struct file *open_firmware_file(PMINI_ADAPTER Adapter, char *path)
+{
+ struct file *flp=NULL;
+ mm_segment_t oldfs;
+ oldfs=get_fs();
+ set_fs(get_ds());
+ flp=filp_open(path, O_RDONLY, S_IRWXU);
+ set_fs(oldfs);
+ if(IS_ERR(flp))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable To Open File %s, err %lx",
+ path, PTR_ERR(flp));
+ flp = NULL;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Got file descriptor pointer of %s!",
+ path);
+ }
+ if(Adapter->device_removed)
+ {
+ flp = NULL;
+ }
+
+ return flp;
+}
+
+
+int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */
+ char *path, /**< path to image file */
+ unsigned int loc /**< Download Address on the chip*/
+ )
+{
+ int errorno=0;
+ struct file *flp=NULL;
+ mm_segment_t oldfs;
+ struct timeval tv={0};
+
+ flp=open_firmware_file(Adapter, path);
+ if(!flp)
+ {
+ errorno = -ENOENT;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Unable to Open %s\n", path);
+ goto exit_download;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Opened file is = %s and length =0x%lx to be downloaded at =0x%x", path,(unsigned long)flp->f_dentry->d_inode->i_size, loc);
+ do_gettimeofday(&tv);
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "download start %lx", ((tv.tv_sec * 1000) +
+ (tv.tv_usec/1000)));
+ if(Adapter->bcm_file_download(Adapter->pvInterfaceAdapter, flp, loc))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to download the firmware with error\
+ %x!!!", -EIO);
+ errorno=-EIO;
+ goto exit_download;
+ }
+ oldfs=get_fs();set_fs(get_ds());
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+ vfs_llseek(flp, 0, 0);
+#endif
+ set_fs(oldfs);
+ if(Adapter->bcm_file_readback_from_chip(Adapter->pvInterfaceAdapter,
+ flp, loc))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Failed to read back firmware!");
+ errorno=-EIO;
+ goto exit_download;
+ }
+
+exit_download:
+ oldfs=get_fs();set_fs(get_ds());
+ if(flp && !(IS_ERR(flp)))
+ filp_close(flp, current->files);
+ set_fs(oldfs);
+ do_gettimeofday(&tv);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "file download done at %lx", ((tv.tv_sec * 1000) +
+ (tv.tv_usec/1000)));
+ return errorno;
+}
+
+
+void bcm_kfree_skb(struct sk_buff *skb)
+{
+ if(skb)
+ {
+ kfree_skb(skb);
+ }
+ skb = NULL ;
+}
+
+VOID bcm_kfree(VOID *ptr)
+{
+ if(ptr)
+ {
+ kfree(ptr);
+ }
+ ptr = NULL ;
+}
+
+/**
+@ingroup ctrl_pkt_functions
+This function copies the contents of given buffer
+to the control packet and queues it for transmission.
+@note Do not acquire the spinock, as it it already acquired.
+@return SUCCESS/FAILURE.
+*/
+INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
+ PVOID ioBuffer/**<Control Packet Buffer*/
+ )
+{
+ PLEADER pLeader=NULL;
+ INT Status=0;
+ unsigned char *ctrl_buff=NULL;
+ UINT pktlen=0;
+ PLINK_REQUEST pLinkReq = NULL;
+ PUCHAR pucAddIndication = NULL;
+
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "======>");
+ if(!ioBuffer)
+ {
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Got Null Buffer\n");
+ return -EINVAL;
+ }
+
+ pLinkReq = (PLINK_REQUEST)ioBuffer;
+ pLeader=(PLEADER)ioBuffer; //ioBuffer Contains sw_Status and Payload
+
+ if(Adapter->bShutStatus == TRUE &&
+ pLinkReq->szData[0] == LINK_DOWN_REQ_PAYLOAD &&
+ pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)
+ {
+ //Got sync down in SHUTDOWN..we could not process this.
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC DOWN Request in Shut Down Mode..\n");
+ return STATUS_FAILURE;
+ }
+
+ if((pLeader->Status == LINK_UP_CONTROL_REQ) &&
+ ((pLinkReq->szData[0] == LINK_UP_REQ_PAYLOAD &&
+ (pLinkReq->szData[1] == LINK_SYNC_UP_SUBTYPE)) ||//Sync Up Command
+ pLinkReq->szData[0] == NETWORK_ENTRY_REQ_PAYLOAD)) //Net Entry Command
+ {
+ if(Adapter->LinkStatus > PHY_SYNC_ACHIVED)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"LinkStatus is Greater than PHY_SYN_ACHIEVED");
+ return STATUS_FAILURE;
+ }
+ if(TRUE == Adapter->bShutStatus)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "SYNC UP IN SHUTDOWN..Device WakeUp\n");
+ if(Adapter->bTriedToWakeUpFromlowPowerMode == FALSE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Waking up for the First Time..\n");
+ Adapter->usIdleModePattern = ABORT_SHUTDOWN_MODE; // change it to 1 for current support.
+ Adapter->bWakeUpDevice = TRUE;
+ wake_up(&Adapter->process_rx_cntrlpkt);
+
+ Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue,
+ !Adapter->bShutStatus, (5 * HZ));
+
+ if(Status == -ERESTARTSYS)
+ return Status;
+
+ if(Adapter->bShutStatus)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Shutdown Mode Wake up Failed - No Wake Up Received\n");
+ return STATUS_FAILURE;
+ }
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Wakeup has been tried already...\n");
+ }
+ }
+
+ }
+ if(TRUE == Adapter->IdleMode)
+ {
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Device is in Idle mode ... hence \n");
+ if(pLeader->Status == LINK_UP_CONTROL_REQ || pLeader->Status == 0x80 ||
+ pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ )
+
+ {
+ if((pLeader->Status == LINK_UP_CONTROL_REQ) && (pLinkReq->szData[0]==LINK_DOWN_REQ_PAYLOAD))
+ {
+ if((pLinkReq->szData[1] == LINK_SYNC_DOWN_SUBTYPE))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Link Down Sent in Idle Mode\n");
+ Adapter->usIdleModePattern = ABORT_IDLE_SYNCDOWN;//LINK DOWN sent in Idle Mode
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n");
+ Adapter->usIdleModePattern = ABORT_IDLE_REG;
+ }
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL,"ABORT_IDLE_MODE pattern is being written\n");
+ Adapter->usIdleModePattern = ABORT_IDLE_MODE;
+ }
+
+ /*Setting bIdleMode_tx_from_host to TRUE to indicate LED control thread to represent
+ the wake up from idlemode is from host*/
+ //Adapter->LEDInfo.bIdleMode_tx_from_host = TRUE;
+#if 0
+ if(STATUS_SUCCESS != InterfaceIdleModeWakeup(Adapter))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Idle Mode Wake up Failed\n");
+ return STATUS_FAILURE;
+ }
+#endif
+ Adapter->bWakeUpDevice = TRUE;
+ wake_up(&Adapter->process_rx_cntrlpkt);
+
+
+
+ if(LINK_DOWN_REQ_PAYLOAD == pLinkReq->szData[0])
+ {
+ // We should not send DREG message down while in idlemode.
+ return STATUS_SUCCESS;
+ }
+
+ Status = wait_event_interruptible_timeout(Adapter->lowpower_mode_wait_queue,
+ !Adapter->IdleMode, (5 * HZ));
+
+ if(Status == -ERESTARTSYS)
+ return Status;
+
+ if(Adapter->IdleMode)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Idle Mode Wake up Failed - No Wake Up Received\n");
+ return STATUS_FAILURE;
+ }
+ }
+ else
+ return STATUS_SUCCESS;
+ }
+ //The Driver has to send control messages with a particular VCID
+ pLeader->Vcid = VCID_CONTROL_PACKET;//VCID for control packet.
+
+ /* Allocate skb for Control Packet */
+ pktlen = pLeader->PLength;
+ ctrl_buff = (char *)Adapter->txctlpacket[atomic_read(&Adapter->index_wr_txcntrlpkt)%MAX_CNTRL_PKTS];
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Control packet to be taken =%d and address is =%pincoming address is =%p and packet len=%x",
+ atomic_read(&Adapter->index_wr_txcntrlpkt), ctrl_buff, ioBuffer, pktlen);
+ if(ctrl_buff)
+ {
+ if(pLeader)
+ {
+ if((pLeader->Status == 0x80) ||
+ (pLeader->Status == CM_CONTROL_NEWDSX_MULTICLASSIFIER_REQ))
+ {
+ /*
+ //Restructure the DSX message to handle Multiple classifier Support
+ // Write the Service Flow param Structures directly to the target
+ //and embed the pointers in the DSX messages sent to target.
+ */
+ //Lets store the current length of the control packet we are transmitting
+ pucAddIndication = (PUCHAR)ioBuffer + LEADER_SIZE;
+ pktlen = pLeader->PLength;
+ Status = StoreCmControlResponseMessage(Adapter,pucAddIndication, &pktlen);
+ if(Status != 1)
+ {
+ ClearTargetDSXBuffer(Adapter,((stLocalSFAddIndicationAlt *)pucAddIndication)->u16TID, FALSE);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, " Error Restoring The DSX Control Packet. Dsx Buffers on Target may not be Setup Properly ");
+ return STATUS_FAILURE;
+ }
+ /*
+ //update the leader to use the new length
+ //The length of the control packet is length of message being sent + Leader length
+ */
+ pLeader->PLength = pktlen;
+ }
+ }
+ memset(ctrl_buff, 0, pktlen+LEADER_SIZE);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Copying the Control Packet Buffer with length=%d\n", pLeader->PLength);
+ *(PLEADER)ctrl_buff=*pLeader;
+ memcpy(ctrl_buff + LEADER_SIZE, ((PUCHAR)ioBuffer + LEADER_SIZE), pLeader->PLength);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "Enqueuing the Control Packet");
+
+ /*Update the statistics counters */
+ spin_lock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock);
+ Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost+=pLeader->PLength;
+ Adapter->PackInfo[HiPriority].uiCurrentPacketsOnHost++;
+ atomic_inc(&Adapter->TotalPacketCount);
+ spin_unlock_bh(&Adapter->PackInfo[HiPriority].SFQueueLock);
+
+ Adapter->PackInfo[HiPriority].bValid = TRUE;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "CurrBytesOnHost: %x bValid: %x",
+ Adapter->PackInfo[HiPriority].uiCurrentBytesOnHost,
+ Adapter->PackInfo[HiPriority].bValid);
+ Status=STATUS_SUCCESS;
+ /*Queue the packet for transmission */
+ atomic_inc(&Adapter->index_wr_txcntrlpkt);
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL,DBG_LVL_ALL, "Calling transmit_packets");
+ atomic_set(&Adapter->TxPktAvail, 1);
+#ifdef BCM_SHM_INTERFACE
+ virtual_mail_box_interrupt();
+#endif
+ wake_up(&Adapter->tx_packet_wait_queue);
+ }
+ else
+ {
+ Status=-ENOMEM;
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "mem allocation Failed");
+ }
+ BCM_DEBUG_PRINT( Adapter,DBG_TYPE_TX, TX_CONTROL, DBG_LVL_ALL, "<====");
+ return Status;
+}
+
+/*****************************************************************
+* Function - SendStatisticsPointerRequest()
+*
+* Description - This function builds and forwards the Statistics
+* Pointer Request control Packet.
+*
+* Parameters - Adapter : Pointer to Adapter structure.
+* - pstStatisticsPtrRequest : Pointer to link request.
+*
+* Returns - None.
+*****************************************************************/
+VOID SendStatisticsPointerRequest(PMINI_ADAPTER Adapter,
+ PLINK_REQUEST pstStatisticsPtrRequest)
+{
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "======>");
+ pstStatisticsPtrRequest->Leader.Status = STATS_POINTER_REQ_STATUS;
+ pstStatisticsPtrRequest->Leader.PLength = sizeof(ULONG);//minimum 4 bytes
+ pstStatisticsPtrRequest->szData[0] = STATISTICS_POINTER_REQ;
+
+ CopyBufferToControlPacket(Adapter,pstStatisticsPtrRequest);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "<=====");
+ return;
+}
+
+
+
+void SendLinkDown(PMINI_ADAPTER Adapter)
+{
+ LINK_REQUEST stLinkDownRequest;
+ memset(&stLinkDownRequest, 0, sizeof(LINK_REQUEST));
+ stLinkDownRequest.Leader.Status=LINK_UP_CONTROL_REQ;
+ stLinkDownRequest.Leader.PLength=sizeof(ULONG);//minimum 4 bytes
+ stLinkDownRequest.szData[0]=LINK_DOWN_REQ_PAYLOAD;
+ Adapter->bLinkDownRequested = TRUE;
+
+ CopyBufferToControlPacket(Adapter,&stLinkDownRequest);
+}
+
+/******************************************************************
+* Function - LinkMessage()
+*
+* Description - This function builds the Sync-up and Link-up request
+* packet messages depending on the device Link status.
+*
+* Parameters - Adapter: Pointer to the Adapter structure.
+*
+* Returns - None.
+*******************************************************************/
+__inline VOID LinkMessage(PMINI_ADAPTER Adapter)
+{
+ PLINK_REQUEST pstLinkRequest=NULL;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>");
+ if(Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup)
+ {
+ pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
+ if(!pstLinkRequest)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
+ return;
+ }
+ memset(pstLinkRequest,0,sizeof(LINK_REQUEST));
+ //sync up request...
+ Adapter->LinkStatus = WAIT_FOR_SYNC;// current link status
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp...");
+ pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD;
+ pstLinkRequest->szData[1]=LINK_SYNC_UP_SUBTYPE;
+ pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ;
+ pstLinkRequest->Leader.PLength=sizeof(ULONG);
+ Adapter->bSyncUpRequestSent = TRUE;
+ }
+ else if(Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp)
+ {
+ pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
+ if(!pstLinkRequest)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
+ return;
+ }
+ memset(pstLinkRequest,0,sizeof(LINK_REQUEST));
+ //LINK_UP_REQUEST
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp...");
+ pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD;
+ pstLinkRequest->szData[1]=LINK_NET_ENTRY;
+ pstLinkRequest->Leader.Status=LINK_UP_CONTROL_REQ;
+ pstLinkRequest->Leader.PLength=sizeof(ULONG);
+ }
+ if(pstLinkRequest)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Calling CopyBufferToControlPacket");
+ CopyBufferToControlPacket(Adapter, pstLinkRequest);
+ bcm_kfree(pstLinkRequest);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "LinkMessage <=====");
+ return;
+}
+
+
+/**********************************************************************
+* Function - StatisticsResponse()
+*
+* Description - This function handles the Statistics response packet.
+*
+* Parameters - Adapter : Pointer to the Adapter structure.
+* - pvBuffer: Starting address of Statistic response data.
+*
+* Returns - None.
+************************************************************************/
+VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer)
+{
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s====>",__FUNCTION__);
+ Adapter->StatisticsPointer = ntohl(*(PULONG)pvBuffer);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Stats at %lx", Adapter->StatisticsPointer);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "%s <====",__FUNCTION__);
+ return;
+}
+
+
+/**********************************************************************
+* Function - LinkControlResponseMessage()
+*
+* Description - This function handles the Link response packets.
+*
+* Parameters - Adapter : Pointer to the Adapter structure.
+* - pucBuffer: Starting address of Link response data.
+*
+* Returns - None.
+***********************************************************************/
+VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter,PUCHAR pucBuffer)
+{
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "=====>");
+
+ if(*pucBuffer==LINK_UP_ACK)
+ {
+ switch(*(pucBuffer+1))
+ {
+ case PHY_SYNC_ACHIVED: //SYNCed UP
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHY_SYNC_ACHIVED");
+
+ if(Adapter->LinkStatus == LINKUP_DONE)
+ {
+ beceem_protocol_reset(Adapter);
+ }
+
+ Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ;
+ Adapter->LinkStatus=PHY_SYNC_ACHIVED;
+
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ Adapter->DriverState = NO_NETWORK_ENTRY;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+
+ LinkMessage(Adapter);
+ break;
+
+ case LINKUP_DONE:
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "LINKUP_DONE");
+ Adapter->LinkStatus=LINKUP_DONE;
+ Adapter->bPHSEnabled = *(pucBuffer+3);
+ Adapter->bETHCSEnabled = *(pucBuffer+4) & ETH_CS_MASK;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "PHS Support Status Recieved In LinkUp Ack : %x \n",Adapter->bPHSEnabled);
+ if((FALSE == Adapter->bShutStatus)&&
+ (FALSE == Adapter->IdleMode))
+ {
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ Adapter->DriverState = NORMAL_OPERATION;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+ }
+ LinkMessage(Adapter);
+ break;
+ case WAIT_FOR_SYNC:
+
+ /*
+ * Driver to ignore the DREG_RECEIVED
+ * WiMAX Application should handle this Message
+ */
+ //Adapter->liTimeSinceLastNetEntry = 0;
+ Adapter->LinkUpStatus = 0;
+ Adapter->LinkStatus = 0;
+ Adapter->usBestEffortQueueIndex=INVALID_QUEUE_INDEX ;
+ Adapter->bTriedToWakeUpFromlowPowerMode = FALSE;
+ Adapter->IdleMode = FALSE;
+ beceem_protocol_reset(Adapter);
+
+ break;
+ case LINK_SHUTDOWN_REQ_FROM_FIRMWARE:
+ case COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW:
+ {
+ HandleShutDownModeRequest(Adapter, pucBuffer);
+ }
+ break;
+ default:
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "default case:LinkResponse %x",*(pucBuffer+1));
+ break;
+ }
+ }
+ else if(SET_MAC_ADDRESS_RESPONSE==*pucBuffer)
+ {
+ PUCHAR puMacAddr = (pucBuffer + 1);
+ Adapter->LinkStatus=SYNC_UP_REQUEST;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "MAC address response, sending SYNC_UP");
+ LinkMessage(Adapter);
+ memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "%s <=====",__FUNCTION__);
+ return;
+}
+
+void SendIdleModeResponse(PMINI_ADAPTER Adapter)
+{
+ INT status = 0, NVMAccess = 0,lowPwrAbortMsg = 0;
+ struct timeval tv;
+ CONTROL_MESSAGE stIdleResponse = {{0}};
+ memset(&tv, 0, sizeof(tv));
+ stIdleResponse.Leader.Status = IDLE_MESSAGE;
+ stIdleResponse.Leader.PLength = IDLE_MODE_PAYLOAD_LENGTH;
+ stIdleResponse.szData[0] = GO_TO_IDLE_MODE_PAYLOAD;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL," ============>");
+
+ /*********************************
+ **down_trylock -
+ ** if [ semaphore is available ]
+ ** acquire semaphone and return value 0 ;
+ ** else
+ ** return non-zero value ;
+ **
+ ***********************************/
+
+ NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
+
+ lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync);
+
+
+ if((NVMAccess || lowPwrAbortMsg || atomic_read(&Adapter->TotalPacketCount)) &&
+ (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) )
+ {
+ if(!NVMAccess)
+ up(&Adapter->NVMRdmWrmLock);
+
+ if(!lowPwrAbortMsg)
+ up(&Adapter->LowPowerModeSync);
+
+ stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on.
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "HOST IS NACKING Idle mode To F/W!!!!!!!!");
+ Adapter->bPreparingForLowPowerMode = FALSE;
+ }
+ else
+ {
+ stIdleResponse.szData[1] = TARGET_CAN_GO_TO_IDLE_MODE; //2;//Idle ACK
+ Adapter->StatisticsPointer = 0;
+
+ /* Wait for the LED to TURN OFF before sending ACK response */
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ INT iRetVal = 0;
+
+ /* Wake the LED Thread with IDLEMODE_ENTER State */
+ Adapter->DriverState = LOWPOWER_MODE_ENTER;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"LED Thread is Running..Hence Setting LED Event as IDLEMODE_ENTER jiffies:%ld",jiffies);;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+
+ /* Wait for 1 SEC for LED to OFF */
+ iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent, \
+ Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000));
+
+
+ /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
+ if(iRetVal <= 0)
+ {
+ stIdleResponse.szData[1] = TARGET_CAN_NOT_GO_TO_IDLE_MODE;//NACK- device access is going on.
+ Adapter->DriverState = NORMAL_OPERATION;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "NACKING Idle mode as time out happen from LED side!!!!!!!!");
+ }
+ }
+ if(stIdleResponse.szData[1] == TARGET_CAN_GO_TO_IDLE_MODE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL,"ACKING IDLE MODE !!!!!!!!!");
+ down(&Adapter->rdmwrmsync);
+ Adapter->bPreparingForLowPowerMode = TRUE;
+ up(&Adapter->rdmwrmsync);
+#ifndef BCM_SHM_INTERFACE
+ //Killing all URBS.
+ if(Adapter->bDoSuspend == TRUE)
+ Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
+
+#endif
+ }
+ else
+ {
+ Adapter->bPreparingForLowPowerMode = FALSE;
+ }
+
+ if(!NVMAccess)
+ up(&Adapter->NVMRdmWrmLock);
+
+ if(!lowPwrAbortMsg)
+ up(&Adapter->LowPowerModeSync);
+
+ }
+ status = CopyBufferToControlPacket(Adapter,&stIdleResponse);
+ if((status != STATUS_SUCCESS))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"fail to send the Idle mode Request \n");
+ Adapter->bPreparingForLowPowerMode = FALSE;
+#ifndef BCM_SHM_INTERFACE
+ StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
+#endif
+ }
+ do_gettimeofday(&tv);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_RX, RX_DPC, DBG_LVL_ALL, "IdleMode Msg submitter to Q :%ld ms", tv.tv_sec *1000 + tv.tv_usec /1000);
+
+}
+
+/******************************************************************
+* Function - DumpPackInfo()
+*
+* Description - This function dumps the all Queue(PackInfo[]) details.
+*
+* Parameters - Adapter: Pointer to the Adapter structure.
+*
+* Returns - None.
+*******************************************************************/
+VOID DumpPackInfo(PMINI_ADAPTER Adapter)
+{
+
+ UINT uiLoopIndex = 0;
+ UINT uiIndex = 0;
+ UINT uiClsfrIndex = 0;
+ S_CLASSIFIER_RULE *pstClassifierEntry = NULL;
+
+ for(uiLoopIndex=0;uiLoopIndex<NO_OF_QUEUES;uiLoopIndex++)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"*********** Showing Details Of Queue %d***** ******",uiLoopIndex);
+ if(FALSE == Adapter->PackInfo[uiLoopIndex].bValid)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid is FALSE for %X index\n",uiLoopIndex);
+ continue;
+ }
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," Dumping SF Rule Entry For SFID %lX \n",Adapter->PackInfo[uiLoopIndex].ulSFID);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," ucDirection %X \n",Adapter->PackInfo[uiLoopIndex].ucDirection);
+ if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv6 Service Flow \n");
+ }
+ else
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Ipv4 Service Flow \n");
+ }
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," SF Traffic Priority %X \n",Adapter->PackInfo[uiLoopIndex].u8TrafficPriority);
+
+ for(uiClsfrIndex=0;uiClsfrIndex<MAX_CLASSIFIERS;uiClsfrIndex++)
+ {
+ pstClassifierEntry = &Adapter->astClassifierTable[uiClsfrIndex];
+ if(!pstClassifierEntry->bUsed)
+ continue;
+
+ if(pstClassifierEntry->ulSFID != Adapter->PackInfo[uiLoopIndex].ulSFID)
+ continue;
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X Classifier Rule ID : %X\n",uiClsfrIndex,pstClassifierEntry->uiClassifierRuleIndex);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X usVCID_Value : %X\n",uiClsfrIndex,pstClassifierEntry->usVCID_Value);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bProtocolValid : %X\n",uiClsfrIndex,pstClassifierEntry->bProtocolValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bTOSValid : %X\n",uiClsfrIndex,pstClassifierEntry->bTOSValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bDestIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bDestIpValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tDumping Classifier Rule Entry For Index: %X bSrcIpValid : %X\n",uiClsfrIndex,pstClassifierEntry->bSrcIpValid);
+
+
+ for(uiIndex=0;uiIndex<MAX_PORT_RANGE;uiIndex++)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusSrcPortRangeLo:%X\n",pstClassifierEntry->usSrcPortRangeLo[uiIndex]);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusSrcPortRangeHi:%X\n",pstClassifierEntry->usSrcPortRangeHi[uiIndex]);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeLo:%X\n",pstClassifierEntry->usDestPortRangeLo[uiIndex]);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tusDestPortRangeHi:%X\n",pstClassifierEntry->usDestPortRangeHi[uiIndex]);
+ }
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL," \tucIPSourceAddressLength : 0x%x\n",pstClassifierEntry->ucIPSourceAddressLength);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucIPDestinationAddressLength : 0x%x\n",pstClassifierEntry->ucIPDestinationAddressLength);
+ for(uiIndex=0;uiIndex<pstClassifierEntry->ucIPSourceAddressLength;uiIndex++)
+ {
+ if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpAddr :\n");
+ DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Addr);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulSrcIpMask :\n");
+ DumpIpv6Address(pstClassifierEntry->stSrcIpAddress.ulIpv6Mask);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpAddr:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Addr[uiIndex]);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulSrcIpMask:%lX\n",pstClassifierEntry->stSrcIpAddress.ulIpv4Mask[uiIndex]);
+ }
+ }
+ for(uiIndex=0;uiIndex<pstClassifierEntry->ucIPDestinationAddressLength;uiIndex++)
+ {
+ if(Adapter->PackInfo[uiLoopIndex].ucIpVersion == IPV6)
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpAddr :\n");
+ DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Addr);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tIpv6 ulDestIpMask :\n");
+ DumpIpv6Address(pstClassifierEntry->stDestIpAddress.ulIpv6Mask);
+
+ }
+ else
+ {
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpAddr:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Addr[uiIndex]);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tulDestIpMask:%lX\n",pstClassifierEntry->stDestIpAddress.ulIpv4Mask[uiIndex]);
+ }
+ }
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tucProtocol:0x%X\n",pstClassifierEntry->ucProtocol[0]);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"\tu8ClassifierRulePriority:%X\n",pstClassifierEntry->u8ClassifierRulePriority);
+
+
+ }
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ulSFID:%lX\n",Adapter->PackInfo[uiLoopIndex].ulSFID);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"usVCID_Value:%X\n",Adapter->PackInfo[uiLoopIndex].usVCID_Value);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"PhsEnabled: 0x%X\n",Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThreshold:%X\n",Adapter->PackInfo[uiLoopIndex].uiThreshold);
+
+
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bValid:%X\n",Adapter->PackInfo[uiLoopIndex].bValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"bActive:%X\n",Adapter->PackInfo[uiLoopIndex].bActive);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"ActivateReqSent: %x", Adapter->PackInfo[uiLoopIndex].bActivateRequestSent);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"u8QueueType:%X\n",Adapter->PackInfo[uiLoopIndex].u8QueueType);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxBucketSize:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxBucketSize);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPerSFTxResourceCount:%X\n",atomic_read(&Adapter->PackInfo[uiLoopIndex].uiPerSFTxResourceCount));
+ //DumpDebug(DUMP_INFO,(" bCSSupport:%X\n",Adapter->PackInfo[uiLoopIndex].bCSSupport));
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"CurrQueueDepthOnTarget: %x\n", Adapter->PackInfo[uiLoopIndex].uiCurrentQueueDepthOnTarget);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentBytesOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentBytesOnHost);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentPacketsOnHost:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentPacketsOnHost);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountBytes);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiDroppedCountPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiDroppedCountPackets);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentBytes);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiSentPackets:%X\n",Adapter->PackInfo[uiLoopIndex].uiSentPackets);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentDrainRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentDrainRate);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiThisPeriodSentBytes:%X\n",Adapter->PackInfo[uiLoopIndex].uiThisPeriodSentBytes);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liDrainCalculated:%llX\n",Adapter->PackInfo[uiLoopIndex].liDrainCalculated);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiCurrentTokenCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiCurrentTokenCount);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"liLastUpdateTokenAt:%llX\n",Adapter->PackInfo[uiLoopIndex].liLastUpdateTokenAt);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiMaxAllowedRate:%X\n",Adapter->PackInfo[uiLoopIndex].uiMaxAllowedRate);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"uiPendedLast:%X\n",Adapter->PackInfo[uiLoopIndex].uiPendedLast);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"NumOfPacketsSent:%X\n",Adapter->PackInfo[uiLoopIndex].NumOfPacketsSent);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Direction: %x\n", Adapter->PackInfo[uiLoopIndex].ucDirection);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "CID: %x\n", Adapter->PackInfo[uiLoopIndex].usCID);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ProtocolValid: %x\n", Adapter->PackInfo[uiLoopIndex].bProtocolValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "TOSValid: %x\n", Adapter->PackInfo[uiLoopIndex].bTOSValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "DestIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bDestIpValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "SrcIpValid: %x\n", Adapter->PackInfo[uiLoopIndex].bSrcIpValid);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ActiveSet: %x\n", Adapter->PackInfo[uiLoopIndex].bActiveSet);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AdmittedSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAdmittedSet);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "AuthzSet: %x\n", Adapter->PackInfo[uiLoopIndex].bAuthorizedSet);
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ClassifyPrority: %x\n", Adapter->PackInfo[uiLoopIndex].bClassifierPriority);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiMaxLatency: %x\n",Adapter->PackInfo[uiLoopIndex].uiMaxLatency);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "ServiceClassName: %x %x %x %x\n",Adapter->PackInfo[uiLoopIndex].ucServiceClassName[0],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[1],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[2],Adapter->PackInfo[uiLoopIndex].ucServiceClassName[3]);
+// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "bHeaderSuppressionEnabled :%X\n", Adapter->PackInfo[uiLoopIndex].bHeaderSuppressionEnabled);
+// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalTxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalTxBytes);
+// BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "uiTotalRxBytes:%X\n", Adapter->PackInfo[uiLoopIndex].uiTotalRxBytes);
+// DumpDebug(DUMP_INFO,(" uiRanOutOfResCount:%X\n",Adapter->PackInfo[uiLoopIndex].uiRanOutOfResCount));
+ }
+
+ for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++)
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aRxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aRxPktSizeHist[uiLoopIndex]);
+
+ for(uiLoopIndex = 0 ; uiLoopIndex < MIBS_MAX_HIST_ENTRIES ; uiLoopIndex++)
+ BCM_DEBUG_PRINT (Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL,"Adapter->aTxPktSizeHist[%x] = %x\n",uiLoopIndex,Adapter->aTxPktSizeHist[uiLoopIndex]);
+
+
+
+ return;
+
+
+}
+
+
+__inline int reset_card_proc(PMINI_ADAPTER ps_adapter)
+{
+ int retval = STATUS_SUCCESS;
+
+#ifndef BCM_SHM_INTERFACE
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
+ unsigned int value = 0, uiResetValue = 0;
+
+ psIntfAdapter = ((PS_INTERFACE_ADAPTER)(ps_adapter->pvInterfaceAdapter)) ;
+
+ ps_adapter->bDDRInitDone = FALSE;
+
+ if(ps_adapter->chip_id >= T3LPB)
+ {
+ //SYS_CFG register is write protected hence for modifying this reg value, it should be read twice before
+ rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value));
+ rdmalt(ps_adapter,SYS_CFG, &value, sizeof(value));
+
+ //making bit[6...5] same as was before f/w download. this setting force the h/w to
+ //re-populated the SP RAM area with the string descriptor .
+ value = value | (ps_adapter->syscfgBefFwDld & 0x00000060) ;
+ wrmalt(ps_adapter, SYS_CFG, &value, sizeof(value));
+ }
+
+#ifndef BCM_SHM_INTERFACE
+ //killing all submitted URBs.
+ psIntfAdapter->psAdapter->StopAllXaction = TRUE ;
+ Bcm_kill_all_URBs(psIntfAdapter);
+#endif
+ /* Reset the UMA-B Device */
+ if(ps_adapter->chip_id >= T3LPB)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reseting UMA-B \n");
+ retval = usb_reset_device(psIntfAdapter->udev);
+
+ psIntfAdapter->psAdapter->StopAllXaction = FALSE ;
+
+ if(retval != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Reset failed with ret value :%d", retval);
+ goto err_exit;
+ }
+ if (ps_adapter->chip_id == BCS220_2 ||
+ ps_adapter->chip_id == BCS220_2BC ||
+ ps_adapter->chip_id == BCS250_BC ||
+ ps_adapter->chip_id == BCS220_3)
+ {
+ retval = rdmalt(ps_adapter,HPM_CONFIG_LDO145, &value, sizeof(value));
+ if( retval < 0)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval);
+ goto err_exit;
+ }
+ //setting 0th bit
+ value |= (1<<0);
+ retval = wrmalt(ps_adapter, HPM_CONFIG_LDO145, &value, sizeof(value));
+ if( retval < 0)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
+ goto err_exit;
+ }
+ }
+
+ }
+ else
+ {
+ retval = rdmalt(ps_adapter,0x0f007018, &value, sizeof(value));
+ if( retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"read failed with status :%d",retval);
+ goto err_exit;
+ }
+ value&=(~(1<<16));
+ retval= wrmalt(ps_adapter, 0x0f007018, &value, sizeof(value)) ;
+ if( retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
+ goto err_exit;
+ }
+
+ // Toggling the GPIO 8, 9
+ value = 0;
+ retval = wrmalt(ps_adapter, GPIO_OUTPUT_REGISTER, &value, sizeof(value));
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
+ goto err_exit;
+ }
+ value = 0x300;
+ retval = wrmalt(ps_adapter, GPIO_MODE_REGISTER, &value, sizeof(value)) ;
+ if(retval < 0) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"write failed with status :%d",retval);
+ goto err_exit;
+ }
+ mdelay(50);
+ }
+
+ //ps_adapter->downloadDDR = false;
+
+ if(ps_adapter->bFlashBoot)
+ {
+ //In flash boot mode MIPS state register has reverse polarity.
+ // So just or with setting bit 30.
+ //Make the MIPS in Reset state.
+ rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue));
+
+ uiResetValue |=(1<<30);
+ wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &uiResetValue, sizeof(uiResetValue));
+ }
+
+ if(ps_adapter->chip_id >= T3LPB)
+ {
+ uiResetValue = 0;
+ //
+ // WA for SYSConfig Issue.
+ // Read SYSCFG Twice to make it writable.
+ //
+ rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));
+ if(uiResetValue & (1<<4))
+ {
+ uiResetValue = 0;
+ rdmalt(ps_adapter, SYS_CFG, &uiResetValue, sizeof(uiResetValue));//2nd read to make it writable.
+ uiResetValue &= (~(1<<4));
+ wrmalt(ps_adapter,SYS_CFG, &uiResetValue, sizeof(uiResetValue));
+ }
+
+ }
+ uiResetValue = 0;
+ wrmalt(ps_adapter, 0x0f01186c, &uiResetValue, sizeof(uiResetValue));
+
+err_exit :
+ psIntfAdapter->psAdapter->StopAllXaction = FALSE ;
+#endif
+ return retval;
+}
+
+__inline int run_card_proc(PMINI_ADAPTER ps_adapter )
+{
+ unsigned int value=0;
+ {
+
+ if(rdmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__);
+ return STATUS_FAILURE;
+ }
+
+ if(ps_adapter->bFlashBoot)
+ {
+
+ value&=(~(1<<30));
+ }
+ else
+ {
+ value |=(1<<30);
+ }
+
+ if(wrmalt(ps_adapter, CLOCK_RESET_CNTRL_REG_1, &value, sizeof(value)) < 0) {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"%s:%d\n", __FUNCTION__, __LINE__);
+ return STATUS_FAILURE;
+ }
+ }
+ return STATUS_SUCCESS;
+}
+
+int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter)
+{
+
+ UINT status = STATUS_SUCCESS;
+ UINT value = 0;
+#ifdef BCM_SHM_INTERFACE
+ unsigned char *pConfigFileAddr = (unsigned char *)CPE_MACXVI_CFG_ADDR;
+#endif
+ /*
+ * Create the threads first and then download the
+ * Firm/DDR Settings..
+ */
+
+ if((status = create_worker_threads(ps_adapter))<0)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Cannot create thread");
+ return status;
+ }
+ /*
+ * For Downloading the Firm, parse the cfg file first.
+ */
+ status = bcm_parse_target_params (ps_adapter);
+ if(status){
+ return status;
+ }
+
+#ifndef BCM_SHM_INTERFACE
+ if(ps_adapter->chip_id >= T3LPB)
+ {
+ rdmalt(ps_adapter, SYS_CFG, &value, sizeof (value));
+ ps_adapter->syscfgBefFwDld = value ;
+ if((value & 0x60)== 0)
+ {
+ ps_adapter->bFlashBoot = TRUE;
+ }
+ }
+
+ reset_card_proc(ps_adapter);
+
+ //Initializing the NVM.
+ BcmInitNVM(ps_adapter);
+ status = ddr_init(ps_adapter);
+ if(status)
+ {
+ BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "ddr_init Failed\n");
+ return status;
+ }
+
+ /* Download cfg file */
+ status = buffDnldVerify(ps_adapter,
+ (PUCHAR)ps_adapter->pstargetparams,
+ sizeof(STARGETPARAMS),
+ CONFIG_BEGIN_ADDR);
+ if(status)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Error downloading CFG file");
+ goto OUT;
+ }
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "CFG file downloaded");
+
+ if(register_networkdev(ps_adapter))
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed.");
+ return -EIO;
+ }
+
+ if(FALSE == ps_adapter->AutoFirmDld)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoFirmDld Disabled in CFG File..\n");
+ //If Auto f/w download is disable, register the control interface,
+ //register the control interface after the mailbox.
+ if(register_control_device_interface(ps_adapter) < 0)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed.");
+ return -EIO;
+ }
+
+ return STATUS_SUCCESS;
+ }
+
+ /*
+ * Do the LED Settings here. It will be used by the Firmware Download
+ * Thread.
+ */
+
+ /*
+ * 1. If the LED Settings fails, do not stop and do the Firmware download.
+ * 2. This init would happend only if the cfg file is present, else
+ * call from the ioctl context.
+ */
+
+ status = InitLedSettings (ps_adapter);
+
+ if(status)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n");
+ return status;
+ }
+ if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ ps_adapter->DriverState = DRIVER_INIT;
+ wake_up(&ps_adapter->LEDInfo.notify_led_event);
+ }
+
+ if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ ps_adapter->DriverState = FW_DOWNLOAD;
+ wake_up(&ps_adapter->LEDInfo.notify_led_event);
+ }
+
+ value = 0;
+ wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
+ wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
+
+ if(ps_adapter->eNVMType == NVM_FLASH)
+ {
+ status = PropagateCalParamsFromFlashToMemory(ps_adapter);
+ if(status)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL," Propogation of Cal param failed .." );
+ goto OUT;
+ }
+ }
+#if 0
+ else if(psAdapter->eNVMType == NVM_EEPROM)
+ {
+ PropagateCalParamsFromEEPROMToMemory();
+ }
+#endif
+
+ /* Download Firmare */
+ if ((status = BcmFileDownload( ps_adapter, BIN_FILE, FIRMWARE_BEGIN_ADDR)))
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "No Firmware File is present... \n");
+ goto OUT;
+ }
+
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "BIN file downloaded");
+ status = run_card_proc(ps_adapter);
+ if(status)
+ {
+ BCM_DEBUG_PRINT (ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "run_card_proc Failed\n");
+ goto OUT;
+ }
+
+
+ ps_adapter->fw_download_done = TRUE;
+ mdelay(10);
+
+OUT:
+ if(ps_adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ ps_adapter->DriverState = FW_DOWNLOAD_DONE;
+ wake_up(&ps_adapter->LEDInfo.notify_led_event);
+ }
+
+#else
+
+ ps_adapter->bDDRInitDone = TRUE;
+ //Initializing the NVM.
+ BcmInitNVM(ps_adapter);
+
+ //Propagating the cal param from Flash to DDR
+ value = 0;
+ wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 4, &value, sizeof(value));
+ wrmalt(ps_adapter, EEPROM_CAL_DATA_INTERNAL_LOC - 8, &value, sizeof(value));
+
+ if(ps_adapter->eNVMType == NVM_FLASH)
+ {
+ status = PropagateCalParamsFromFlashToMemory(ps_adapter);
+ if(status)
+ {
+ printk("\nPropogation of Cal param from flash to DDR failed ..\n" );
+ }
+ }
+
+ //Copy config file param to DDR.
+ memcpy(pConfigFileAddr,ps_adapter->pstargetparams, sizeof(STARGETPARAMS));
+
+ if(register_networkdev(ps_adapter))
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Netdevice failed. Cleanup needs to be performed.");
+ return -EIO;
+ }
+
+
+ status = InitLedSettings (ps_adapter);
+ if(status)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_PRINTK, 0, 0,"INIT LED FAILED\n");
+ return status;
+ }
+
+
+ if(register_control_device_interface(ps_adapter) < 0)
+ {
+ BCM_DEBUG_PRINT(ps_adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Register Control Device failed. Cleanup needs to be performed.");
+ return -EIO;
+ }
+
+ ps_adapter->fw_download_done = TRUE;
+#endif
+ return status;
+}
+
+
+int bcm_parse_target_params(PMINI_ADAPTER Adapter)
+{
+#ifdef BCM_SHM_INTERFACE
+ extern void read_cfg_file(PMINI_ADAPTER Adapter);
+#endif
+ struct file *flp=NULL;
+ mm_segment_t oldfs={0};
+ char *buff = NULL;
+ int len = 0;
+ loff_t pos = 0;
+
+ buff=(PCHAR)kmalloc(BUFFER_1K, GFP_KERNEL);
+ if(!buff)
+ {
+ return -ENOMEM;
+ }
+ if((Adapter->pstargetparams =
+ kmalloc(sizeof(STARGETPARAMS), GFP_KERNEL)) == NULL)
+ {
+ bcm_kfree(buff);
+ return -ENOMEM;
+ }
+ flp=open_firmware_file(Adapter, CFG_FILE);
+ if(!flp) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "NOT ABLE TO OPEN THE %s FILE \n", CFG_FILE);
+ bcm_kfree(buff);
+ bcm_kfree(Adapter->pstargetparams);
+ Adapter->pstargetparams = NULL;
+ return -ENOENT;
+ }
+ oldfs=get_fs(); set_fs(get_ds());
+ len=vfs_read(flp, buff, BUFFER_1K, &pos);
+ set_fs(oldfs);
+
+ if(len != sizeof(STARGETPARAMS))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Mismatch in Target Param Structure!\n");
+ bcm_kfree(buff);
+ bcm_kfree(Adapter->pstargetparams);
+ Adapter->pstargetparams = NULL;
+ filp_close(flp, current->files);
+ return -ENOENT;
+ }
+ filp_close(flp, current->files);
+
+ /* Check for autolink in config params */
+ /*
+ * Values in Adapter->pstargetparams are in network byte order
+ */
+ memcpy(Adapter->pstargetparams, buff, sizeof(STARGETPARAMS));
+ bcm_kfree (buff);
+ beceem_parse_target_struct(Adapter);
+#ifdef BCM_SHM_INTERFACE
+ read_cfg_file(Adapter);
+
+#endif
+ return STATUS_SUCCESS;
+}
+
+void beceem_parse_target_struct(PMINI_ADAPTER Adapter)
+{
+ UINT uiHostDrvrCfg6 =0, uiEEPROMFlag = 0;;
+
+ if(ntohl(Adapter->pstargetparams->m_u32PhyParameter2) & AUTO_SYNC_DISABLE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Disabled\n");
+ Adapter->AutoSyncup = FALSE;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "AutoSyncup is Enabled\n");
+ Adapter->AutoSyncup = TRUE;
+ }
+ if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_LINKUP_ENABLE)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling autolink up");
+ Adapter->AutoLinkUp = TRUE;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling autolink up");
+ Adapter->AutoLinkUp = FALSE;
+ }
+ // Setting the DDR Setting..
+ Adapter->DDRSetting =
+ (ntohl(Adapter->pstargetparams->HostDrvrConfig6) >>8)&0x0F;
+ Adapter->ulPowerSaveMode =
+ (ntohl(Adapter->pstargetparams->HostDrvrConfig6)>>12)&0x0F;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "DDR Setting: %x\n", Adapter->DDRSetting);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT,DBG_LVL_ALL, "Power Save Mode: %lx\n",
+ Adapter->ulPowerSaveMode);
+ if(ntohl(Adapter->pstargetparams->HostDrvrConfig6) & AUTO_FIRM_DOWNLOAD)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Enabling Auto Firmware Download\n");
+ Adapter->AutoFirmDld = TRUE;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Disabling Auto Firmware Download\n");
+ Adapter->AutoFirmDld = FALSE;
+ }
+ uiHostDrvrCfg6 = ntohl(Adapter->pstargetparams->HostDrvrConfig6);
+ Adapter->bMipsConfig = (uiHostDrvrCfg6>>20)&0x01;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"MIPSConfig : 0x%X\n",Adapter->bMipsConfig);
+ //used for backward compatibility.
+ Adapter->bDPLLConfig = (uiHostDrvrCfg6>>19)&0x01;
+
+ Adapter->PmuMode= (uiHostDrvrCfg6 >> 24 ) & 0x03;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "PMU MODE: %x", Adapter->PmuMode);
+
+ if((uiHostDrvrCfg6 >> HOST_BUS_SUSPEND_BIT ) & (0x01))
+ {
+ Adapter->bDoSuspend = TRUE;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Making DoSuspend TRUE as per configFile");
+ }
+
+ uiEEPROMFlag = ntohl(Adapter->pstargetparams->m_u32EEPROMFlag);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "uiEEPROMFlag : 0x%X\n",uiEEPROMFlag);
+ Adapter->eNVMType = (NVM_TYPE)((uiEEPROMFlag>>4)&0x3);
+
+
+ Adapter->bStatusWrite = (uiEEPROMFlag>>6)&0x1;
+ //printk(("bStatusWrite : 0x%X\n", Adapter->bStatusWrite));
+
+ Adapter->uiSectorSizeInCFG = 1024*(0xFFFF & ntohl(Adapter->pstargetparams->HostDrvrConfig4));
+ //printk(("uiSectorSize : 0x%X\n", Adapter->uiSectorSizeInCFG));
+
+ Adapter->bSectorSizeOverride =(bool) ((ntohl(Adapter->pstargetparams->HostDrvrConfig4))>>16)&0x1;
+ //printk(MP_INIT,("bSectorSizeOverride : 0x%X\n",Adapter->bSectorSizeOverride));
+
+ if(ntohl(Adapter->pstargetparams->m_u32PowerSavingModeOptions) &0x01)
+ Adapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE;
+ //autocorrection part
+ if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
+ doPowerAutoCorrection(Adapter);
+
+}
+
+VOID doPowerAutoCorrection(PMINI_ADAPTER psAdapter)
+{
+ UINT reporting_mode = 0;
+
+ reporting_mode = ntohl(psAdapter->pstargetparams->m_u32PowerSavingModeOptions) &0x02 ;
+ psAdapter->bIsAutoCorrectEnabled = !((char)(psAdapter->ulPowerSaveMode >> 3) & 0x1);
+
+ if(reporting_mode == TRUE)
+ {
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"can't do suspen/resume as reporting mode is enable");
+ psAdapter->bDoSuspend = FALSE;
+ }
+
+ if (psAdapter->bIsAutoCorrectEnabled && (psAdapter->chip_id >= T3LPB))
+ {
+ //If reporting mode is enable, switch PMU to PMC
+ #if 0
+ if(reporting_mode == FALSE)
+ {
+ psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_SHUTDOWN;
+ psAdapter->bDoSuspend = TRUE;
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMU selected ....");
+
+ }
+ else
+ #endif
+ {
+ psAdapter->ulPowerSaveMode = DEVICE_POWERSAVE_MODE_AS_PMU_CLOCK_GATING;
+ psAdapter->bDoSuspend =FALSE;
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"PMC selected..");
+
+ }
+
+ //clearing space bit[15..12]
+ psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl((0xF << 12)));
+ //placing the power save mode option
+ psAdapter->pstargetparams->HostDrvrConfig6 |= htonl((psAdapter->ulPowerSaveMode << 12));
+
+ }
+ else if (psAdapter->bIsAutoCorrectEnabled == FALSE)
+ {
+
+ // remove the autocorrect disable bit set before dumping.
+ psAdapter->ulPowerSaveMode &= ~(1 << 3);
+ psAdapter->pstargetparams->HostDrvrConfig6 &= ~(htonl(1 << 15));
+ BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL,"Using Forced User Choice: %lx\n", psAdapter->ulPowerSaveMode);
+ }
+}
+unsigned char *ReadMacAddrEEPROM(PMINI_ADAPTER Adapter, ulong dwAddress)
+{
+ unsigned char *pucmacaddr = NULL;
+ int status = 0, i=0;
+ unsigned int temp =0;
+
+
+ pucmacaddr = (unsigned char *)kmalloc(MAC_ADDRESS_SIZE, GFP_KERNEL);
+ if(!pucmacaddr)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "No Buffers to Read the EEPROM Address\n");
+ return NULL;
+ }
+
+ dwAddress |= 0x5b000000;
+ status = wrmalt(Adapter, EEPROM_COMMAND_Q_REG,
+ (PUINT)&dwAddress, sizeof(UINT));
+ if(status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "wrm Failed..\n");
+ bcm_kfree(pucmacaddr);
+ pucmacaddr = NULL;
+ goto OUT;
+ }
+ for(i=0;i<MAC_ADDRESS_SIZE;i++)
+ {
+ status = rdmalt(Adapter, EEPROM_READ_DATA_Q_REG, &temp,sizeof(temp));
+ if(status != STATUS_SUCCESS)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm Failed..\n");
+ bcm_kfree(pucmacaddr);
+ pucmacaddr = NULL;
+ goto OUT;
+ }
+ pucmacaddr[i] = temp & 0xff;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL,"%x \n", pucmacaddr[i]);
+ }
+OUT:
+ return pucmacaddr;
+}
+
+#if 0
+INT ReadMacAddressFromEEPROM(PMINI_ADAPTER Adapter)
+{
+ unsigned char *puMacAddr = NULL;
+ int i =0;
+
+ puMacAddr = ReadMacAddrEEPROM(Adapter,0x200);
+ if(!puMacAddr)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Couldn't retrieve the Mac Address\n");
+ return STATUS_FAILURE;
+ }
+ else
+ {
+ if((puMacAddr[0] == 0x0 && puMacAddr[1] == 0x0 &&
+ puMacAddr[2] == 0x0 && puMacAddr[3] == 0x0 &&
+ puMacAddr[4] == 0x0 && puMacAddr[5] == 0x0) ||
+ (puMacAddr[0] == 0xFF && puMacAddr[1] == 0xFF &&
+ puMacAddr[2] == 0xFF && puMacAddr[3] == 0xFF &&
+ puMacAddr[4] == 0xFF && puMacAddr[5] == 0xFF))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "Invalid Mac Address\n");
+ bcm_kfree(puMacAddr);
+ return STATUS_FAILURE;
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "The Mac Address received is: \n");
+ memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE);
+ for(i=0;i<MAC_ADDRESS_SIZE;i++)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%02x ", Adapter->dev->dev_addr[i]);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"\n");
+ bcm_kfree(puMacAddr);
+ }
+ return STATUS_SUCCESS;
+}
+#endif
+
+void convertEndian(B_UINT8 rwFlag, PUINT puiBuffer, UINT uiByteCount)
+{
+ UINT uiIndex = 0;
+
+ if(RWM_WRITE == rwFlag) {
+ for(uiIndex =0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) {
+ puiBuffer[uiIndex] = htonl(puiBuffer[uiIndex]);
+ }
+ } else {
+ for(uiIndex =0; uiIndex < (uiByteCount/sizeof(UINT)); uiIndex++) {
+ puiBuffer[uiIndex] = ntohl(puiBuffer[uiIndex]);
+ }
+ }
+}
+
+#define CACHE_ADDRESS_MASK 0x80000000
+#define UNCACHE_ADDRESS_MASK 0xa0000000
+
+int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
+{
+ INT uiRetVal =0;
+
+#ifndef BCM_SHM_INTERFACE
+ uiRetVal = Adapter->interface_rdm(Adapter->pvInterfaceAdapter,
+ uiAddress, pucBuff, sSize);
+
+ if(uiRetVal < 0)
+ return uiRetVal;
+
+#else
+ int indx;
+ uiRetVal = STATUS_SUCCESS;
+ if(uiAddress & 0x10000000) {
+ // DDR Memory Access
+ uiAddress |= CACHE_ADDRESS_MASK;
+ memcpy(pucBuff,(unsigned char *)uiAddress ,sSize);
+ }
+ else {
+ // Register, SPRAM, Flash
+ uiAddress |= UNCACHE_ADDRESS_MASK;
+ if ((uiAddress & FLASH_ADDR_MASK) == (FLASH_CONTIGIOUS_START_ADDR_BCS350 & FLASH_ADDR_MASK))
+ {
+ #if defined(FLASH_DIRECT_ACCESS)
+ memcpy(pucBuff,(unsigned char *)uiAddress ,sSize);
+ #else
+ printk("\nInvalid GSPI ACCESS :Addr :%#X", uiAddress);
+ uiRetVal = STATUS_FAILURE;
+ #endif
+ }
+ else if(((unsigned int )uiAddress & 0x3) ||
+ ((unsigned int )pucBuff & 0x3) ||
+ ((unsigned int )sSize & 0x3)) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"rdmalt :unalligned register access uiAddress = %x,pucBuff = %x size = %x\n",(unsigned int )uiAddress,(unsigned int )pucBuff,(unsigned int )sSize);
+ uiRetVal = STATUS_FAILURE;
+ }
+ else {
+ for (indx=0;indx<sSize;indx+=4){
+ *(PUINT)(pucBuff + indx) = *(PUINT)(uiAddress + indx);
+ }
+ }
+ }
+#endif
+ return uiRetVal;
+}
+int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
+{
+ int iRetVal;
+
+#ifndef BCM_SHM_INTERFACE
+ iRetVal = Adapter->interface_wrm(Adapter->pvInterfaceAdapter,
+ uiAddress, pucBuff, sSize);
+
+#else
+ int indx;
+ if(uiAddress & 0x10000000) {
+ // DDR Memory Access
+ uiAddress |= CACHE_ADDRESS_MASK;
+ memcpy((unsigned char *)(uiAddress),pucBuff,sSize);
+ }
+ else {
+ // Register, SPRAM, Flash
+ uiAddress |= UNCACHE_ADDRESS_MASK;
+
+ if(((unsigned int )uiAddress & 0x3) ||
+ ((unsigned int )pucBuff & 0x3) ||
+ ((unsigned int )sSize & 0x3)) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"wrmalt: unalligned register access uiAddress = %x,pucBuff = %x size = %x\n",(unsigned int )uiAddress,(unsigned int )pucBuff,(unsigned int )sSize);
+ iRetVal = STATUS_FAILURE;
+ }
+ else {
+ for (indx=0;indx<sSize;indx+=4) {
+ *(PUINT)(uiAddress + indx) = *(PUINT)(pucBuff + indx);
+ }
+ }
+ }
+ iRetVal = STATUS_SUCCESS;
+#endif
+
+ return iRetVal;
+}
+
+int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+{
+ convertEndian(RWM_WRITE, pucBuff, size);
+ return wrm(Adapter, uiAddress, (PUCHAR)pucBuff, size);
+}
+
+int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+{
+ INT uiRetVal =0;
+
+ uiRetVal = rdm(Adapter,uiAddress,(PUCHAR)pucBuff,size);
+ convertEndian(RWM_READ, (PUINT)pucBuff, size);
+
+ return uiRetVal;
+}
+
+int rdmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
+{
+
+ INT status = STATUS_SUCCESS ;
+ down(&Adapter->rdmwrmsync);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ status = -EACCES;
+ goto exit;
+ }
+
+ status = rdm(Adapter, uiAddress, pucBuff, sSize);
+
+exit:
+ up(&Adapter->rdmwrmsync);
+ return status ;
+}
+int wrmWithLock(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t sSize)
+{
+ INT status = STATUS_SUCCESS ;
+ down(&Adapter->rdmwrmsync);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ status = -EACCES;
+ goto exit;
+ }
+
+ status =wrm(Adapter, uiAddress, pucBuff, sSize);
+
+exit:
+ up(&Adapter->rdmwrmsync);
+ return status ;
+}
+
+int wrmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+{
+ int iRetVal = STATUS_SUCCESS;
+
+ down(&Adapter->rdmwrmsync);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ iRetVal = -EACCES;
+ goto exit;
+ }
+
+ iRetVal = wrmalt(Adapter,uiAddress,pucBuff,size);
+
+exit:
+ up(&Adapter->rdmwrmsync);
+ return iRetVal;
+}
+
+int rdmaltWithLock (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t size)
+{
+ INT uiRetVal =STATUS_SUCCESS;
+
+ down(&Adapter->rdmwrmsync);
+
+ if((Adapter->IdleMode == TRUE) ||
+ (Adapter->bShutStatus ==TRUE) ||
+ (Adapter->bPreparingForLowPowerMode ==TRUE))
+ {
+ uiRetVal = -EACCES;
+ goto exit;
+ }
+
+ uiRetVal = rdmalt(Adapter,uiAddress, pucBuff, size);
+
+exit:
+ up(&Adapter->rdmwrmsync);
+ return uiRetVal;
+}
+
+
+VOID HandleShutDownModeWakeup(PMINI_ADAPTER Adapter)
+{
+ int clear_abort_pattern = 0,Status = 0;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
+ //target has woken up From Shut Down
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Clearing Shut Down Software abort pattern\n");
+ Status = wrmalt(Adapter,SW_ABORT_IDLEMODE_LOC, (PUINT)&clear_abort_pattern, sizeof(clear_abort_pattern));
+ if(Status)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"WRM to SW_ABORT_IDLEMODE_LOC failed with err:%d", Status);
+ return;
+ }
+ if(Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)
+ {
+ msleep(100);
+ InterfaceHandleShutdownModeWakeup(Adapter);
+ msleep(100);
+ }
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ Adapter->DriverState = NO_NETWORK_ENTRY;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+
+ Adapter->bTriedToWakeUpFromlowPowerMode = FALSE;
+ Adapter->bShutStatus = FALSE;
+ wake_up(&Adapter->lowpower_mode_wait_queue);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
+}
+
+VOID SendShutModeResponse(PMINI_ADAPTER Adapter)
+{
+ CONTROL_MESSAGE stShutdownResponse;
+ UINT NVMAccess = 0,lowPwrAbortMsg = 0;
+ UINT Status = 0;
+
+ memset (&stShutdownResponse, 0, sizeof(CONTROL_MESSAGE));
+ stShutdownResponse.Leader.Status = LINK_UP_CONTROL_REQ;
+ stShutdownResponse.Leader.PLength = 8;//8 bytes;
+ stShutdownResponse.szData[0] = LINK_UP_ACK;
+ stShutdownResponse.szData[1] = LINK_SHUTDOWN_REQ_FROM_FIRMWARE;
+
+ /*********************************
+ **down_trylock -
+ ** if [ semaphore is available ]
+ ** acquire semaphone and return value 0 ;
+ ** else
+ ** return non-zero value ;
+ **
+ ***********************************/
+
+ NVMAccess = down_trylock(&Adapter->NVMRdmWrmLock);
+
+ lowPwrAbortMsg= down_trylock(&Adapter->LowPowerModeSync);
+
+
+ if(NVMAccess || lowPwrAbortMsg|| atomic_read(&Adapter->TotalPacketCount))
+ {
+ if(!NVMAccess)
+ up(&Adapter->NVMRdmWrmLock);
+
+ if(!lowPwrAbortMsg)
+ up(&Adapter->LowPowerModeSync);
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Device Access is going on NACK the Shut Down MODE\n");
+ stShutdownResponse.szData[2] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on.
+ Adapter->bPreparingForLowPowerMode = FALSE;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "Sending SHUTDOWN MODE ACK\n");
+ stShutdownResponse.szData[2] = SHUTDOWN_ACK_FROM_DRIVER;//ShutDown ACK
+
+ /* Wait for the LED to TURN OFF before sending ACK response */
+ if(Adapter->LEDInfo.led_thread_running & BCM_LED_THREAD_RUNNING_ACTIVELY)
+ {
+ INT iRetVal = 0;
+
+ /* Wake the LED Thread with LOWPOWER_MODE_ENTER State */
+ Adapter->DriverState = LOWPOWER_MODE_ENTER;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+
+ /* Wait for 1 SEC for LED to OFF */
+ iRetVal = wait_event_timeout(Adapter->LEDInfo.idleModeSyncEvent,\
+ Adapter->LEDInfo.bIdle_led_off, msecs_to_jiffies(1000));
+
+ /* If Timed Out to Sync IDLE MODE Enter, do IDLE mode Exit and Send NACK to device */
+ if(iRetVal <= 0)
+ {
+ stShutdownResponse.szData[1] = SHUTDOWN_NACK_FROM_DRIVER;//NACK- device access is going on.
+
+ Adapter->DriverState = NO_NETWORK_ENTRY;
+ wake_up(&Adapter->LEDInfo.notify_led_event);
+ }
+ }
+
+ if(stShutdownResponse.szData[2] == SHUTDOWN_ACK_FROM_DRIVER)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ACKING SHUTDOWN MODE !!!!!!!!!");
+ down(&Adapter->rdmwrmsync);
+ Adapter->bPreparingForLowPowerMode = TRUE;
+ up(&Adapter->rdmwrmsync);
+ //Killing all URBS.
+#ifndef BCM_SHM_INTERFACE
+ if(Adapter->bDoSuspend == TRUE)
+ Bcm_kill_all_URBs((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
+#endif
+ }
+ else
+ {
+ Adapter->bPreparingForLowPowerMode = FALSE;
+ }
+
+ if(!NVMAccess)
+ up(&Adapter->NVMRdmWrmLock);
+
+ if(!lowPwrAbortMsg)
+ up(&Adapter->LowPowerModeSync);
+ }
+ Status = CopyBufferToControlPacket(Adapter,&stShutdownResponse);
+ if((Status != STATUS_SUCCESS))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"fail to send the Idle mode Request \n");
+ Adapter->bPreparingForLowPowerMode = FALSE;
+
+#ifndef BCM_SHM_INTERFACE
+ StartInterruptUrb((PS_INTERFACE_ADAPTER)(Adapter->pvInterfaceAdapter));
+#endif
+ }
+}
+
+
+void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer)
+{
+ B_UINT32 uiResetValue = 0;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "====>\n");
+
+ if(*(pucBuffer+1) == COMPLETE_WAKE_UP_NOTIFICATION_FRM_FW)
+ {
+ HandleShutDownModeWakeup(Adapter);
+ }
+ else if(*(pucBuffer+1) == LINK_SHUTDOWN_REQ_FROM_FIRMWARE)
+ {
+ //Target wants to go to Shut Down Mode
+ //InterfacePrepareForShutdown(Adapter);
+ if(Adapter->chip_id == BCS220_2 ||
+ Adapter->chip_id == BCS220_2BC ||
+ Adapter->chip_id == BCS250_BC ||
+ Adapter->chip_id == BCS220_3)
+ {
+ rdmalt(Adapter,HPM_CONFIG_MSW, &uiResetValue, 4);
+ uiResetValue |= (1<<17);
+ wrmalt(Adapter, HPM_CONFIG_MSW, &uiResetValue, 4);
+ }
+
+ SendShutModeResponse(Adapter);
+ BCM_DEBUG_PRINT (Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL,"ShutDownModeResponse:Notification received: Sending the response(Ack/Nack)\n");
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, MP_SHUTDOWN, DBG_LVL_ALL, "<====\n");
+ return;
+
+}
+
+VOID ResetCounters(PMINI_ADAPTER Adapter)
+{
+
+ beceem_protocol_reset(Adapter);
+
+ Adapter->CurrNumRecvDescs = 0;
+ Adapter->PrevNumRecvDescs = 0;
+ Adapter->LinkUpStatus = 0;
+ Adapter->LinkStatus = 0;
+ atomic_set(&Adapter->cntrlpktCnt,0);
+ atomic_set (&Adapter->TotalPacketCount,0);
+ Adapter->fw_download_done=FALSE;
+ Adapter->LinkStatus = 0;
+ Adapter->AutoLinkUp = FALSE;
+ Adapter->IdleMode = FALSE;
+ Adapter->bShutStatus = FALSE;
+
+}
+S_CLASSIFIER_RULE *GetFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIP)
+{
+ UINT uiIndex=0;
+ for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++)
+ {
+ if((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)&&
+ (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&&
+ (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIP)&&
+ !Adapter->astFragmentedPktClassifierTable[uiIndex].bOutOfOrderFragment)
+ return Adapter->astFragmentedPktClassifierTable[uiIndex].pstMatchedClassifierEntry;
+ }
+ return NULL;
+}
+
+void AddFragIPClsEntry(PMINI_ADAPTER Adapter,PS_FRAGMENTED_PACKET_INFO psFragPktInfo)
+{
+ UINT uiIndex=0;
+ for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++)
+ {
+ if(!Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)
+ {
+ memcpy(&Adapter->astFragmentedPktClassifierTable[uiIndex],psFragPktInfo,sizeof(S_FRAGMENTED_PACKET_INFO));
+ break;
+ }
+ }
+
+}
+
+void DelFragIPClsEntry(PMINI_ADAPTER Adapter,USHORT usIpIdentification,ULONG SrcIp)
+{
+ UINT uiIndex=0;
+ for(uiIndex=0;uiIndex<MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES;uiIndex++)
+ {
+ if((Adapter->astFragmentedPktClassifierTable[uiIndex].bUsed)&&
+ (Adapter->astFragmentedPktClassifierTable[uiIndex].usIpIdentification == usIpIdentification)&&
+ (Adapter->astFragmentedPktClassifierTable[uiIndex].ulSrcIpAddress== SrcIp))
+ memset(&Adapter->astFragmentedPktClassifierTable[uiIndex],0,sizeof(S_FRAGMENTED_PACKET_INFO));
+ }
+}
+
+void update_per_cid_rx (PMINI_ADAPTER Adapter)
+{
+ UINT qindex = 0;
+
+ if((jiffies - Adapter->liDrainCalculated) < XSECONDS)
+ return;
+
+ for(qindex = 0; qindex < HiPriority; qindex++)
+ {
+ if(Adapter->PackInfo[qindex].ucDirection == 0)
+ {
+ Adapter->PackInfo[qindex].uiCurrentRxRate =
+ (Adapter->PackInfo[qindex].uiCurrentRxRate +
+ Adapter->PackInfo[qindex].uiThisPeriodRxBytes)/2;
+
+ Adapter->PackInfo[qindex].uiThisPeriodRxBytes = 0;
+ }
+ else
+ {
+ Adapter->PackInfo[qindex].uiCurrentDrainRate =
+ (Adapter->PackInfo[qindex].uiCurrentDrainRate +
+ Adapter->PackInfo[qindex].uiThisPeriodSentBytes)/2;
+
+ Adapter->PackInfo[qindex].uiThisPeriodSentBytes=0;
+ }
+ }
+ Adapter->liDrainCalculated=jiffies;
+}
+void update_per_sf_desc_cnts( PMINI_ADAPTER Adapter)
+{
+ INT iIndex = 0;
+ u32 uibuff[MAX_TARGET_DSX_BUFFERS];
+
+ if(!atomic_read (&Adapter->uiMBupdate))
+ return;
+
+#ifdef BCM_SHM_INTERFACE
+ if(rdmalt(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0)
+#else
+ if(rdmaltWithLock(Adapter, TARGET_SFID_TXDESC_MAP_LOC, (PUINT)uibuff, sizeof(UINT) * MAX_TARGET_DSX_BUFFERS)<0)
+#endif
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "rdm failed\n");
+ return;
+ }
+ for(iIndex = 0;iIndex < HiPriority; iIndex++)
+ {
+ if(Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].ucDirection)
+ {
+ if(Adapter->PackInfo[iIndex].usVCID_Value < MAX_TARGET_DSX_BUFFERS)
+ {
+ atomic_set(&Adapter->PackInfo[iIndex].uiPerSFTxResourceCount, uibuff[Adapter->PackInfo[iIndex].usVCID_Value]);
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Invalid VCID : %x \n",
+ Adapter->PackInfo[iIndex].usVCID_Value);
+ }
+ }
+ }
+ atomic_set (&Adapter->uiMBupdate, FALSE);
+}
+
+void flush_queue(PMINI_ADAPTER Adapter, UINT iQIndex)
+{
+ struct sk_buff* PacketToDrop=NULL;
+ struct net_device_stats* netstats=NULL;
+
+ netstats = &((PLINUX_DEP_DATA)Adapter->pvOsDepData)->netstats;
+
+ spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
+
+ while(Adapter->PackInfo[iQIndex].FirstTxQueue &&
+ atomic_read(&Adapter->TotalPacketCount))
+ {
+ PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue;
+ if(PacketToDrop && PacketToDrop->len)
+ {
+ netstats->tx_dropped++;
+ DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, \
+ Adapter->PackInfo[iQIndex].LastTxQueue);
+
+ Adapter->PackInfo[iQIndex].uiCurrentPacketsOnHost--;
+ Adapter->PackInfo[iQIndex].uiCurrentBytesOnHost -= PacketToDrop->len;
+
+ //Adding dropped statistics
+ Adapter->PackInfo[iQIndex].uiDroppedCountBytes += PacketToDrop->len;
+ Adapter->PackInfo[iQIndex].uiDroppedCountPackets++;
+
+ bcm_kfree_skb(PacketToDrop);
+ atomic_dec(&Adapter->TotalPacketCount);
+ atomic_inc(&Adapter->TxDroppedPacketCount);
+
+ }
+ }
+ spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock);
+
+}
+
+void beceem_protocol_reset (PMINI_ADAPTER Adapter)
+{
+ int i =0;
+
+ if(NULL != Adapter->dev)
+ {
+ netif_carrier_off(Adapter->dev);
+ netif_stop_queue(Adapter->dev);
+ }
+
+ Adapter->IdleMode = FALSE;
+ Adapter->LinkUpStatus = FALSE;
+ ClearTargetDSXBuffer(Adapter,0, TRUE);
+ //Delete All Classifier Rules
+
+ for(i = 0;i<HiPriority;i++)
+ {
+ DeleteAllClassifiersForSF(Adapter,i);
+ }
+
+ flush_all_queues(Adapter);
+
+ if(Adapter->TimerActive == TRUE)
+ Adapter->TimerActive = FALSE;
+
+ memset(Adapter->astFragmentedPktClassifierTable, 0,
+ sizeof(S_FRAGMENTED_PACKET_INFO) *
+ MAX_FRAGMENTEDIP_CLASSIFICATION_ENTRIES);
+
+ for(i = 0;i<HiPriority;i++)
+ {
+ //resetting only the first size (S_MIBS_SERVICEFLOW_TABLE) for the SF.
+ // It is same between MIBs and SF.
+ memset((PVOID)&Adapter->PackInfo[i],0,sizeof(S_MIBS_SERVICEFLOW_TABLE));
+ }
+}
+
+
+
+#ifdef BCM_SHM_INTERFACE
+
+
+#define GET_GTB_DIFF(start, end) \
+( (start) < (end) )? ( (end) - (start) ) : ( ~0x0 - ( (start) - (end)) +1 )
+
+void usdelay ( unsigned int a) {
+ unsigned int start= *(unsigned int *)0xaf8051b4;
+ unsigned int end = start+1;
+ unsigned int diff = 0;
+
+ while(1) {
+ end = *(unsigned int *)0xaf8051b4;
+ diff = (GET_GTB_DIFF(start,end))/80;
+ if (diff >= a)
+ break;
+ }
+}
+void read_cfg_file(PMINI_ADAPTER Adapter) {
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Config File Version = 0x%x \n",Adapter->pstargetparams->m_u32CfgVersion );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Center Frequency = 0x%x \n",Adapter->pstargetparams->m_u32CenterFrequency );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band A Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandAScan );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band B Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandBScan );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Band C Scan = 0x%x \n",Adapter->pstargetparams->m_u32BandCScan );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ERTPS Options = 0x%x \n",Adapter->pstargetparams->m_u32ErtpsOptions );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PHS Enable = 0x%x \n",Adapter->pstargetparams->m_u32PHSEnable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Handoff Enable = 0x%x \n",Adapter->pstargetparams->m_u32HoEnable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved1 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved1 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HO Reserved2 = 0x%x \n",Adapter->pstargetparams->m_u32HoReserved2 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MIMO Enable = 0x%x \n",Adapter->pstargetparams->m_u32MimoEnable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PKMv2 Enable = 0x%x \n",Adapter->pstargetparams->m_u32SecurityEnable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Powersaving Modes Enable = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModesEnable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Power Saving Mode Options = 0x%x \n",Adapter->pstargetparams->m_u32PowerSavingModeOptions );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ARQ Enable = 0x%x \n",Adapter->pstargetparams->m_u32ArqEnable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Harq Enable = 0x%x \n",Adapter->pstargetparams->m_u32HarqEnable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"EEPROM Flag = 0x%x \n",Adapter->pstargetparams->m_u32EEPROMFlag );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Customize = 0x%x \n",Adapter->pstargetparams->m_u32Customize );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Bandwidth = 0x%x \n",Adapter->pstargetparams->m_u32ConfigBW );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"ShutDown Timer Value = 0x%x \n",Adapter->pstargetparams->m_u32ShutDownInitThresholdTimer );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"RadioParameter = 0x%x \n",Adapter->pstargetparams->m_u32RadioParameter );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter1 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter1 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter2 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter2 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"PhyParameter3 = 0x%x \n",Adapter->pstargetparams->m_u32PhyParameter3 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"m_u32TestOptions = 0x%x \n",Adapter->pstargetparams->m_u32TestOptions );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperDLFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperDLFrame );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"MaxMACDataperULFrame = 0x%x \n",Adapter->pstargetparams->m_u32MaxMACDataperULFrame );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Corr2MacFlags = 0x%x \n",Adapter->pstargetparams->m_u32Corr2MacFlags );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig1 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig1 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig2 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig2 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig3 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig3 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig4 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig4 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig5 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig5 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"HostDrvrConfig6 = 0x%x \n",Adapter->pstargetparams->HostDrvrConfig6 );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Segmented PUSC Enable = 0x%x \n",Adapter->pstargetparams->m_u32SegmentedPUSCenable );
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"BamcEnable = 0x%x \n",Adapter->pstargetparams->m_u32BandAMCEnable );
+}
+
+#endif
+
+
diff --git a/drivers/staging/bcm/Osal_Misc.c b/drivers/staging/bcm/Osal_Misc.c
new file mode 100644
index 00000000000..feefd20a529
--- /dev/null
+++ b/drivers/staging/bcm/Osal_Misc.c
@@ -0,0 +1,27 @@
+ /*++
+
+ Copyright (c) Beceem Communications Inc.
+
+ Module Name:
+ WIN_Misc.c
+
+ Abstract:
+ Implements the Miscelanneous OS Construts
+ Linked Lists
+ Dispatcher Objects(Events,Semaphores,Spin Locks and the like)
+ Files
+
+ Revision History:
+ Who When What
+ -------- -------- ----------------------------------------------
+ Name Date Created/reviewed/modified
+ Rajeev 24/1/08 Created
+ Notes:
+
+ --*/
+#include "headers.h"
+
+bool OsalMemCompare(void *dest, void *src, UINT len)
+{
+ return (memcmp(src, dest, len));
+}
diff --git a/drivers/staging/bcm/PHSDefines.h b/drivers/staging/bcm/PHSDefines.h
new file mode 100644
index 00000000000..9889a993ad5
--- /dev/null
+++ b/drivers/staging/bcm/PHSDefines.h
@@ -0,0 +1,125 @@
+#ifndef BCM_PHS_DEFINES_H
+#define BCM_PHS_DEFINES_H
+
+#define PHS_INVALID_TABLE_INDEX 0xffffffff
+
+/************************* MACROS **********************************************/
+#define PHS_MEM_TAG '_SHP'
+
+
+
+//PHS Defines
+#define STATUS_PHS_COMPRESSED 0xa1
+#define STATUS_PHS_NOCOMPRESSION 0xa2
+#define APPLY_PHS 1
+#define MAX_NO_BIT 7
+#define ZERO_PHSI 0
+#define VERIFY 0
+#define SIZE_MULTIPLE_32 4
+#define UNCOMPRESSED_PACKET 0
+#define DYNAMIC 0
+#define SUPPRESS 0x80
+#define NO_CLASSIFIER_MATCH 0
+#define SEND_PACKET_UNCOMPRESSED 0
+#define PHSI_IS_ZERO 0
+#define PHSI_LEN 1
+#define ERROR_LEN 0
+#define PHS_BUFFER_SIZE 1532
+
+
+//#define MAX_PHS_LENGTHS 100
+#define MAX_PHSRULE_PER_SF 20
+#define MAX_SERVICEFLOWS 17
+
+//PHS Error Defines
+#define PHS_SUCCESS 0
+#define ERR_PHS_INVALID_DEVICE_EXETENSION 0x800
+#define ERR_PHS_INVALID_PHS_RULE 0x801
+#define ERR_PHS_RULE_ALREADY_EXISTS 0x802
+#define ERR_SF_MATCH_FAIL 0x803
+#define ERR_INVALID_CLASSIFIERTABLE_FOR_SF 0x804
+#define ERR_SFTABLE_FULL 0x805
+#define ERR_CLSASSIFIER_TABLE_FULL 0x806
+#define ERR_PHSRULE_MEMALLOC_FAIL 0x807
+#define ERR_CLSID_MATCH_FAIL 0x808
+#define ERR_PHSRULE_MATCH_FAIL 0x809
+
+typedef struct _S_PHS_RULE
+{
+ /// brief 8bit PHSI Of The Service Flow
+ B_UINT8 u8PHSI;
+ /// brief PHSF Of The Service Flow
+ B_UINT8 u8PHSFLength;
+ B_UINT8 u8PHSF[MAX_PHS_LENGTHS];
+ /// brief PHSM Of The Service Flow
+ B_UINT8 u8PHSMLength;
+ B_UINT8 u8PHSM[MAX_PHS_LENGTHS];
+ /// brief 8bit PHSS Of The Service Flow
+ B_UINT8 u8PHSS;
+ /// brief 8bit PHSV Of The Service Flow
+ B_UINT8 u8PHSV;
+ //Reference Count for this PHS Rule
+ B_UINT8 u8RefCnt;
+ //Flag to Store Unclassified PHS rules only in DL
+ B_UINT8 bUnclassifiedPHSRule;
+
+ B_UINT8 u8Reserved[3];
+
+ LONG PHSModifiedBytes;
+ ULONG PHSModifiedNumPackets;
+ ULONG PHSErrorNumPackets;
+}S_PHS_RULE;
+
+
+typedef enum _E_CLASSIFIER_ENTRY_CONTEXT
+{
+ eActiveClassifierRuleContext,
+ eOldClassifierRuleContext
+}E_CLASSIFIER_ENTRY_CONTEXT;
+
+typedef struct _S_CLASSIFIER_ENTRY
+{
+ B_UINT8 bUsed;
+ B_UINT16 uiClassifierRuleId;
+ B_UINT8 u8PHSI;
+ S_PHS_RULE *pstPhsRule;
+ B_UINT8 bUnclassifiedPHSRule;
+
+}S_CLASSIFIER_ENTRY;
+
+
+typedef struct _S_CLASSIFIER_TABLE
+{
+ B_UINT16 uiTotalClassifiers;
+ S_CLASSIFIER_ENTRY stActivePhsRulesList[MAX_PHSRULE_PER_SF];
+ S_CLASSIFIER_ENTRY stOldPhsRulesList[MAX_PHSRULE_PER_SF];
+ B_UINT16 uiOldestPhsRuleIndex;
+
+}S_CLASSIFIER_TABLE;
+
+
+typedef struct _S_SERVICEFLOW_ENTRY
+{
+ B_UINT8 bUsed;
+ B_UINT16 uiVcid;
+ S_CLASSIFIER_TABLE *pstClassifierTable;
+}S_SERVICEFLOW_ENTRY;
+
+typedef struct _S_SERVICEFLOW_TABLE
+{
+ B_UINT16 uiTotalServiceFlows;
+ S_SERVICEFLOW_ENTRY stSFList[MAX_SERVICEFLOWS];
+
+}S_SERVICEFLOW_TABLE;
+
+
+typedef struct _PHS_DEVICE_EXTENSION
+{
+ /* PHS Specific data*/
+ S_SERVICEFLOW_TABLE *pstServiceFlowPhsRulesTable;
+ void *CompressedTxBuffer;
+ void *UnCompressedRxBuffer;
+}PHS_DEVICE_EXTENSION,*PPHS_DEVICE_EXTENSION;
+
+
+#endif
diff --git a/drivers/staging/bcm/PHSModule.c b/drivers/staging/bcm/PHSModule.c
new file mode 100644
index 00000000000..8ba8489afc2
--- /dev/null
+++ b/drivers/staging/bcm/PHSModule.c
@@ -0,0 +1,1641 @@
+#include "headers.h"
+
+#define IN
+#define OUT
+
+void DumpDataPacketHeader(PUCHAR pPkt);
+
+/*
+Function: PHSTransmit
+
+Description: This routine handle PHS(Payload Header Suppression for Tx path.
+ It extracts a fragment of the NDIS_PACKET containing the header
+ to be suppressed.It then supresses the header by invoking PHS exported compress routine.
+ The header data after supression is copied back to the NDIS_PACKET.
+
+
+Input parameters: IN PMINI_ADAPTER Adapter - Miniport Adapter Context
+ IN Packet - NDIS packet containing data to be transmitted
+ IN USHORT Vcid - vcid pertaining to connection on which the packet is being sent.Used to
+ identify PHS rule to be applied.
+ B_UINT16 uiClassifierRuleID - Classifier Rule ID
+ BOOLEAN bHeaderSuppressionEnabled - indicates if header suprression is enabled for SF.
+
+Return: STATUS_SUCCESS - If the send was successful.
+ Other - If an error occured.
+*/
+
+int PHSTransmit(PMINI_ADAPTER Adapter,
+ struct sk_buff **pPacket,
+ USHORT Vcid,
+ B_UINT16 uiClassifierRuleID,
+ BOOLEAN bHeaderSuppressionEnabled,
+ UINT *PacketLen,
+ UCHAR bEthCSSupport)
+{
+
+ //PHS Sepcific
+ UINT unPHSPktHdrBytesCopied = 0;
+ UINT unPhsOldHdrSize = 0;
+ UINT unPHSNewPktHeaderLen = 0;
+ /* Pointer to PHS IN Hdr Buffer */
+ PUCHAR pucPHSPktHdrInBuf =
+ Adapter->stPhsTxContextInfo.ucaHdrSupressionInBuf;
+ /* Pointer to PHS OUT Hdr Buffer */
+ PUCHAR pucPHSPktHdrOutBuf =
+ Adapter->stPhsTxContextInfo.ucaHdrSupressionOutBuf;
+ UINT usPacketType;
+ UINT BytesToRemove=0;
+ BOOLEAN bPHSI = 0;
+ LONG ulPhsStatus = 0;
+ UINT numBytesCompressed = 0;
+ struct sk_buff *newPacket = NULL;
+ struct sk_buff *Packet = *pPacket;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL, "In PHSTransmit");
+
+ if(!bEthCSSupport)
+ BytesToRemove=ETH_HLEN;
+ /*
+ Accumulate the header upto the size we support supression
+ from NDIS packet
+ */
+
+ usPacketType=((struct ethhdr *)(Packet->data))->h_proto;
+
+
+ pucPHSPktHdrInBuf = Packet->data + BytesToRemove;
+ //considering data after ethernet header
+ if((*PacketLen - BytesToRemove) < MAX_PHS_LENGTHS)
+ {
+
+ unPHSPktHdrBytesCopied = (*PacketLen - BytesToRemove);
+ }
+ else
+ {
+ unPHSPktHdrBytesCopied = MAX_PHS_LENGTHS;
+ }
+
+ if( (unPHSPktHdrBytesCopied > 0 ) &&
+ (unPHSPktHdrBytesCopied <= MAX_PHS_LENGTHS))
+ {
+
+
+ //DumpDataPacketHeader(pucPHSPktHdrInBuf);
+
+ // Step 2 Supress Header using PHS and fill into intermediate ucaPHSPktHdrOutBuf.
+ // Suppress only if IP Header and PHS Enabled For the Service Flow
+ if(((usPacketType == ETHERNET_FRAMETYPE_IPV4) ||
+ (usPacketType == ETHERNET_FRAMETYPE_IPV6)) &&
+ (bHeaderSuppressionEnabled))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nTrying to PHS Compress Using Classifier rule 0x%X",uiClassifierRuleID);
+
+
+ unPHSNewPktHeaderLen = unPHSPktHdrBytesCopied;
+ ulPhsStatus = PhsCompress(&Adapter->stBCMPhsContext,
+ Vcid,
+ uiClassifierRuleID,
+ pucPHSPktHdrInBuf,
+ pucPHSPktHdrOutBuf,
+ &unPhsOldHdrSize,
+ &unPHSNewPktHeaderLen);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nPHS Old header Size : %d New Header Size %d\n",unPhsOldHdrSize,unPHSNewPktHeaderLen);
+
+ if(unPHSNewPktHeaderLen == unPhsOldHdrSize)
+ {
+ if( ulPhsStatus == STATUS_PHS_COMPRESSED)
+ bPHSI = *pucPHSPktHdrOutBuf;
+ ulPhsStatus = STATUS_PHS_NOCOMPRESSION;
+ }
+
+ if( ulPhsStatus == STATUS_PHS_COMPRESSED)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHS Sending packet Compressed");
+
+ if(skb_cloned(Packet))
+ {
+ newPacket = skb_copy(Packet, GFP_ATOMIC);
+
+ if(newPacket == NULL)
+ return STATUS_FAILURE;
+
+ bcm_kfree_skb(Packet);
+ *pPacket = Packet = newPacket;
+ pucPHSPktHdrInBuf = Packet->data + BytesToRemove;
+ }
+
+ numBytesCompressed = unPhsOldHdrSize - (unPHSNewPktHeaderLen+PHSI_LEN);
+
+ OsalMemMove(pucPHSPktHdrInBuf + numBytesCompressed, pucPHSPktHdrOutBuf, unPHSNewPktHeaderLen + PHSI_LEN);
+ OsalMemMove(Packet->data + numBytesCompressed, Packet->data, BytesToRemove);
+ skb_pull(Packet, numBytesCompressed);
+
+ return STATUS_SUCCESS;
+ }
+
+ else
+ {
+ //if one byte headroom is not available, increase it through skb_cow
+ if(!(skb_headroom(Packet) > 0))
+ {
+ if(skb_cow(Packet, 1))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "SKB Cow Failed\n");
+ return STATUS_FAILURE;
+ }
+ }
+ skb_push(Packet, 1);
+
+ // CAUTION: The MAC Header is getting corrupted here for IP CS - can be saved by copying 14 Bytes. not needed .... hence corrupting it.
+ *(Packet->data + BytesToRemove) = bPHSI;
+ return STATUS_SUCCESS;
+ }
+ }
+ else
+ {
+ if(!bHeaderSuppressionEnabled)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nHeader Suppression Disabled For SF: No PHS\n");
+ }
+
+ return STATUS_SUCCESS;
+ }
+ }
+
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"PHSTransmit : Dumping data packet After PHS");
+ return STATUS_SUCCESS;
+}
+
+int PHSRecieve(PMINI_ADAPTER Adapter,
+ USHORT usVcid,
+ struct sk_buff *packet,
+ UINT *punPacketLen,
+ UCHAR *pucEthernetHdr,
+ UINT bHeaderSuppressionEnabled)
+{
+ u32 nStandardPktHdrLen = 0;
+ u32 nTotalsupressedPktHdrBytes = 0;
+ int ulPhsStatus = 0;
+ PUCHAR pucInBuff = NULL ;
+ UINT TotalBytesAdded = 0;
+ if(!bHeaderSuppressionEnabled)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nPhs Disabled for incoming packet");
+ return ulPhsStatus;
+ }
+
+ pucInBuff = packet->data;
+
+ //Restore PHS suppressed header
+ nStandardPktHdrLen = packet->len;
+ ulPhsStatus = PhsDeCompress(&Adapter->stBCMPhsContext,
+ usVcid,
+ pucInBuff,
+ Adapter->ucaPHSPktRestoreBuf,
+ &nTotalsupressedPktHdrBytes,
+ &nStandardPktHdrLen);
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nSupressed PktHdrLen : 0x%x Restored PktHdrLen : 0x%x",
+ nTotalsupressedPktHdrBytes,nStandardPktHdrLen);
+
+ if(ulPhsStatus != STATUS_PHS_COMPRESSED)
+ {
+ skb_pull(packet, 1);
+ return STATUS_SUCCESS;
+ }
+ else
+ {
+ TotalBytesAdded = nStandardPktHdrLen - nTotalsupressedPktHdrBytes - PHSI_LEN;
+ if(TotalBytesAdded)
+ {
+ if(skb_headroom(packet) >= (SKB_RESERVE_ETHERNET_HEADER + TotalBytesAdded))
+ skb_push(packet, TotalBytesAdded);
+ else
+ {
+ if(skb_cow(packet, skb_headroom(packet) + TotalBytesAdded))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "cow failed in receive\n");
+ return STATUS_FAILURE;
+ }
+
+ skb_push(packet, TotalBytesAdded);
+ }
+ }
+
+ OsalMemMove(packet->data, Adapter->ucaPHSPktRestoreBuf, nStandardPktHdrLen);
+ }
+
+ return STATUS_SUCCESS;
+}
+
+void DumpDataPacketHeader(PUCHAR pPkt)
+{
+ struct iphdr *iphd = (struct iphdr*)pPkt;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Phs Send/Recieve : IP Packet Hdr \n");
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"TOS : %x \n",iphd->tos);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Src IP : %x \n",iphd->saddr);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Dest IP : %x \n \n",iphd->daddr);
+
+}
+
+void DumpFullPacket(UCHAR *pBuf,UINT nPktLen)
+{
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"Dumping Data Packet");
+ BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,pBuf,nPktLen);
+}
+
+//-----------------------------------------------------------------------------
+// Procedure: phs_init
+//
+// Description: This routine is responsible for allocating memory for classifier and
+// PHS rules.
+//
+// Arguments:
+// pPhsdeviceExtension - ptr to Device extension containing PHS Classifier rules and PHS Rules , RX, TX buffer etc
+//
+// Returns:
+// TRUE(1) -If allocation of memory was success full.
+// FALSE -If allocation of memory fails.
+//-----------------------------------------------------------------------------
+int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter)
+{
+ int i;
+ S_SERVICEFLOW_TABLE *pstServiceFlowTable;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nPHS:phs_init function ");
+
+ if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
+ return -EINVAL;
+
+ pPhsdeviceExtension->pstServiceFlowPhsRulesTable =
+ (S_SERVICEFLOW_TABLE*)OsalMemAlloc(sizeof(S_SERVICEFLOW_TABLE),
+ PHS_MEM_TAG);
+
+ if(pPhsdeviceExtension->pstServiceFlowPhsRulesTable)
+ {
+ OsalZeroMemory(pPhsdeviceExtension->pstServiceFlowPhsRulesTable,
+ sizeof(S_SERVICEFLOW_TABLE));
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation ServiceFlowPhsRulesTable failed");
+ return -ENOMEM;
+ }
+
+ pstServiceFlowTable = pPhsdeviceExtension->pstServiceFlowPhsRulesTable;
+ for(i=0;i<MAX_SERVICEFLOWS;i++)
+ {
+ S_SERVICEFLOW_ENTRY sServiceFlow = pstServiceFlowTable->stSFList[i];
+ sServiceFlow.pstClassifierTable = (S_CLASSIFIER_TABLE*)OsalMemAlloc(
+ sizeof(S_CLASSIFIER_TABLE), PHS_MEM_TAG);
+ if(sServiceFlow.pstClassifierTable)
+ {
+ OsalZeroMemory(sServiceFlow.pstClassifierTable,sizeof(S_CLASSIFIER_TABLE));
+ pstServiceFlowTable->stSFList[i].pstClassifierTable = sServiceFlow.pstClassifierTable;
+ }
+ else
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
+ free_phs_serviceflow_rules(pPhsdeviceExtension->
+ pstServiceFlowPhsRulesTable);
+ pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
+ return -ENOMEM;
+ }
+ }
+
+
+ pPhsdeviceExtension->CompressedTxBuffer =
+ OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG);
+
+ if(pPhsdeviceExtension->CompressedTxBuffer == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
+ free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
+ pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
+ return -ENOMEM;
+ }
+
+ pPhsdeviceExtension->UnCompressedRxBuffer =
+ OsalMemAlloc(PHS_BUFFER_SIZE,PHS_MEM_TAG);
+ if(pPhsdeviceExtension->UnCompressedRxBuffer == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAllocation failed");
+ OsalMemFree(pPhsdeviceExtension->CompressedTxBuffer,PHS_BUFFER_SIZE);
+ free_phs_serviceflow_rules(pPhsdeviceExtension->pstServiceFlowPhsRulesTable);
+ pPhsdeviceExtension->pstServiceFlowPhsRulesTable = NULL;
+ return -ENOMEM;
+ }
+
+
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n phs_init Successfull");
+ return STATUS_SUCCESS;
+}
+
+
+int PhsCleanup(IN PPHS_DEVICE_EXTENSION pPHSDeviceExt)
+{
+ if(pPHSDeviceExt->pstServiceFlowPhsRulesTable)
+ {
+ free_phs_serviceflow_rules(pPHSDeviceExt->pstServiceFlowPhsRulesTable);
+ pPHSDeviceExt->pstServiceFlowPhsRulesTable = NULL;
+ }
+
+ if(pPHSDeviceExt->CompressedTxBuffer)
+ {
+ OsalMemFree(pPHSDeviceExt->CompressedTxBuffer,PHS_BUFFER_SIZE);
+ pPHSDeviceExt->CompressedTxBuffer = NULL;
+ }
+ if(pPHSDeviceExt->UnCompressedRxBuffer)
+ {
+ OsalMemFree(pPHSDeviceExt->UnCompressedRxBuffer,PHS_BUFFER_SIZE);
+ pPHSDeviceExt->UnCompressedRxBuffer = NULL;
+ }
+
+ return 0;
+}
+
+
+
+//PHS functions
+/*++
+PhsUpdateClassifierRule
+
+Routine Description:
+ Exported function to add or modify a PHS Rule.
+
+Arguments:
+ IN void* pvContext - PHS Driver Specific Context
+ IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies
+ IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies.
+ IN S_PHS_RULE *psPhsRule - The PHS Rule strcuture to be added to the PHS Rule table.
+
+Return Value:
+
+ 0 if successful,
+ >0 Error.
+
+--*/
+ULONG PhsUpdateClassifierRule(IN void* pvContext,
+ IN B_UINT16 uiVcid ,
+ IN B_UINT16 uiClsId ,
+ IN S_PHS_RULE *psPhsRule,
+ IN B_UINT8 u8AssociatedPHSI)
+{
+ ULONG lStatus =0;
+ UINT nSFIndex =0 ;
+ S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+
+
+ PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS With Corr2 Changes \n");
+
+ if(pDeviceExtension == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Invalid Device Extension\n");
+ return ERR_PHS_INVALID_DEVICE_EXETENSION;
+ }
+
+
+ if(u8AssociatedPHSI == 0)
+ {
+ return ERR_PHS_INVALID_PHS_RULE;
+ }
+
+ /* Retrieve the SFID Entry Index for requested Service Flow */
+
+ nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
+ uiVcid,&pstServiceFlowEntry);
+
+ if(nSFIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ /* This is a new SF. Create a mapping entry for this */
+ lStatus = CreateSFToClassifierRuleMapping(uiVcid, uiClsId,
+ pDeviceExtension->pstServiceFlowPhsRulesTable, psPhsRule, u8AssociatedPHSI);
+ return lStatus;
+ }
+
+ /* SF already Exists Add PHS Rule to existing SF */
+ lStatus = CreateClassiferToPHSRuleMapping(uiVcid, uiClsId,
+ pstServiceFlowEntry, psPhsRule, u8AssociatedPHSI);
+
+ return lStatus;
+}
+
+/*++
+PhsDeletePHSRule
+
+Routine Description:
+ Deletes the specified phs Rule within Vcid
+
+Arguments:
+ IN void* pvContext - PHS Driver Specific Context
+ IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies
+ IN B_UINT8 u8PHSI - the PHS Index identifying PHS rule to be deleted.
+
+Return Value:
+
+ 0 if successful,
+ >0 Error.
+
+--*/
+
+ULONG PhsDeletePHSRule(IN void* pvContext,IN B_UINT16 uiVcid,IN B_UINT8 u8PHSI)
+{
+ ULONG lStatus =0;
+ UINT nSFIndex =0, nClsidIndex =0 ;
+ S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
+ S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+
+ PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "======>\n");
+
+ if(pDeviceExtension)
+ {
+
+ //Retrieve the SFID Entry Index for requested Service Flow
+ nSFIndex = GetServiceFlowEntry(pDeviceExtension
+ ->pstServiceFlowPhsRulesTable,uiVcid,&pstServiceFlowEntry);
+
+ if(nSFIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n");
+ return ERR_SF_MATCH_FAIL;
+ }
+
+ pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable;
+ if(pstClassifierRulesTable)
+ {
+ for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++)
+ {
+ if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].bUsed && pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule)
+ {
+ if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
+ .pstPhsRule->u8PHSI == u8PHSI)
+ {
+ if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule
+ ->u8RefCnt)
+ pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule
+ ->u8RefCnt--;
+ if(0 == pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
+ .pstPhsRule->u8RefCnt)
+ OsalMemFree(pstClassifierRulesTable
+ ->stActivePhsRulesList[nClsidIndex].pstPhsRule,
+ sizeof(S_PHS_RULE));
+ OsalZeroMemory(&pstClassifierRulesTable
+ ->stActivePhsRulesList[nClsidIndex],
+ sizeof(S_CLASSIFIER_ENTRY));
+ }
+ }
+ }
+ }
+
+ }
+ return lStatus;
+}
+
+/*++
+PhsDeleteClassifierRule
+
+Routine Description:
+ Exported function to Delete a PHS Rule for the SFID,CLSID Pair.
+
+Arguments:
+ IN void* pvContext - PHS Driver Specific Context
+ IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rule applies
+ IN B_UINT16 uiClsId - The Classifier ID within the Service Flow for which the PHS rule applies.
+
+Return Value:
+
+ 0 if successful,
+ >0 Error.
+
+--*/
+ULONG PhsDeleteClassifierRule(IN void* pvContext,IN B_UINT16 uiVcid ,IN B_UINT16 uiClsId)
+{
+ ULONG lStatus =0;
+ UINT nSFIndex =0, nClsidIndex =0 ;
+ S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
+ S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+
+ if(pDeviceExtension)
+ {
+ //Retrieve the SFID Entry Index for requested Service Flow
+ nSFIndex = GetServiceFlowEntry(pDeviceExtension
+ ->pstServiceFlowPhsRulesTable, uiVcid, &pstServiceFlowEntry);
+ if(nSFIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"SFID Match Failed\n");
+ return ERR_SF_MATCH_FAIL;
+ }
+
+ nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
+ uiClsId, eActiveClassifierRuleContext, &pstClassifierEntry);
+ if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule))
+ {
+ if(pstClassifierEntry->pstPhsRule)
+ {
+ if(pstClassifierEntry->pstPhsRule->u8RefCnt)
+ pstClassifierEntry->pstPhsRule->u8RefCnt--;
+ if(0==pstClassifierEntry->pstPhsRule->u8RefCnt)
+ OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE));
+
+ }
+ OsalZeroMemory(pstClassifierEntry,sizeof(S_CLASSIFIER_ENTRY));
+ }
+
+ nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
+ uiClsId,eOldClassifierRuleContext,&pstClassifierEntry);
+
+ if((nClsidIndex != PHS_INVALID_TABLE_INDEX) && (!pstClassifierEntry->bUnclassifiedPHSRule))
+ {
+ if(pstClassifierEntry->pstPhsRule)
+ //Delete the classifier entry
+ OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE));
+ OsalZeroMemory(pstClassifierEntry,sizeof(S_CLASSIFIER_ENTRY));
+ }
+ }
+ return lStatus;
+}
+
+/*++
+PhsDeleteSFRules
+
+Routine Description:
+ Exported function to Delete a all PHS Rules for the SFID.
+
+Arguments:
+ IN void* pvContext - PHS Driver Specific Context
+ IN B_UINT16 uiVcid - The Service Flow ID for which the PHS rules need to be deleted
+
+Return Value:
+
+ 0 if successful,
+ >0 Error.
+
+--*/
+ULONG PhsDeleteSFRules(IN void* pvContext,IN B_UINT16 uiVcid)
+{
+
+ ULONG lStatus =0;
+ UINT nSFIndex =0, nClsidIndex =0 ;
+ S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
+ S_CLASSIFIER_TABLE *pstClassifierRulesTable = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"====> \n");
+
+ if(pDeviceExtension)
+ {
+ //Retrieve the SFID Entry Index for requested Service Flow
+ nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
+ uiVcid,&pstServiceFlowEntry);
+ if(nSFIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "SFID Match Failed\n");
+ return ERR_SF_MATCH_FAIL;
+ }
+
+ pstClassifierRulesTable=pstServiceFlowEntry->pstClassifierTable;
+ if(pstClassifierRulesTable)
+ {
+ for(nClsidIndex=0;nClsidIndex<MAX_PHSRULE_PER_SF;nClsidIndex++)
+ {
+ if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex].pstPhsRule)
+ {
+ if(pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
+ .pstPhsRule->u8RefCnt)
+ pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
+ .pstPhsRule->u8RefCnt--;
+ if(0==pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
+ .pstPhsRule->u8RefCnt)
+ OsalMemFree(pstClassifierRulesTable
+ ->stActivePhsRulesList[nClsidIndex].pstPhsRule,
+ sizeof(S_PHS_RULE));
+ pstClassifierRulesTable->stActivePhsRulesList[nClsidIndex]
+ .pstPhsRule = NULL;
+ }
+ OsalZeroMemory(&pstClassifierRulesTable
+ ->stActivePhsRulesList[nClsidIndex],sizeof(S_CLASSIFIER_ENTRY));
+ if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex].pstPhsRule)
+ {
+ if(pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
+ .pstPhsRule->u8RefCnt)
+ pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
+ .pstPhsRule->u8RefCnt--;
+ if(0 == pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
+ .pstPhsRule->u8RefCnt)
+ OsalMemFree(pstClassifierRulesTable
+ ->stOldPhsRulesList[nClsidIndex].pstPhsRule,
+ sizeof(S_PHS_RULE));
+ pstClassifierRulesTable->stOldPhsRulesList[nClsidIndex]
+ .pstPhsRule = NULL;
+ }
+ OsalZeroMemory(&pstClassifierRulesTable
+ ->stOldPhsRulesList[nClsidIndex],
+ sizeof(S_CLASSIFIER_ENTRY));
+ }
+ }
+ pstServiceFlowEntry->bUsed = FALSE;
+ pstServiceFlowEntry->uiVcid = 0;
+
+ }
+
+ return lStatus;
+}
+
+
+/*++
+PhsCompress
+
+Routine Description:
+ Exported function to compress the data using PHS.
+
+Arguments:
+ IN void* pvContext - PHS Driver Specific Context.
+ IN B_UINT16 uiVcid - The Service Flow ID to which current packet header compression applies.
+ IN UINT uiClsId - The Classifier ID to which current packet header compression applies.
+ IN void *pvInputBuffer - The Input buffer containg packet header data
+ IN void *pvOutputBuffer - The output buffer returned by this function after PHS
+ IN UINT *pOldHeaderSize - The actual size of the header before PHS
+ IN UINT *pNewHeaderSize - The new size of the header after applying PHS
+
+Return Value:
+
+ 0 if successful,
+ >0 Error.
+
+--*/
+ULONG PhsCompress(IN void* pvContext,
+ IN B_UINT16 uiVcid,
+ IN B_UINT16 uiClsId,
+ IN void *pvInputBuffer,
+ OUT void *pvOutputBuffer,
+ OUT UINT *pOldHeaderSize,
+ OUT UINT *pNewHeaderSize )
+{
+ UINT nSFIndex =0, nClsidIndex =0 ;
+ S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
+ S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
+ S_PHS_RULE *pstPhsRule = NULL;
+ ULONG lStatus =0;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+
+
+ PPHS_DEVICE_EXTENSION pDeviceExtension= (PPHS_DEVICE_EXTENSION)pvContext;
+
+
+ if(pDeviceExtension == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Invalid Device Extension\n");
+ lStatus = STATUS_PHS_NOCOMPRESSION ;
+ return lStatus;
+
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"Suppressing header \n");
+
+
+ //Retrieve the SFID Entry Index for requested Service Flow
+ nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
+ uiVcid,&pstServiceFlowEntry);
+ if(nSFIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"SFID Match Failed\n");
+ lStatus = STATUS_PHS_NOCOMPRESSION ;
+ return lStatus;
+ }
+
+ nClsidIndex = GetClassifierEntry(pstServiceFlowEntry->pstClassifierTable,
+ uiClsId,eActiveClassifierRuleContext,&pstClassifierEntry);
+
+ if(nClsidIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"No PHS Rule Defined For Classifier\n");
+ lStatus = STATUS_PHS_NOCOMPRESSION ;
+ return lStatus;
+ }
+
+
+ //get rule from SF id,Cls ID pair and proceed
+ pstPhsRule = pstClassifierEntry->pstPhsRule;
+
+ if(!ValidatePHSRuleComplete(pstPhsRule))
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"PHS Rule Defined For Classifier But Not Complete\n");
+ lStatus = STATUS_PHS_NOCOMPRESSION ;
+ return lStatus;
+ }
+
+ //Compress Packet
+ lStatus = phs_compress(pstPhsRule,(PUCHAR)pvInputBuffer,
+ (PUCHAR)pvOutputBuffer, pOldHeaderSize,pNewHeaderSize);
+
+ if(lStatus == STATUS_PHS_COMPRESSED)
+ {
+ pstPhsRule->PHSModifiedBytes += *pOldHeaderSize - *pNewHeaderSize - 1;
+ pstPhsRule->PHSModifiedNumPackets++;
+ }
+ else
+ pstPhsRule->PHSErrorNumPackets++;
+
+ return lStatus;
+}
+
+/*++
+PhsDeCompress
+
+Routine Description:
+ Exported function to restore the packet header in Rx path.
+
+Arguments:
+ IN void* pvContext - PHS Driver Specific Context.
+ IN B_UINT16 uiVcid - The Service Flow ID to which current packet header restoration applies.
+ IN void *pvInputBuffer - The Input buffer containg suppressed packet header data
+ OUT void *pvOutputBuffer - The output buffer returned by this function after restoration
+ OUT UINT *pHeaderSize - The packet header size after restoration is returned in this parameter.
+
+Return Value:
+
+ 0 if successful,
+ >0 Error.
+
+--*/
+ULONG PhsDeCompress(IN void* pvContext,
+ IN B_UINT16 uiVcid,
+ IN void *pvInputBuffer,
+ OUT void *pvOutputBuffer,
+ OUT UINT *pInHeaderSize,
+ OUT UINT *pOutHeaderSize )
+{
+ UINT nSFIndex =0, nPhsRuleIndex =0 ;
+ S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
+ S_PHS_RULE *pstPhsRule = NULL;
+ UINT phsi;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ PPHS_DEVICE_EXTENSION pDeviceExtension=
+ (PPHS_DEVICE_EXTENSION)pvContext;
+
+ *pInHeaderSize = 0;
+
+ if(pDeviceExtension == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"Invalid Device Extension\n");
+ return ERR_PHS_INVALID_DEVICE_EXETENSION;
+ }
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"Restoring header \n");
+
+ phsi = *((unsigned char *)(pvInputBuffer));
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"PHSI To Be Used For restore : %x \n",phsi);
+ if(phsi == UNCOMPRESSED_PACKET )
+ {
+ return STATUS_PHS_NOCOMPRESSION;
+ }
+
+ //Retrieve the SFID Entry Index for requested Service Flow
+ nSFIndex = GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
+ uiVcid,&pstServiceFlowEntry);
+ if(nSFIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"SFID Match Failed During Lookup\n");
+ return ERR_SF_MATCH_FAIL;
+ }
+
+ nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,phsi,
+ eActiveClassifierRuleContext,&pstPhsRule);
+ if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ //Phs Rule does not exist in active rules table. Lets try in the old rules table.
+ nPhsRuleIndex = GetPhsRuleEntry(pstServiceFlowEntry->pstClassifierTable,
+ phsi,eOldClassifierRuleContext,&pstPhsRule);
+ if(nPhsRuleIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ return ERR_PHSRULE_MATCH_FAIL;
+ }
+
+ }
+
+ *pInHeaderSize = phs_decompress((PUCHAR)pvInputBuffer,
+ (PUCHAR)pvOutputBuffer,pstPhsRule,pOutHeaderSize);
+
+ pstPhsRule->PHSModifiedBytes += *pOutHeaderSize - *pInHeaderSize - 1;
+
+ pstPhsRule->PHSModifiedNumPackets++;
+ return STATUS_PHS_COMPRESSED;
+}
+
+
+//-----------------------------------------------------------------------------
+// Procedure: free_phs_serviceflow_rules
+//
+// Description: This routine is responsible for freeing memory allocated for PHS rules.
+//
+// Arguments:
+// rules - ptr to S_SERVICEFLOW_TABLE structure.
+//
+// Returns:
+// Does not return any value.
+//-----------------------------------------------------------------------------
+
+void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable)
+{
+ int i,j;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "=======>\n");
+ if(psServiceFlowRulesTable)
+ {
+ for(i=0;i<MAX_SERVICEFLOWS;i++)
+ {
+ S_SERVICEFLOW_ENTRY stServiceFlowEntry =
+ psServiceFlowRulesTable->stSFList[i];
+ S_CLASSIFIER_TABLE *pstClassifierRulesTable =
+ stServiceFlowEntry.pstClassifierTable;
+
+ if(pstClassifierRulesTable)
+ {
+ for(j=0;j<MAX_PHSRULE_PER_SF;j++)
+ {
+ if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule)
+ {
+ if(pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule
+ ->u8RefCnt)
+ pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule
+ ->u8RefCnt--;
+ if(0==pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule
+ ->u8RefCnt)
+ OsalMemFree(pstClassifierRulesTable->stActivePhsRulesList[j].
+ pstPhsRule, sizeof(S_PHS_RULE));
+ pstClassifierRulesTable->stActivePhsRulesList[j].pstPhsRule = NULL;
+ }
+ if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule)
+ {
+ if(pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule
+ ->u8RefCnt)
+ pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule
+ ->u8RefCnt--;
+ if(0==pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule
+ ->u8RefCnt)
+ OsalMemFree(pstClassifierRulesTable->stOldPhsRulesList[j]
+ .pstPhsRule,sizeof(S_PHS_RULE));
+ pstClassifierRulesTable->stOldPhsRulesList[j].pstPhsRule = NULL;
+ }
+ }
+ OsalMemFree(pstClassifierRulesTable,sizeof(S_CLASSIFIER_TABLE));
+ stServiceFlowEntry.pstClassifierTable = pstClassifierRulesTable = NULL;
+ }
+ }
+ }
+
+ OsalMemFree(psServiceFlowRulesTable,sizeof(S_SERVICEFLOW_TABLE));
+ psServiceFlowRulesTable = NULL;
+}
+
+
+
+BOOLEAN ValidatePHSRuleComplete(IN S_PHS_RULE *psPhsRule)
+{
+ if(psPhsRule)
+ {
+ if(!psPhsRule->u8PHSI)
+ {
+ // PHSI is not valid
+ return FALSE;
+ }
+
+ if(!psPhsRule->u8PHSS)
+ {
+ //PHSS Is Undefined
+ return FALSE;
+ }
+
+ //Check if PHSF is defines for the PHS Rule
+ if(!psPhsRule->u8PHSFLength) // If any part of PHSF is valid then Rule contains valid PHSF
+ {
+ return FALSE;
+ }
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+UINT GetServiceFlowEntry(IN S_SERVICEFLOW_TABLE *psServiceFlowTable,
+ IN B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry)
+{
+ int i;
+ for(i=0;i<MAX_SERVICEFLOWS;i++)
+ {
+ if(psServiceFlowTable->stSFList[i].bUsed)
+ {
+ if(psServiceFlowTable->stSFList[i].uiVcid == uiVcid)
+ {
+ *ppstServiceFlowEntry = &psServiceFlowTable->stSFList[i];
+ return i;
+ }
+ }
+ }
+
+ *ppstServiceFlowEntry = NULL;
+ return PHS_INVALID_TABLE_INDEX;
+}
+
+
+UINT GetClassifierEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
+ IN B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,
+ OUT S_CLASSIFIER_ENTRY **ppstClassifierEntry)
+{
+ int i;
+ S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
+ for(i=0;i<MAX_PHSRULE_PER_SF;i++)
+ {
+
+ if(eClsContext == eActiveClassifierRuleContext)
+ {
+ psClassifierRules = &pstClassifierTable->stActivePhsRulesList[i];
+ }
+ else
+ {
+ psClassifierRules = &pstClassifierTable->stOldPhsRulesList[i];
+ }
+
+ if(psClassifierRules->bUsed)
+ {
+ if(psClassifierRules->uiClassifierRuleId == uiClsid)
+ {
+ *ppstClassifierEntry = psClassifierRules;
+ return i;
+ }
+ }
+
+ }
+
+ *ppstClassifierEntry = NULL;
+ return PHS_INVALID_TABLE_INDEX;
+}
+
+UINT GetPhsRuleEntry(IN S_CLASSIFIER_TABLE *pstClassifierTable,
+ IN B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,
+ OUT S_PHS_RULE **ppstPhsRule)
+{
+ int i;
+ S_CLASSIFIER_ENTRY *pstClassifierRule = NULL;
+ for(i=0;i<MAX_PHSRULE_PER_SF;i++)
+ {
+ if(eClsContext == eActiveClassifierRuleContext)
+ {
+ pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[i];
+ }
+ else
+ {
+ pstClassifierRule = &pstClassifierTable->stOldPhsRulesList[i];
+ }
+ if(pstClassifierRule->bUsed)
+ {
+ if(pstClassifierRule->u8PHSI == uiPHSI)
+ {
+ *ppstPhsRule = pstClassifierRule->pstPhsRule;
+ return i;
+ }
+ }
+
+ }
+
+ *ppstPhsRule = NULL;
+ return PHS_INVALID_TABLE_INDEX;
+}
+
+UINT CreateSFToClassifierRuleMapping(IN B_UINT16 uiVcid,IN B_UINT16 uiClsId,
+ IN S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,
+ B_UINT8 u8AssociatedPHSI)
+{
+
+ S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
+ UINT uiStatus = 0;
+ int iSfIndex;
+ BOOLEAN bFreeEntryFound =FALSE;
+ //Check for a free entry in SFID table
+ for(iSfIndex=0;iSfIndex < MAX_SERVICEFLOWS;iSfIndex++)
+ {
+ if(!psServiceFlowTable->stSFList[iSfIndex].bUsed)
+ {
+ bFreeEntryFound = TRUE;
+ break;
+ }
+ }
+
+ if(!bFreeEntryFound)
+ return ERR_SFTABLE_FULL;
+
+
+ psaClassifiertable = psServiceFlowTable->stSFList[iSfIndex].pstClassifierTable;
+ uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,psPhsRule,
+ eActiveClassifierRuleContext,u8AssociatedPHSI);
+ if(uiStatus == PHS_SUCCESS)
+ {
+ //Add entry at free index to the SF
+ psServiceFlowTable->stSFList[iSfIndex].bUsed = TRUE;
+ psServiceFlowTable->stSFList[iSfIndex].uiVcid = uiVcid;
+ }
+
+ return uiStatus;
+
+}
+
+UINT CreateClassiferToPHSRuleMapping(IN B_UINT16 uiVcid,
+ IN B_UINT16 uiClsId,IN S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,
+ S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI)
+{
+ S_CLASSIFIER_ENTRY *pstClassifierEntry = NULL;
+ UINT uiStatus =PHS_SUCCESS;
+ UINT nClassifierIndex = 0;
+ S_CLASSIFIER_TABLE *psaClassifiertable = NULL;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ psaClassifiertable = pstServiceFlowEntry->pstClassifierTable;
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "==>");
+
+ /* Check if the supplied Classifier already exists */
+ nClassifierIndex =GetClassifierEntry(
+ pstServiceFlowEntry->pstClassifierTable,uiClsId,
+ eActiveClassifierRuleContext,&pstClassifierEntry);
+ if(nClassifierIndex == PHS_INVALID_TABLE_INDEX)
+ {
+ /*
+ The Classifier doesn't exist. So its a new classifier being added.
+ Add new entry to associate PHS Rule to the Classifier
+ */
+
+ uiStatus = CreateClassifierPHSRule(uiClsId,psaClassifiertable,
+ psPhsRule,eActiveClassifierRuleContext,u8AssociatedPHSI);
+ return uiStatus;
+ }
+
+ /*
+ The Classifier exists.The PHS Rule for this classifier
+ is being modified
+ */
+ if(pstClassifierEntry->u8PHSI == psPhsRule->u8PHSI)
+ {
+ if(pstClassifierEntry->pstPhsRule == NULL)
+ return ERR_PHS_INVALID_PHS_RULE;
+
+ /*
+ This rule already exists if any fields are changed for this PHS
+ rule update them.
+ */
+ /* If any part of PHSF is valid then we update PHSF */
+ if(psPhsRule->u8PHSFLength)
+ {
+ //update PHSF
+ OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSF,
+ psPhsRule->u8PHSF , MAX_PHS_LENGTHS);
+ }
+ if(psPhsRule->u8PHSFLength)
+ {
+ //update PHSFLen
+ pstClassifierEntry->pstPhsRule->u8PHSFLength =
+ psPhsRule->u8PHSFLength;
+ }
+ if(psPhsRule->u8PHSMLength)
+ {
+ //update PHSM
+ OsalMemMove(pstClassifierEntry->pstPhsRule->u8PHSM,
+ psPhsRule->u8PHSM, MAX_PHS_LENGTHS);
+ }
+ if(psPhsRule->u8PHSMLength)
+ {
+ //update PHSM Len
+ pstClassifierEntry->pstPhsRule->u8PHSMLength =
+ psPhsRule->u8PHSMLength;
+ }
+ if(psPhsRule->u8PHSS)
+ {
+ //update PHSS
+ pstClassifierEntry->pstPhsRule->u8PHSS = psPhsRule->u8PHSS;
+ }
+
+ //update PHSV
+ pstClassifierEntry->pstPhsRule->u8PHSV = psPhsRule->u8PHSV;
+
+ }
+ else
+ {
+ /*
+ A new rule is being set for this classifier.
+ */
+ uiStatus=UpdateClassifierPHSRule( uiClsId, pstClassifierEntry,
+ psaClassifiertable, psPhsRule, u8AssociatedPHSI);
+ }
+
+
+
+ return uiStatus;
+}
+
+UINT CreateClassifierPHSRule(IN B_UINT16 uiClsId,
+ S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
+ E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI)
+{
+ UINT iClassifierIndex = 0;
+ BOOLEAN bFreeEntryFound = FALSE;
+ S_CLASSIFIER_ENTRY *psClassifierRules = NULL;
+ UINT nStatus = PHS_SUCCESS;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL,"Inside CreateClassifierPHSRule");
+ if(psaClassifiertable == NULL)
+ {
+ return ERR_INVALID_CLASSIFIERTABLE_FOR_SF;
+ }
+
+ if(eClsContext == eOldClassifierRuleContext)
+ {
+ /* If An Old Entry for this classifier ID already exists in the
+ old rules table replace it. */
+
+ iClassifierIndex =
+ GetClassifierEntry(psaClassifiertable, uiClsId,
+ eClsContext,&psClassifierRules);
+ if(iClassifierIndex != PHS_INVALID_TABLE_INDEX)
+ {
+ /*
+ The Classifier already exists in the old rules table
+ Lets replace the old classifier with the new one.
+ */
+ bFreeEntryFound = TRUE;
+ }
+ }
+
+ if(!bFreeEntryFound)
+ {
+ /*
+ Continue to search for a free location to add the rule
+ */
+ for(iClassifierIndex = 0; iClassifierIndex <
+ MAX_PHSRULE_PER_SF; iClassifierIndex++)
+ {
+ if(eClsContext == eActiveClassifierRuleContext)
+ {
+ psClassifierRules =
+ &psaClassifiertable->stActivePhsRulesList[iClassifierIndex];
+ }
+ else
+ {
+ psClassifierRules =
+ &psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
+ }
+
+ if(!psClassifierRules->bUsed)
+ {
+ bFreeEntryFound = TRUE;
+ break;
+ }
+ }
+ }
+
+ if(!bFreeEntryFound)
+ {
+ if(eClsContext == eActiveClassifierRuleContext)
+ {
+ return ERR_CLSASSIFIER_TABLE_FULL;
+ }
+ else
+ {
+ //Lets replace the oldest rule if we are looking in old Rule table
+ if(psaClassifiertable->uiOldestPhsRuleIndex >=
+ MAX_PHSRULE_PER_SF)
+ {
+ psaClassifiertable->uiOldestPhsRuleIndex =0;
+ }
+
+ iClassifierIndex = psaClassifiertable->uiOldestPhsRuleIndex;
+ psClassifierRules =
+ &psaClassifiertable->stOldPhsRulesList[iClassifierIndex];
+
+ (psaClassifiertable->uiOldestPhsRuleIndex)++;
+ }
+ }
+
+ if(eClsContext == eOldClassifierRuleContext)
+ {
+ if(psClassifierRules->pstPhsRule == NULL)
+ {
+ psClassifierRules->pstPhsRule = (S_PHS_RULE*)OsalMemAlloc
+ (sizeof(S_PHS_RULE),PHS_MEM_TAG);
+
+ if(NULL == psClassifierRules->pstPhsRule)
+ return ERR_PHSRULE_MEMALLOC_FAIL;
+ }
+
+ psClassifierRules->bUsed = TRUE;
+ psClassifierRules->uiClassifierRuleId = uiClsId;
+ psClassifierRules->u8PHSI = psPhsRule->u8PHSI;
+ psClassifierRules->bUnclassifiedPHSRule = psPhsRule->bUnclassifiedPHSRule;
+
+ /* Update The PHS rule */
+ OsalMemMove(psClassifierRules->pstPhsRule,
+ psPhsRule, sizeof(S_PHS_RULE));
+ }
+ else
+ {
+ nStatus = UpdateClassifierPHSRule(uiClsId,psClassifierRules,
+ psaClassifiertable,psPhsRule,u8AssociatedPHSI);
+ }
+ return nStatus;
+}
+
+
+UINT UpdateClassifierPHSRule(IN B_UINT16 uiClsId,
+ IN S_CLASSIFIER_ENTRY *pstClassifierEntry,
+ S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,
+ B_UINT8 u8AssociatedPHSI)
+{
+ S_PHS_RULE *pstAddPhsRule = NULL;
+ UINT nPhsRuleIndex = 0;
+ BOOLEAN bPHSRuleOrphaned = FALSE;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ psPhsRule->u8RefCnt =0;
+
+ /* Step 1 Deref Any Exisiting PHS Rule in this classifier Entry*/
+ bPHSRuleOrphaned = DerefPhsRule( uiClsId, psaClassifiertable,
+ pstClassifierEntry->pstPhsRule);
+
+ //Step 2 Search if there is a PHS Rule with u8AssociatedPHSI in Classifier table for this SF
+ nPhsRuleIndex =GetPhsRuleEntry(psaClassifiertable,u8AssociatedPHSI,
+ eActiveClassifierRuleContext, &pstAddPhsRule);
+ if(PHS_INVALID_TABLE_INDEX == nPhsRuleIndex)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nAdding New PHSRuleEntry For Classifier");
+
+ if(psPhsRule->u8PHSI == 0)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nError PHSI is Zero\n");
+ return ERR_PHS_INVALID_PHS_RULE;
+ }
+ //Step 2.a PHS Rule Does Not Exist .Create New PHS Rule for uiClsId
+ if(FALSE == bPHSRuleOrphaned)
+ {
+ pstClassifierEntry->pstPhsRule = (S_PHS_RULE*)OsalMemAlloc(sizeof(S_PHS_RULE),PHS_MEM_TAG);
+ if(NULL == pstClassifierEntry->pstPhsRule)
+ {
+ return ERR_PHSRULE_MEMALLOC_FAIL;
+ }
+ }
+ OsalMemMove(pstClassifierEntry->pstPhsRule, psPhsRule, sizeof(S_PHS_RULE));
+
+ }
+ else
+ {
+ //Step 2.b PHS Rule Exists Tie uiClsId with the existing PHS Rule
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\nTying Classifier to Existing PHS Rule");
+ if(bPHSRuleOrphaned)
+ {
+ if(pstClassifierEntry->pstPhsRule)
+ {
+ //Just Free the PHS Rule as Ref Count is Zero
+ OsalMemFree(pstClassifierEntry->pstPhsRule,sizeof(S_PHS_RULE));
+ pstClassifierEntry->pstPhsRule = NULL;
+
+ }
+
+ }
+ pstClassifierEntry->pstPhsRule = pstAddPhsRule;
+
+ }
+ pstClassifierEntry->bUsed = TRUE;
+ pstClassifierEntry->u8PHSI = pstClassifierEntry->pstPhsRule->u8PHSI;
+ pstClassifierEntry->uiClassifierRuleId = uiClsId;
+ pstClassifierEntry->pstPhsRule->u8RefCnt++;
+ pstClassifierEntry->bUnclassifiedPHSRule = pstClassifierEntry->pstPhsRule->bUnclassifiedPHSRule;
+
+ return PHS_SUCCESS;
+
+}
+
+BOOLEAN DerefPhsRule(IN B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule)
+{
+ if(pstPhsRule==NULL)
+ return FALSE;
+ if(pstPhsRule->u8RefCnt)
+ pstPhsRule->u8RefCnt--;
+ if(0==pstPhsRule->u8RefCnt)
+ {
+ /*if(pstPhsRule->u8PHSI)
+ //Store the currently active rule into the old rules list
+ CreateClassifierPHSRule(uiClsId,psaClassifiertable,pstPhsRule,eOldClassifierRuleContext,pstPhsRule->u8PHSI);*/
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+void DumpBuffer(PVOID BuffVAddress, int xferSize)
+{
+ int i;
+ int iPrintLength;
+ PUCHAR temp=(PUCHAR)BuffVAddress;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ iPrintLength=(xferSize<32?xferSize:32);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n");
+
+ for (i=0;i < iPrintLength;i++) {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "%x|",temp[i]);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_DISPATCH, DBG_LVL_ALL, "\n");
+}
+
+
+void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension)
+{
+ int i,j,k,l;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n Dumping PHS Rules : \n");
+ for(i=0;i<MAX_SERVICEFLOWS;i++)
+ {
+ S_SERVICEFLOW_ENTRY stServFlowEntry =
+ pDeviceExtension->pstServiceFlowPhsRulesTable->stSFList[i];
+ if(stServFlowEntry.bUsed)
+ {
+ for(j=0;j<MAX_PHSRULE_PER_SF;j++)
+ {
+ for(l=0;l<2;l++)
+ {
+ S_CLASSIFIER_ENTRY stClsEntry;
+ if(l==0)
+ {
+ stClsEntry = stServFlowEntry.pstClassifierTable->stActivePhsRulesList[j];
+ if(stClsEntry.bUsed)
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Active PHS Rule : \n");
+ }
+ else
+ {
+ stClsEntry = stServFlowEntry.pstClassifierTable->stOldPhsRulesList[j];
+ if(stClsEntry.bUsed)
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n Old PHS Rule : \n");
+ }
+ if(stClsEntry.bUsed)
+ {
+
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n VCID : %#X",stServFlowEntry.uiVcid);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n ClassifierID : %#X",stClsEntry.uiClassifierRuleId);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSRuleID : %#X",stClsEntry.u8PHSI);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n****************PHS Rule********************\n");
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSI : %#X",stClsEntry.pstPhsRule->u8PHSI);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSFLength : %#X ",stClsEntry.pstPhsRule->u8PHSFLength);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSF : ");
+ for(k=0;k<stClsEntry.pstPhsRule->u8PHSFLength;k++)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSF[k]);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSMLength : %#X",stClsEntry.pstPhsRule->u8PHSMLength);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSM :");
+ for(k=0;k<stClsEntry.pstPhsRule->u8PHSMLength;k++)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "%#X ",stClsEntry.pstPhsRule->u8PHSM[k]);
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSS : %#X ",stClsEntry.pstPhsRule->u8PHSS);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, (DBG_LVL_ALL|DBG_NO_FUNC_PRINT), "\n PHSV : %#X",stClsEntry.pstPhsRule->u8PHSV);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "\n********************************************\n");
+ }
+ }
+ }
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Procedure: phs_decompress
+//
+// Description: This routine restores the static fields within the packet.
+//
+// Arguments:
+// in_buf - ptr to incoming packet buffer.
+// out_buf - ptr to output buffer where the suppressed header is copied.
+// decomp_phs_rules - ptr to PHS rule.
+// header_size - ptr to field which holds the phss or phsf_length.
+//
+// Returns:
+// size -The number of bytes of dynamic fields present with in the incoming packet
+// header.
+// 0 -If PHS rule is NULL.If PHSI is 0 indicateing packet as uncompressed.
+//-----------------------------------------------------------------------------
+
+int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,
+ S_PHS_RULE *decomp_phs_rules,UINT *header_size)
+{
+ int phss,size=0;
+ S_PHS_RULE *tmp_memb;
+ int bit,i=0;
+ unsigned char *phsf,*phsm;
+ int in_buf_len = *header_size-1;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ in_buf++;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"====>\n");
+ *header_size = 0;
+
+ if((decomp_phs_rules == NULL ))
+ return 0;
+
+
+ tmp_memb = decomp_phs_rules;
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI 1 %d",phsi));
+ //*header_size = tmp_memb->u8PHSFLength;
+ phss = tmp_memb->u8PHSS;
+ phsf = tmp_memb->u8PHSF;
+ phsm = tmp_memb->u8PHSM;
+
+ if(phss > MAX_PHS_LENGTHS)
+ phss = MAX_PHS_LENGTHS;
+ //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phs_decompress PHSI %d phss %d index %d",phsi,phss,index));
+ while((phss > 0) && (size < in_buf_len))
+ {
+ bit = ((*phsm << i)& SUPPRESS);
+
+ if(bit == SUPPRESS)
+ {
+ *out_buf = *phsf;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phss %d phsf %d ouput %d",
+ phss,*phsf,*out_buf);
+ }
+ else
+ {
+ *out_buf = *in_buf;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_RECIEVE,DBG_LVL_ALL,"\nDECOMP:In phss %d input %d ouput %d",
+ phss,*in_buf,*out_buf);
+ in_buf++;
+ size++;
+ }
+ out_buf++;
+ phsf++;
+ phss--;
+ i++;
+ *header_size=*header_size + 1;
+
+ if(i > MAX_NO_BIT)
+ {
+ i=0;
+ phsm++;
+ }
+ }
+ return size;
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+// Procedure: phs_compress
+//
+// Description: This routine suppresses the static fields within the packet.Before
+// that it will verify the fields to be suppressed with the corresponding fields in the
+// phsf. For verification it checks the phsv field of PHS rule. If set and verification
+// succeeds it suppresses the field.If any one static field is found different none of
+// the static fields are suppressed then the packet is sent as uncompressed packet with
+// phsi=0.
+//
+// Arguments:
+// phs_rule - ptr to PHS rule.
+// in_buf - ptr to incoming packet buffer.
+// out_buf - ptr to output buffer where the suppressed header is copied.
+// header_size - ptr to field which holds the phss.
+//
+// Returns:
+// size-The number of bytes copied into the output buffer i.e dynamic fields
+// 0 -If PHS rule is NULL.If PHSV field is not set.If the verification fails.
+//-----------------------------------------------------------------------------
+int phs_compress(S_PHS_RULE *phs_rule,unsigned char *in_buf
+ ,unsigned char *out_buf,UINT *header_size,UINT *new_header_size)
+{
+ unsigned char *old_addr = out_buf;
+ int supress = 0;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ if(phs_rule == NULL)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nphs_compress(): phs_rule null!");
+ *out_buf = ZERO_PHSI;
+ return STATUS_PHS_NOCOMPRESSION;
+ }
+
+
+ if(phs_rule->u8PHSS <= *new_header_size)
+ {
+ *header_size = phs_rule->u8PHSS;
+ }
+ else
+ {
+ *header_size = *new_header_size;
+ }
+ //To copy PHSI
+ out_buf++;
+ supress = verify_suppress_phsf(in_buf,out_buf,phs_rule->u8PHSF,
+ phs_rule->u8PHSM, phs_rule->u8PHSS, phs_rule->u8PHSV,new_header_size);
+
+ if(supress == STATUS_PHS_COMPRESSED)
+ {
+ *old_addr = (unsigned char)phs_rule->u8PHSI;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress phsi %d",phs_rule->u8PHSI);
+ }
+ else
+ {
+ *old_addr = ZERO_PHSI;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In phs_compress PHSV Verification failed");
+ }
+ return supress;
+}
+
+
+//-----------------------------------------------------------------------------
+// Procedure: verify_suppress_phsf
+//
+// Description: This routine verifies the fields of the packet and if all the
+// static fields are equal it adds the phsi of that PHS rule.If any static
+// field differs it woun't suppress any field.
+//
+// Arguments:
+// rules_set - ptr to classifier_rules.
+// in_buffer - ptr to incoming packet buffer.
+// out_buffer - ptr to output buffer where the suppressed header is copied.
+// phsf - ptr to phsf.
+// phsm - ptr to phsm.
+// phss - variable holding phss.
+//
+// Returns:
+// size-The number of bytes copied into the output buffer i.e dynamic fields.
+// 0 -Packet has failed the verification.
+//-----------------------------------------------------------------------------
+
+ int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer,
+ unsigned char *phsf,unsigned char *phsm,unsigned int phss,
+ unsigned int phsv,UINT* new_header_size)
+{
+ unsigned int size=0;
+ int bit,i=0;
+ PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev);
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf PHSM - 0x%X",*phsm);
+
+
+ if(phss>(*new_header_size))
+ {
+ phss=*new_header_size;
+ }
+ while(phss > 0)
+ {
+ bit = ((*phsm << i)& SUPPRESS);
+ if(bit == SUPPRESS)
+ {
+
+ if(*in_buffer != *phsf)
+ {
+ if(phsv == VERIFY)
+ {
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf failed for field %d buf %d phsf %d",phss,*in_buffer,*phsf);
+ return STATUS_PHS_NOCOMPRESSION;
+ }
+ }
+ else
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success for field %d buf %d phsf %d",phss,*in_buffer,*phsf);
+ }
+ else
+ {
+ *out_buffer = *in_buffer;
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In copying_header input %d out %d",*in_buffer,*out_buffer);
+ out_buffer++;
+ size++;
+ }
+ in_buffer++;
+ phsf++;
+ phss--;
+ i++;
+ if(i > MAX_NO_BIT)
+ {
+ i=0;
+ phsm++;
+ }
+ }
+ BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, PHS_SEND, DBG_LVL_ALL,"\nCOMP:In verify_phsf success");
+ *new_header_size = size;
+ return STATUS_PHS_COMPRESSED;
+}
+
+
+
+
+
+
diff --git a/drivers/staging/bcm/PHSModule.h b/drivers/staging/bcm/PHSModule.h
new file mode 100644
index 00000000000..bf2b5763252
--- /dev/null
+++ b/drivers/staging/bcm/PHSModule.h
@@ -0,0 +1,95 @@
+#ifndef BCM_MINIPORT_PHSMODULE_H
+#define BCM_MINIPORT_PHSMODULE_H
+
+int PHSTransmit(PMINI_ADAPTER Adapter,
+ struct sk_buff **pPacket,
+ USHORT Vcid,
+ B_UINT16 uiClassifierRuleID,
+ BOOLEAN bHeaderSuppressionEnabled,
+ PUINT PacketLen,
+ UCHAR bEthCSSupport);
+
+int PHSRecieve(PMINI_ADAPTER Adapter,
+ USHORT usVcid,
+ struct sk_buff *packet,
+ UINT *punPacketLen,
+ UCHAR *pucEthernetHdr,
+ UINT
+ );
+
+
+void DumpDataPacketHeader(PUCHAR pPkt);
+
+void DumpFullPacket(UCHAR *pBuf,UINT nPktLen);
+
+void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
+
+
+int phs_init(PPHS_DEVICE_EXTENSION pPhsdeviceExtension,PMINI_ADAPTER Adapter);
+
+void free_phs_serviceflow_rules(S_SERVICEFLOW_TABLE *psServiceFlowRulesTable);
+
+int phs_compress(S_PHS_RULE *phs_members,unsigned char *in_buf,
+ unsigned char *out_buf,unsigned int *header_size,UINT *new_header_size );
+
+
+int verify_suppress_phsf(unsigned char *in_buffer,unsigned char *out_buffer,
+ unsigned char *phsf,unsigned char *phsm,unsigned int phss,unsigned int phsv,UINT *new_header_size );
+
+int phs_decompress(unsigned char *in_buf,unsigned char *out_buf,\
+ S_PHS_RULE *phs_rules,UINT *header_size);
+
+
+int PhsCleanup(PPHS_DEVICE_EXTENSION pPHSDeviceExt);
+
+//Utility Functions
+ULONG PhsUpdateClassifierRule(void* pvContext,B_UINT16 uiVcid,B_UINT16 uiClsId,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI );
+
+ULONG PhsDeletePHSRule(void* pvContext,B_UINT16 uiVcid,B_UINT8 u8PHSI);
+
+ULONG PhsDeleteClassifierRule(void* pvContext, B_UINT16 uiVcid ,B_UINT16 uiClsId);
+
+ULONG PhsDeleteSFRules(void* pvContext,B_UINT16 uiVcid) ;
+
+
+ULONG PhsCompress(void* pvContext,
+ B_UINT16 uiVcid,
+ B_UINT16 uiClsId,
+ void *pvInputBuffer,
+ void *pvOutputBuffer,
+ UINT *pOldHeaderSize,
+ UINT *pNewHeaderSize );
+
+ULONG PhsDeCompress(void* pvContext,
+ B_UINT16 uiVcid,
+ void *pvInputBuffer,
+ void *pvOutputBuffer,
+ UINT *pInHeaderSize,
+ UINT *pOutHeaderSize);
+
+
+BOOLEAN ValidatePHSRule(S_PHS_RULE *psPhsRule);
+
+BOOLEAN ValidatePHSRuleComplete(S_PHS_RULE *psPhsRule);
+
+UINT GetServiceFlowEntry(S_SERVICEFLOW_TABLE *psServiceFlowTable,B_UINT16 uiVcid,S_SERVICEFLOW_ENTRY **ppstServiceFlowEntry);
+
+UINT GetClassifierEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiClsid,E_CLASSIFIER_ENTRY_CONTEXT eClsContext, S_CLASSIFIER_ENTRY **ppstClassifierEntry);
+
+UINT GetPhsRuleEntry(S_CLASSIFIER_TABLE *pstClassifierTable,B_UINT32 uiPHSI,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,S_PHS_RULE **ppstPhsRule);
+
+
+UINT CreateSFToClassifierRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_TABLE *psServiceFlowTable,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI);
+
+UINT CreateClassiferToPHSRuleMapping(B_UINT16 uiVcid,B_UINT16 uiClsId,S_SERVICEFLOW_ENTRY *pstServiceFlowEntry,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI);
+
+UINT CreateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,E_CLASSIFIER_ENTRY_CONTEXT eClsContext,B_UINT8 u8AssociatedPHSI);
+
+UINT UpdateClassifierPHSRule(B_UINT16 uiClsId,S_CLASSIFIER_ENTRY *pstClassifierEntry,S_CLASSIFIER_TABLE *psaClassifiertable ,S_PHS_RULE *psPhsRule,B_UINT8 u8AssociatedPHSI);
+
+BOOLEAN DerefPhsRule(B_UINT16 uiClsId,S_CLASSIFIER_TABLE *psaClassifiertable,S_PHS_RULE *pstPhsRule);
+
+void DumpPhsRules(PPHS_DEVICE_EXTENSION pDeviceExtension);
+
+
+#endif
diff --git a/drivers/staging/bcm/Protocol.h b/drivers/staging/bcm/Protocol.h
new file mode 100644
index 00000000000..00f1cc12356
--- /dev/null
+++ b/drivers/staging/bcm/Protocol.h
@@ -0,0 +1,151 @@
+/************************************
+* Protocol.h
+*************************************/
+#ifndef __PROTOCOL_H__
+#define __PROTOCOL_H__
+
+
+#define IPV4 4
+#define IPV6 6
+
+
+struct ArpHeader {
+ struct arphdr arp;
+ unsigned char ar_sha[ETH_ALEN]; /* sender hardware address */
+ unsigned char ar_sip[4]; /* sender IP address */
+ unsigned char ar_tha[ETH_ALEN]; /* target hardware address */
+ unsigned char ar_tip[4]; /* target IP address */
+}/*__attribute__((packed))*/;
+
+
+struct TransportHeaderT
+{
+ union
+ {
+ struct udphdr uhdr;
+ struct tcphdr thdr;
+ };
+} __attribute__((packed));
+typedef struct TransportHeaderT xporthdr;
+
+
+typedef enum _E_NWPKT_IPFRAME_TYPE
+{
+ eNonIPPacket,
+ eIPv4Packet,
+ eIPv6Packet
+}E_NWPKT_IPFRAME_TYPE;
+
+typedef enum _E_NWPKT_ETHFRAME_TYPE
+{
+ eEthUnsupportedFrame,
+ eEth802LLCFrame,
+ eEth802LLCSNAPFrame,
+ eEth802QVLANFrame,
+ eEthOtherFrame
+} E_NWPKT_ETHFRAME_TYPE;
+
+typedef struct _S_ETHCS_PKT_INFO
+{
+ E_NWPKT_IPFRAME_TYPE eNwpktIPFrameType;
+ E_NWPKT_ETHFRAME_TYPE eNwpktEthFrameType;
+ USHORT usEtherType;
+ UCHAR ucDSAP;
+}S_ETHCS_PKT_INFO,*PS_ETHCS_PKT_INFO;
+
+typedef struct _ETH_CS_802_Q_FRAME
+{
+ ETH_HEADER_STRUC EThHdr;
+ USHORT UserPriority:3;
+ USHORT CFI:1;
+ USHORT VLANID:12;
+ USHORT EthType;
+} __attribute__((packed)) ETH_CS_802_Q_FRAME;
+
+typedef struct _ETH_CS_802_LLC_FRAME
+{
+ ETH_HEADER_STRUC EThHdr;
+ unsigned char DSAP;
+ unsigned char SSAP;
+ unsigned char Control;
+}__attribute__((packed)) ETH_CS_802_LLC_FRAME;
+
+typedef struct _ETH_CS_802_LLC_SNAP_FRAME
+{
+ ETH_HEADER_STRUC EThHdr;
+ unsigned char DSAP;
+ unsigned char SSAP;
+ unsigned char Control;
+ unsigned char OUI[3];
+ unsigned short usEtherType;
+} __attribute__((packed)) ETH_CS_802_LLC_SNAP_FRAME;
+
+typedef struct _ETH_CS_ETH2_FRAME
+{
+ ETH_HEADER_STRUC EThHdr;
+} __attribute__((packed)) ETH_CS_ETH2_FRAME;
+
+
+#define ETHERNET_FRAMETYPE_IPV4 ntohs(0x0800)
+#define ETHERNET_FRAMETYPE_IPV6 ntohs(0x86dd)
+#define ETHERNET_FRAMETYPE_802QVLAN 0x8100
+//Per SF CS Specification Encodings
+typedef enum _E_SERVICEFLOW_CS_SPEC_
+{
+ eCSSpecUnspecified =0,
+ eCSPacketIPV4,
+ eCSPacketIPV6,
+ eCS802_3PacketEthernet,
+ eCS802_1QPacketVLAN,
+ eCSPacketIPV4Over802_3Ethernet,
+ eCSPacketIPV6Over802_3Ethernet,
+ eCSPacketIPV4Over802_1QVLAN,
+ eCSPacketIPV6Over802_1QVLAN,
+ eCSPacketUnsupported
+}E_SERVICEFLOW_CS_SPEC;
+
+
+#define IP6_HEADER_LEN 40
+
+#define IP_VERSION(byte) (((byte&0xF0)>>4))
+
+
+
+#define MAC_ADDRESS_SIZE 6
+#define ETH_AND_IP_HEADER_LEN 14 + 20
+#define L4_SRC_PORT_LEN 2
+#define L4_DEST_PORT_LEN 2
+
+
+
+#define CTRL_PKT_LEN 8 + ETH_AND_IP_HEADER_LEN
+
+#define ETH_ARP_FRAME 0x806
+#define ETH_IPV4_FRAME 0x800
+#define ETH_IPV6_FRAME 0x86DD
+#define UDP 0x11
+#define TCP 0x06
+
+#define ARP_OP_REQUEST 0x01
+#define ARP_OP_REPLY 0x02
+#define ARP_PKT_SIZE 60
+
+// This is the format for the TCP packet header
+typedef struct _TCP_HEADER
+{
+ USHORT usSrcPort;
+ USHORT usDestPort;
+ ULONG ulSeqNumber;
+ ULONG ulAckNumber;
+ UCHAR HeaderLength;
+ UCHAR ucFlags;
+ USHORT usWindowsSize;
+ USHORT usChkSum;
+ USHORT usUrgetPtr;
+} TCP_HEADER,*PTCP_HEADER;
+#define TCP_HEADER_LEN sizeof(TCP_HEADER)
+#define TCP_ACK 0x10 //Bit 4 in tcpflags field.
+#define GET_TCP_HEADER_LEN(byte) ((byte&0xF0)>>4)
+
+
+#endif //__PROTOCOL_H__
diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h
new file mode 100644
index 00000000000..7718937c5bd
--- /dev/null
+++ b/drivers/staging/bcm/Prototypes.h
@@ -0,0 +1,323 @@
+#ifndef _PROTOTYPES_H_
+#define _PROTOTYPES_H_
+
+int BcmFileDownload(PMINI_ADAPTER Adapter,/**< Logical Adapter */
+ char *path, /**< path to image file */
+ unsigned int loc /**< Download Address on the chip*/
+ );
+VOID LinkControlResponseMessage(PMINI_ADAPTER Adapter, PUCHAR pucBuffer);
+
+VOID StatisticsResponse(PMINI_ADAPTER Adapter,PVOID pvBuffer);
+
+VOID IdleModeResponse(PMINI_ADAPTER Adapter,PUINT puiBuffer);
+
+void bcm_kfree_skb(struct sk_buff *skb);
+VOID bcm_kfree(VOID *ptr);
+
+
+VOID handle_rx_control_packet(PMINI_ADAPTER Adapter, /**<Pointer to the Adapter structure*/
+ struct sk_buff *skb); /**<Pointer to the socket buffer*/
+
+int control_packet_handler (PMINI_ADAPTER Adapter);
+
+VOID DeleteAllClassifiersForSF(PMINI_ADAPTER Adapter,UINT uiSearchRuleIndex);
+
+VOID flush_all_queues(PMINI_ADAPTER Adapter);
+
+int register_control_device_interface(PMINI_ADAPTER ps_adapter);
+
+void unregister_control_device_interface(PMINI_ADAPTER Adapter);
+
+INT CopyBufferToControlPacket(PMINI_ADAPTER Adapter,/**<Logical Adapter*/
+ PVOID ioBuffer/**<Control Packet Buffer*/
+ );
+
+VOID SortPackInfo(PMINI_ADAPTER Adapter);
+
+VOID SortClassifiers(PMINI_ADAPTER Adapter);
+
+VOID flush_all_queues(PMINI_ADAPTER Adapter);
+
+USHORT IpVersion4(PMINI_ADAPTER Adapter, /**< Pointer to the driver control structure */
+ struct iphdr *iphd, /**<Pointer to the IP Hdr of the packet*/
+ S_CLASSIFIER_RULE *pstClassifierRule );
+
+VOID PruneQueue(PMINI_ADAPTER Adapter,/**<Pointer to the driver control structure*/
+ INT iIndex/**<Queue Index*/
+ );
+
+VOID PruneQueueAllSF(PMINI_ADAPTER Adapter);
+
+INT SearchSfid(PMINI_ADAPTER Adapter,UINT uiSfid);
+
+USHORT GetPacketQueueIndex(PMINI_ADAPTER Adapter, /**<Pointer to the driver control structure */
+ struct sk_buff* Packet /**< Pointer to the Packet to be sent*/
+ );
+
+VOID
+reply_to_arp_request(struct sk_buff *skb /**<sk_buff of ARP request*/
+ );
+
+INT SetupNextSend(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
+ struct sk_buff *Packet, /**<data buffer*/
+ USHORT Vcid) ;
+
+VOID LinkMessage(PMINI_ADAPTER Adapter);
+
+VOID transmit_packets(PMINI_ADAPTER Adapter);
+
+INT SendControlPacket(PMINI_ADAPTER Adapter, /**<Logical Adapter*/
+ char *pControlPacket/**<Control Packet*/
+ );
+
+INT bcm_transmit(struct sk_buff *skb, /**< skb */
+ struct net_device *dev /**< net device pointer */
+ );
+
+int register_networkdev(PMINI_ADAPTER Adapter);
+
+INT AllocAdapterDsxBuffer(PMINI_ADAPTER Adapter);
+
+VOID AdapterFree(PMINI_ADAPTER Adapter);
+
+INT FreeAdapterDsxBuffer(PMINI_ADAPTER Adapter);
+
+int create_worker_threads(PMINI_ADAPTER psAdapter);
+
+int tx_pkt_handler(PMINI_ADAPTER Adapter);
+
+int reset_card_proc(PMINI_ADAPTER Adapter );
+
+int run_card_proc(PMINI_ADAPTER Adapter );
+
+int InitCardAndDownloadFirmware(PMINI_ADAPTER ps_adapter);
+
+int bcm_parse_target_params(PMINI_ADAPTER Adapter);
+
+INT ReadMacAddressFromNVM(PMINI_ADAPTER Adapter);
+
+int register_control_device_interface(PMINI_ADAPTER ps_adapter);
+
+void DumpPackInfo(PMINI_ADAPTER Adapter);
+
+int rdm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
+
+int wrm(PMINI_ADAPTER Adapter, UINT uiAddress, PCHAR pucBuff, size_t size);
+
+int wrmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
+
+int rdmalt (PMINI_ADAPTER Adapter, UINT uiAddress, PUINT pucBuff, size_t sSize);
+
+int get_dsx_sf_data_to_application(PMINI_ADAPTER Adapter, UINT uiSFId,
+ PUCHAR user_buffer);
+
+void SendLinkDown(PMINI_ADAPTER Adapter);
+
+void SendIdleModeResponse(PMINI_ADAPTER Adapter);
+
+void HandleShutDownModeRequest(PMINI_ADAPTER Adapter,PUCHAR pucBuffer);
+
+int ProcessGetHostMibs(PMINI_ADAPTER Adapter, PVOID ioBuffer,
+ ULONG inputBufferLength);
+
+int GetDroppedAppCntrlPktMibs(PVOID ioBuffer, PPER_TARANG_DATA pTarang);
+void beceem_parse_target_struct(PMINI_ADAPTER Adapter);
+
+void doPowerAutoCorrection(PMINI_ADAPTER psAdapter);