Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ACENIC_H_
0003 #define _ACENIC_H_
0004 #include <linux/interrupt.h>
0005 
0006 
0007 /*
0008  * Generate TX index update each time, when TX ring is closed.
0009  * Normally, this is not useful, because results in more dma (and irqs
0010  * without TX_COAL_INTS_ONLY).
0011  */
0012 #define USE_TX_COAL_NOW  0
0013 
0014 /*
0015  * Addressing:
0016  *
0017  * The Tigon uses 64-bit host addresses, regardless of their actual
0018  * length, and it expects a big-endian format. For 32 bit systems the
0019  * upper 32 bits of the address are simply ignored (zero), however for
0020  * little endian 64 bit systems (Alpha) this looks strange with the
0021  * two parts of the address word being swapped.
0022  *
0023  * The addresses are split in two 32 bit words for all architectures
0024  * as some of them are in PCI shared memory and it is necessary to use
0025  * readl/writel to access them.
0026  *
0027  * The addressing code is derived from Pete Wyckoff's work, but
0028  * modified to deal properly with readl/writel usage.
0029  */
0030 
0031 struct ace_regs {
0032     u32 pad0[16];   /* PCI control registers */
0033 
0034     u32 HostCtrl;   /* 0x40 */
0035     u32 LocalCtrl;
0036 
0037     u32 pad1[2];
0038 
0039     u32 MiscCfg;    /* 0x50 */
0040 
0041     u32 pad2[2];
0042 
0043     u32 PciState;
0044 
0045     u32 pad3[2];    /* 0x60 */
0046 
0047     u32 WinBase;
0048     u32 WinData;
0049 
0050     u32 pad4[12];   /* 0x70 */
0051 
0052     u32 DmaWriteState;  /* 0xa0 */
0053     u32 pad5[3];
0054     u32 DmaReadState;   /* 0xb0 */
0055 
0056     u32 pad6[26];
0057 
0058     u32 AssistState;
0059 
0060     u32 pad7[8];    /* 0x120 */
0061 
0062     u32 CpuCtrl;    /* 0x140 */
0063     u32 Pc;
0064 
0065     u32 pad8[3];
0066 
0067     u32 SramAddr;   /* 0x154 */
0068     u32 SramData;
0069 
0070     u32 pad9[49];
0071 
0072     u32 MacRxState; /* 0x220 */
0073 
0074     u32 pad10[7];
0075 
0076     u32 CpuBCtrl;   /* 0x240 */
0077     u32 PcB;
0078 
0079     u32 pad11[3];
0080 
0081     u32 SramBAddr;  /* 0x254 */
0082     u32 SramBData;
0083 
0084     u32 pad12[105];
0085 
0086     u32 pad13[32];  /* 0x400 */
0087     u32 Stats[32];
0088 
0089     u32 Mb0Hi;      /* 0x500 */
0090     u32 Mb0Lo;
0091     u32 Mb1Hi;
0092     u32 CmdPrd;
0093     u32 Mb2Hi;
0094     u32 TxPrd;
0095     u32 Mb3Hi;
0096     u32 RxStdPrd;
0097     u32 Mb4Hi;
0098     u32 RxJumboPrd;
0099     u32 Mb5Hi;
0100     u32 RxMiniPrd;
0101     u32 Mb6Hi;
0102     u32 Mb6Lo;
0103     u32 Mb7Hi;
0104     u32 Mb7Lo;
0105     u32 Mb8Hi;
0106     u32 Mb8Lo;
0107     u32 Mb9Hi;
0108     u32 Mb9Lo;
0109     u32 MbAHi;
0110     u32 MbALo;
0111     u32 MbBHi;
0112     u32 MbBLo;
0113     u32 MbCHi;
0114     u32 MbCLo;
0115     u32 MbDHi;
0116     u32 MbDLo;
0117     u32 MbEHi;
0118     u32 MbELo;
0119     u32 MbFHi;
0120     u32 MbFLo;
0121 
0122     u32 pad14[32];
0123 
0124     u32 MacAddrHi;  /* 0x600 */
0125     u32 MacAddrLo;
0126     u32 InfoPtrHi;
0127     u32 InfoPtrLo;
0128     u32 MultiCastHi;    /* 0x610 */
0129     u32 MultiCastLo;
0130     u32 ModeStat;
0131     u32 DmaReadCfg;
0132     u32 DmaWriteCfg;    /* 0x620 */
0133     u32 TxBufRat;
0134     u32 EvtCsm;
0135     u32 CmdCsm;
0136     u32 TuneRxCoalTicks;/* 0x630 */
0137     u32 TuneTxCoalTicks;
0138     u32 TuneStatTicks;
0139     u32 TuneMaxTxDesc;
0140     u32 TuneMaxRxDesc;  /* 0x640 */
0141     u32 TuneTrace;
0142     u32 TuneLink;
0143     u32 TuneFastLink;
0144     u32 TracePtr;   /* 0x650 */
0145     u32 TraceStrt;
0146     u32 TraceLen;
0147     u32 IfIdx;
0148     u32 IfMtu;      /* 0x660 */
0149     u32 MaskInt;
0150     u32 GigLnkState;
0151     u32 FastLnkState;
0152     u32 pad16[4];   /* 0x670 */
0153     u32 RxRetCsm;   /* 0x680 */
0154 
0155     u32 pad17[31];
0156 
0157     u32 CmdRng[64]; /* 0x700 */
0158     u32 Window[0x200];
0159 };
0160 
0161 
0162 typedef struct {
0163     u32 addrhi;
0164     u32 addrlo;
0165 } aceaddr;
0166 
0167 
0168 #define ACE_WINDOW_SIZE 0x800
0169 
0170 #define ACE_JUMBO_MTU 9000
0171 #define ACE_STD_MTU 1500
0172 
0173 #define ACE_TRACE_SIZE 0x8000
0174 
0175 /*
0176  * Host control register bits.
0177  */
0178 
0179 #define IN_INT      0x01
0180 #define CLR_INT     0x02
0181 #define HW_RESET    0x08
0182 #define BYTE_SWAP   0x10
0183 #define WORD_SWAP   0x20
0184 #define MASK_INTS   0x40
0185 
0186 /*
0187  * Local control register bits.
0188  */
0189 
0190 #define EEPROM_DATA_IN      0x800000
0191 #define EEPROM_DATA_OUT     0x400000
0192 #define EEPROM_WRITE_ENABLE 0x200000
0193 #define EEPROM_CLK_OUT      0x100000
0194 
0195 #define EEPROM_BASE     0xa0000000
0196 
0197 #define EEPROM_WRITE_SELECT 0xa0
0198 #define EEPROM_READ_SELECT  0xa1
0199 
0200 #define SRAM_BANK_512K      0x200
0201 
0202 
0203 /*
0204  * udelay() values for when clocking the eeprom
0205  */
0206 #define ACE_SHORT_DELAY     2
0207 #define ACE_LONG_DELAY      4
0208 
0209 
0210 /*
0211  * Misc Config bits
0212  */
0213 
0214 #define SYNC_SRAM_TIMING    0x100000
0215 
0216 
0217 /*
0218  * CPU state bits.
0219  */
0220 
0221 #define CPU_RESET       0x01
0222 #define CPU_TRACE       0x02
0223 #define CPU_PROM_FAILED     0x10
0224 #define CPU_HALT        0x00010000
0225 #define CPU_HALTED      0xffff0000
0226 
0227 
0228 /*
0229  * PCI State bits.
0230  */
0231 
0232 #define DMA_READ_MAX_4      0x04
0233 #define DMA_READ_MAX_16     0x08
0234 #define DMA_READ_MAX_32     0x0c
0235 #define DMA_READ_MAX_64     0x10
0236 #define DMA_READ_MAX_128    0x14
0237 #define DMA_READ_MAX_256    0x18
0238 #define DMA_READ_MAX_1K     0x1c
0239 #define DMA_WRITE_MAX_4     0x20
0240 #define DMA_WRITE_MAX_16    0x40
0241 #define DMA_WRITE_MAX_32    0x60
0242 #define DMA_WRITE_MAX_64    0x80
0243 #define DMA_WRITE_MAX_128   0xa0
0244 #define DMA_WRITE_MAX_256   0xc0
0245 #define DMA_WRITE_MAX_1K    0xe0
0246 #define DMA_READ_WRITE_MASK 0xfc
0247 #define MEM_READ_MULTIPLE   0x00020000
0248 #define PCI_66MHZ       0x00080000
0249 #define PCI_32BIT       0x00100000
0250 #define DMA_WRITE_ALL_ALIGN 0x00800000
0251 #define READ_CMD_MEM        0x06000000
0252 #define WRITE_CMD_MEM       0x70000000
0253 
0254 
0255 /*
0256  * Mode status
0257  */
0258 
0259 #define ACE_BYTE_SWAP_BD    0x02
0260 #define ACE_WORD_SWAP_BD    0x04        /* not actually used */
0261 #define ACE_WARN        0x08
0262 #define ACE_BYTE_SWAP_DMA   0x10
0263 #define ACE_NO_JUMBO_FRAG   0x200
0264 #define ACE_FATAL       0x40000000
0265 
0266 
0267 /*
0268  * DMA config
0269  */
0270 
0271 #define DMA_THRESH_1W       0x10
0272 #define DMA_THRESH_2W       0x20
0273 #define DMA_THRESH_4W       0x40
0274 #define DMA_THRESH_8W       0x80
0275 #define DMA_THRESH_16W      0x100
0276 #define DMA_THRESH_32W      0x0 /* not described in doc, but exists. */
0277 
0278 
0279 /*
0280  * Tuning parameters
0281  */
0282 
0283 #define TICKS_PER_SEC       1000000
0284 
0285 
0286 /*
0287  * Link bits
0288  */
0289 
0290 #define LNK_PREF        0x00008000
0291 #define LNK_10MB        0x00010000
0292 #define LNK_100MB       0x00020000
0293 #define LNK_1000MB      0x00040000
0294 #define LNK_FULL_DUPLEX     0x00080000
0295 #define LNK_HALF_DUPLEX     0x00100000
0296 #define LNK_TX_FLOW_CTL_Y   0x00200000
0297 #define LNK_NEG_ADVANCED    0x00400000
0298 #define LNK_RX_FLOW_CTL_Y   0x00800000
0299 #define LNK_NIC         0x01000000
0300 #define LNK_JAM         0x02000000
0301 #define LNK_JUMBO       0x04000000
0302 #define LNK_ALTEON      0x08000000
0303 #define LNK_NEG_FCTL        0x10000000
0304 #define LNK_NEGOTIATE       0x20000000
0305 #define LNK_ENABLE      0x40000000
0306 #define LNK_UP          0x80000000
0307 
0308 
0309 /*
0310  * Event definitions
0311  */
0312 
0313 #define EVT_RING_ENTRIES    256
0314 #define EVT_RING_SIZE   (EVT_RING_ENTRIES * sizeof(struct event))
0315 
0316 struct event {
0317 #ifdef __LITTLE_ENDIAN_BITFIELD
0318     u32 idx:12;
0319     u32 code:12;
0320     u32 evt:8;
0321 #else
0322     u32 evt:8;
0323     u32 code:12;
0324     u32 idx:12;
0325 #endif
0326     u32     pad;
0327 };
0328 
0329 
0330 /*
0331  * Events
0332  */
0333 
0334 #define E_FW_RUNNING        0x01
0335 #define E_STATS_UPDATED     0x04
0336 
0337 #define E_STATS_UPDATE      0x04
0338 
0339 #define E_LNK_STATE     0x06
0340 #define E_C_LINK_UP     0x01
0341 #define E_C_LINK_DOWN       0x02
0342 #define E_C_LINK_10_100     0x03
0343 
0344 #define E_ERROR         0x07
0345 #define E_C_ERR_INVAL_CMD   0x01
0346 #define E_C_ERR_UNIMP_CMD   0x02
0347 #define E_C_ERR_BAD_CFG     0x03
0348 
0349 #define E_MCAST_LIST        0x08
0350 #define E_C_MCAST_ADDR_ADD  0x01
0351 #define E_C_MCAST_ADDR_DEL  0x02
0352 
0353 #define E_RESET_JUMBO_RNG   0x09
0354 
0355 
0356 /*
0357  * Commands
0358  */
0359 
0360 #define CMD_RING_ENTRIES    64
0361 
0362 struct cmd {
0363 #ifdef __LITTLE_ENDIAN_BITFIELD
0364     u32 idx:12;
0365     u32 code:12;
0366     u32 evt:8;
0367 #else
0368     u32 evt:8;
0369     u32 code:12;
0370     u32 idx:12;
0371 #endif
0372 };
0373 
0374 
0375 #define C_HOST_STATE        0x01
0376 #define C_C_STACK_UP        0x01
0377 #define C_C_STACK_DOWN      0x02
0378 
0379 #define C_FDR_FILTERING     0x02
0380 #define C_C_FDR_FILT_ENABLE 0x01
0381 #define C_C_FDR_FILT_DISABLE    0x02
0382 
0383 #define C_SET_RX_PRD_IDX    0x03
0384 #define C_UPDATE_STATS      0x04
0385 #define C_RESET_JUMBO_RNG   0x05
0386 #define C_ADD_MULTICAST_ADDR    0x08
0387 #define C_DEL_MULTICAST_ADDR    0x09
0388 
0389 #define C_SET_PROMISC_MODE  0x0a
0390 #define C_C_PROMISC_ENABLE  0x01
0391 #define C_C_PROMISC_DISABLE 0x02
0392 
0393 #define C_LNK_NEGOTIATION   0x0b
0394 #define C_C_NEGOTIATE_BOTH  0x00
0395 #define C_C_NEGOTIATE_GIG   0x01
0396 #define C_C_NEGOTIATE_10_100    0x02
0397 
0398 #define C_SET_MAC_ADDR      0x0c
0399 #define C_CLEAR_PROFILE     0x0d
0400 
0401 #define C_SET_MULTICAST_MODE    0x0e
0402 #define C_C_MCAST_ENABLE    0x01
0403 #define C_C_MCAST_DISABLE   0x02
0404 
0405 #define C_CLEAR_STATS       0x0f
0406 #define C_SET_RX_JUMBO_PRD_IDX  0x10
0407 #define C_REFRESH_STATS     0x11
0408 
0409 
0410 /*
0411  * Descriptor flags
0412  */
0413 #define BD_FLG_TCP_UDP_SUM  0x01
0414 #define BD_FLG_IP_SUM       0x02
0415 #define BD_FLG_END      0x04
0416 #define BD_FLG_MORE     0x08
0417 #define BD_FLG_JUMBO        0x10
0418 #define BD_FLG_UCAST        0x20
0419 #define BD_FLG_MCAST        0x40
0420 #define BD_FLG_BCAST        0x60
0421 #define BD_FLG_TYP_MASK     0x60
0422 #define BD_FLG_IP_FRAG      0x80
0423 #define BD_FLG_IP_FRAG_END  0x100
0424 #define BD_FLG_VLAN_TAG     0x200
0425 #define BD_FLG_FRAME_ERROR  0x400
0426 #define BD_FLG_COAL_NOW     0x800
0427 #define BD_FLG_MINI     0x1000
0428 
0429 
0430 /*
0431  * Ring Control block flags
0432  */
0433 #define RCB_FLG_TCP_UDP_SUM 0x01
0434 #define RCB_FLG_IP_SUM      0x02
0435 #define RCB_FLG_NO_PSEUDO_HDR   0x08
0436 #define RCB_FLG_VLAN_ASSIST 0x10
0437 #define RCB_FLG_COAL_INT_ONLY   0x20
0438 #define RCB_FLG_TX_HOST_RING    0x40
0439 #define RCB_FLG_IEEE_SNAP_SUM   0x80
0440 #define RCB_FLG_EXT_RX_BD   0x100
0441 #define RCB_FLG_RNG_DISABLE 0x200
0442 
0443 
0444 /*
0445  * TX ring - maximum TX ring entries for Tigon I's is 128
0446  */
0447 #define MAX_TX_RING_ENTRIES 256
0448 #define TIGON_I_TX_RING_ENTRIES 128
0449 #define TX_RING_SIZE        (MAX_TX_RING_ENTRIES * sizeof(struct tx_desc))
0450 #define TX_RING_BASE        0x3800
0451 
0452 struct tx_desc{
0453         aceaddr addr;
0454     u32 flagsize;
0455 #if 0
0456 /*
0457  * This is in PCI shared mem and must be accessed with readl/writel
0458  * real layout is:
0459  */
0460 #if __LITTLE_ENDIAN
0461     u16 flags;
0462     u16 size;
0463     u16 vlan;
0464     u16 reserved;
0465 #else
0466     u16 size;
0467     u16 flags;
0468     u16 reserved;
0469     u16 vlan;
0470 #endif
0471 #endif
0472     u32 vlanres;
0473 };
0474 
0475 
0476 #define RX_STD_RING_ENTRIES 512
0477 #define RX_STD_RING_SIZE    (RX_STD_RING_ENTRIES * sizeof(struct rx_desc))
0478 
0479 #define RX_JUMBO_RING_ENTRIES   256
0480 #define RX_JUMBO_RING_SIZE  (RX_JUMBO_RING_ENTRIES *sizeof(struct rx_desc))
0481 
0482 #define RX_MINI_RING_ENTRIES    1024
0483 #define RX_MINI_RING_SIZE   (RX_MINI_RING_ENTRIES *sizeof(struct rx_desc))
0484 
0485 #define RX_RETURN_RING_ENTRIES  2048
0486 #define RX_RETURN_RING_SIZE (RX_MAX_RETURN_RING_ENTRIES * \
0487                  sizeof(struct rx_desc))
0488 
0489 struct rx_desc{
0490     aceaddr addr;
0491 #ifdef __LITTLE_ENDIAN
0492     u16 size;
0493     u16 idx;
0494 #else
0495     u16 idx;
0496     u16 size;
0497 #endif
0498 #ifdef __LITTLE_ENDIAN
0499     u16 flags;
0500     u16 type;
0501 #else
0502     u16 type;
0503     u16 flags;
0504 #endif
0505 #ifdef __LITTLE_ENDIAN
0506     u16 tcp_udp_csum;
0507     u16 ip_csum;
0508 #else
0509     u16 ip_csum;
0510     u16 tcp_udp_csum;
0511 #endif
0512 #ifdef __LITTLE_ENDIAN
0513     u16 vlan;
0514     u16 err_flags;
0515 #else
0516     u16 err_flags;
0517     u16 vlan;
0518 #endif
0519     u32 reserved;
0520     u32 opague;
0521 };
0522 
0523 
0524 /*
0525  * This struct is shared with the NIC firmware.
0526  */
0527 struct ring_ctrl {
0528     aceaddr rngptr;
0529 #ifdef __LITTLE_ENDIAN
0530     u16 flags;
0531     u16 max_len;
0532 #else
0533     u16 max_len;
0534     u16 flags;
0535 #endif
0536     u32 pad;
0537 };
0538 
0539 
0540 struct ace_mac_stats {
0541     u32 excess_colls;
0542     u32 coll_1;
0543     u32 coll_2;
0544     u32 coll_3;
0545     u32 coll_4;
0546     u32 coll_5;
0547     u32 coll_6;
0548     u32 coll_7;
0549     u32 coll_8;
0550     u32 coll_9;
0551     u32 coll_10;
0552     u32 coll_11;
0553     u32 coll_12;
0554     u32 coll_13;
0555     u32 coll_14;
0556     u32 coll_15;
0557     u32 late_coll;
0558     u32 defers;
0559     u32 crc_err;
0560     u32 underrun;
0561     u32 crs_err;
0562     u32 pad[3];
0563     u32 drop_ula;
0564     u32 drop_mc;
0565     u32 drop_fc;
0566     u32 drop_space;
0567     u32 coll;
0568     u32 kept_bc;
0569     u32 kept_mc;
0570     u32 kept_uc;
0571 };
0572 
0573 
0574 struct ace_info {
0575     union {
0576         u32 stats[256];
0577     } s;
0578     struct ring_ctrl    evt_ctrl;
0579     struct ring_ctrl    cmd_ctrl;
0580     struct ring_ctrl    tx_ctrl;
0581     struct ring_ctrl    rx_std_ctrl;
0582     struct ring_ctrl    rx_jumbo_ctrl;
0583     struct ring_ctrl    rx_mini_ctrl;
0584     struct ring_ctrl    rx_return_ctrl;
0585     aceaddr evt_prd_ptr;
0586     aceaddr rx_ret_prd_ptr;
0587     aceaddr tx_csm_ptr;
0588     aceaddr stats2_ptr;
0589 };
0590 
0591 
0592 struct ring_info {
0593     struct sk_buff      *skb;
0594     DEFINE_DMA_UNMAP_ADDR(mapping);
0595 };
0596 
0597 
0598 /*
0599  * Funny... As soon as we add maplen on alpha, it starts to work
0600  * much slower. Hmm... is it because struct does not fit to one cacheline?
0601  * So, split tx_ring_info.
0602  */
0603 struct tx_ring_info {
0604     struct sk_buff      *skb;
0605     DEFINE_DMA_UNMAP_ADDR(mapping);
0606     DEFINE_DMA_UNMAP_LEN(maplen);
0607 };
0608 
0609 
0610 /*
0611  * struct ace_skb holding the rings of skb's. This is an awful lot of
0612  * pointers, but I don't see any other smart mode to do this in an
0613  * efficient manner ;-(
0614  */
0615 struct ace_skb
0616 {
0617     struct tx_ring_info tx_skbuff[MAX_TX_RING_ENTRIES];
0618     struct ring_info    rx_std_skbuff[RX_STD_RING_ENTRIES];
0619     struct ring_info    rx_mini_skbuff[RX_MINI_RING_ENTRIES];
0620     struct ring_info    rx_jumbo_skbuff[RX_JUMBO_RING_ENTRIES];
0621 };
0622 
0623 
0624 /*
0625  * Struct private for the AceNIC.
0626  *
0627  * Elements are grouped so variables used by the tx handling goes
0628  * together, and will go into the same cache lines etc. in order to
0629  * avoid cache line contention between the rx and tx handling on SMP.
0630  *
0631  * Frequently accessed variables are put at the beginning of the
0632  * struct to help the compiler generate better/shorter code.
0633  */
0634 struct ace_private
0635 {
0636     struct net_device   *ndev;      /* backpointer */
0637     struct ace_info     *info;
0638     struct ace_regs __iomem *regs;      /* register base */
0639     struct ace_skb      *skb;
0640     dma_addr_t      info_dma;   /* 32/64 bit */
0641 
0642     int         version, link;
0643     int         promisc, mcast_all;
0644 
0645     /*
0646      * TX elements
0647      */
0648     struct tx_desc      *tx_ring;
0649     u32         tx_prd;
0650     volatile u32        tx_ret_csm;
0651     int         tx_ring_entries;
0652 
0653     /*
0654      * RX elements
0655      */
0656     unsigned long       std_refill_busy
0657                 __attribute__ ((aligned (SMP_CACHE_BYTES)));
0658     unsigned long       mini_refill_busy, jumbo_refill_busy;
0659     atomic_t        cur_rx_bufs;
0660     atomic_t        cur_mini_bufs;
0661     atomic_t        cur_jumbo_bufs;
0662     u32         rx_std_skbprd, rx_mini_skbprd, rx_jumbo_skbprd;
0663     u32         cur_rx;
0664 
0665     struct rx_desc      *rx_std_ring;
0666     struct rx_desc      *rx_jumbo_ring;
0667     struct rx_desc      *rx_mini_ring;
0668     struct rx_desc      *rx_return_ring;
0669 
0670     int         tasklet_pending, jumbo;
0671     struct tasklet_struct   ace_tasklet;
0672 
0673     struct event        *evt_ring;
0674 
0675     volatile u32        *evt_prd, *rx_ret_prd, *tx_csm;
0676 
0677     dma_addr_t      tx_ring_dma;    /* 32/64 bit */
0678     dma_addr_t      rx_ring_base_dma;
0679     dma_addr_t      evt_ring_dma;
0680     dma_addr_t      evt_prd_dma, rx_ret_prd_dma, tx_csm_dma;
0681 
0682     unsigned char       *trace_buf;
0683     struct pci_dev      *pdev;
0684     struct net_device   *next;
0685     volatile int        fw_running;
0686     int         board_idx;
0687     u16         pci_command;
0688     u8          pci_latency;
0689     const char      *name;
0690 #ifdef INDEX_DEBUG
0691     spinlock_t      debug_lock
0692                 __attribute__ ((aligned (SMP_CACHE_BYTES)));
0693     u32         last_tx, last_std_rx, last_mini_rx;
0694 #endif
0695     u8          firmware_major;
0696     u8          firmware_minor;
0697     u8          firmware_fix;
0698     u32         firmware_start;
0699 };
0700 
0701 
0702 #define TX_RESERVED MAX_SKB_FRAGS
0703 
0704 static inline int tx_space (struct ace_private *ap, u32 csm, u32 prd)
0705 {
0706     return (csm - prd - 1) & (ACE_TX_RING_ENTRIES(ap) - 1);
0707 }
0708 
0709 #define tx_free(ap)         tx_space((ap)->tx_ret_csm, (ap)->tx_prd, ap)
0710 #define tx_ring_full(ap, csm, prd)  (tx_space(ap, csm, prd) <= TX_RESERVED)
0711 
0712 static inline void set_aceaddr(aceaddr *aa, dma_addr_t addr)
0713 {
0714     u64 baddr = (u64) addr;
0715     aa->addrlo = baddr & 0xffffffff;
0716     aa->addrhi = baddr >> 32;
0717     wmb();
0718 }
0719 
0720 
0721 static inline void ace_set_txprd(struct ace_regs __iomem *regs,
0722                  struct ace_private *ap, u32 value)
0723 {
0724 #ifdef INDEX_DEBUG
0725     unsigned long flags;
0726     spin_lock_irqsave(&ap->debug_lock, flags);
0727     writel(value, &regs->TxPrd);
0728     if (value == ap->last_tx)
0729         printk(KERN_ERR "AceNIC RACE ALERT! writing identical value "
0730                "to tx producer (%i)\n", value);
0731     ap->last_tx = value;
0732     spin_unlock_irqrestore(&ap->debug_lock, flags);
0733 #else
0734     writel(value, &regs->TxPrd);
0735 #endif
0736     wmb();
0737 }
0738 
0739 
0740 static inline void ace_mask_irq(struct net_device *dev)
0741 {
0742     struct ace_private *ap = netdev_priv(dev);
0743     struct ace_regs __iomem *regs = ap->regs;
0744 
0745     if (ACE_IS_TIGON_I(ap))
0746         writel(1, &regs->MaskInt);
0747     else
0748         writel(readl(&regs->HostCtrl) | MASK_INTS, &regs->HostCtrl);
0749 
0750     ace_sync_irq(dev->irq);
0751 }
0752 
0753 
0754 static inline void ace_unmask_irq(struct net_device *dev)
0755 {
0756     struct ace_private *ap = netdev_priv(dev);
0757     struct ace_regs __iomem *regs = ap->regs;
0758 
0759     if (ACE_IS_TIGON_I(ap))
0760         writel(0, &regs->MaskInt);
0761     else
0762         writel(readl(&regs->HostCtrl) & ~MASK_INTS, &regs->HostCtrl);
0763 }
0764 
0765 
0766 /*
0767  * Prototypes
0768  */
0769 static int ace_init(struct net_device *dev);
0770 static void ace_load_std_rx_ring(struct net_device *dev, int nr_bufs);
0771 static void ace_load_mini_rx_ring(struct net_device *dev, int nr_bufs);
0772 static void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs);
0773 static irqreturn_t ace_interrupt(int irq, void *dev_id);
0774 static int ace_load_firmware(struct net_device *dev);
0775 static int ace_open(struct net_device *dev);
0776 static netdev_tx_t ace_start_xmit(struct sk_buff *skb,
0777                   struct net_device *dev);
0778 static int ace_close(struct net_device *dev);
0779 static void ace_tasklet(struct tasklet_struct *t);
0780 static void ace_dump_trace(struct ace_private *ap);
0781 static void ace_set_multicast_list(struct net_device *dev);
0782 static int ace_change_mtu(struct net_device *dev, int new_mtu);
0783 static int ace_set_mac_addr(struct net_device *dev, void *p);
0784 static void ace_set_rxtx_parms(struct net_device *dev, int jumbo);
0785 static int ace_allocate_descriptors(struct net_device *dev);
0786 static void ace_free_descriptors(struct net_device *dev);
0787 static void ace_init_cleanup(struct net_device *dev);
0788 static struct net_device_stats *ace_get_stats(struct net_device *dev);
0789 static int read_eeprom_byte(struct net_device *dev, unsigned long offset);
0790 
0791 #endif /* _ACENIC_H_ */