sge.c 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685
  1. /*****************************************************************************
  2. * *
  3. * File: sge.c *
  4. * $Revision: 1.26 $ *
  5. * $Date: 2005/06/21 18:29:48 $ *
  6. * Description: *
  7. * DMA engine. *
  8. * part of the Chelsio 10Gb Ethernet Driver. *
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License, version 2, as *
  12. * published by the Free Software Foundation. *
  13. * *
  14. * You should have received a copy of the GNU General Public License along *
  15. * with this program; if not, write to the Free Software Foundation, Inc., *
  16. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  17. * *
  18. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED *
  19. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF *
  20. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
  21. * *
  22. * http://www.chelsio.com *
  23. * *
  24. * Copyright (c) 2003 - 2005 Chelsio Communications, Inc. *
  25. * All rights reserved. *
  26. * *
  27. * Maintainers: maintainers@chelsio.com *
  28. * *
  29. * Authors: Dimitrios Michailidis <dm@chelsio.com> *
  30. * Tina Yang <tainay@chelsio.com> *
  31. * Felix Marti <felix@chelsio.com> *
  32. * Scott Bardone <sbardone@chelsio.com> *
  33. * Kurt Ottaway <kottaway@chelsio.com> *
  34. * Frank DiMambro <frank@chelsio.com> *
  35. * *
  36. * History: *
  37. * *
  38. ****************************************************************************/
  39. #include "common.h"
  40. #include <linux/config.h>
  41. #include <linux/types.h>
  42. #include <linux/errno.h>
  43. #include <linux/pci.h>
  44. #include <linux/netdevice.h>
  45. #include <linux/etherdevice.h>
  46. #include <linux/if_vlan.h>
  47. #include <linux/skbuff.h>
  48. #include <linux/init.h>
  49. #include <linux/mm.h>
  50. #include <linux/ip.h>
  51. #include <linux/in.h>
  52. #include <linux/if_arp.h>
  53. #include "cpl5_cmd.h"
  54. #include "sge.h"
  55. #include "regs.h"
  56. #include "espi.h"
  57. #ifdef NETIF_F_TSO
  58. #include <linux/tcp.h>
  59. #endif
  60. #define SGE_CMDQ_N 2
  61. #define SGE_FREELQ_N 2
  62. #define SGE_CMDQ0_E_N 1024
  63. #define SGE_CMDQ1_E_N 128
  64. #define SGE_FREEL_SIZE 4096
  65. #define SGE_JUMBO_FREEL_SIZE 512
  66. #define SGE_FREEL_REFILL_THRESH 16
  67. #define SGE_RESPQ_E_N 1024
  68. #define SGE_INTRTIMER_NRES 1000
  69. #define SGE_RX_COPY_THRES 256
  70. #define SGE_RX_SM_BUF_SIZE 1536
  71. # define SGE_RX_DROP_THRES 2
  72. #define SGE_RESPQ_REPLENISH_THRES (SGE_RESPQ_E_N / 4)
  73. /*
  74. * Period of the TX buffer reclaim timer. This timer does not need to run
  75. * frequently as TX buffers are usually reclaimed by new TX packets.
  76. */
  77. #define TX_RECLAIM_PERIOD (HZ / 4)
  78. #ifndef NET_IP_ALIGN
  79. # define NET_IP_ALIGN 2
  80. #endif
  81. #define M_CMD_LEN 0x7fffffff
  82. #define V_CMD_LEN(v) (v)
  83. #define G_CMD_LEN(v) ((v) & M_CMD_LEN)
  84. #define V_CMD_GEN1(v) ((v) << 31)
  85. #define V_CMD_GEN2(v) (v)
  86. #define F_CMD_DATAVALID (1 << 1)
  87. #define F_CMD_SOP (1 << 2)
  88. #define V_CMD_EOP(v) ((v) << 3)
  89. /*
  90. * Command queue, receive buffer list, and response queue descriptors.
  91. */
  92. #if defined(__BIG_ENDIAN_BITFIELD)
  93. struct cmdQ_e {
  94. u32 addr_lo;
  95. u32 len_gen;
  96. u32 flags;
  97. u32 addr_hi;
  98. };
  99. struct freelQ_e {
  100. u32 addr_lo;
  101. u32 len_gen;
  102. u32 gen2;
  103. u32 addr_hi;
  104. };
  105. struct respQ_e {
  106. u32 Qsleeping : 4;
  107. u32 Cmdq1CreditReturn : 5;
  108. u32 Cmdq1DmaComplete : 5;
  109. u32 Cmdq0CreditReturn : 5;
  110. u32 Cmdq0DmaComplete : 5;
  111. u32 FreelistQid : 2;
  112. u32 CreditValid : 1;
  113. u32 DataValid : 1;
  114. u32 Offload : 1;
  115. u32 Eop : 1;
  116. u32 Sop : 1;
  117. u32 GenerationBit : 1;
  118. u32 BufferLength;
  119. };
  120. #elif defined(__LITTLE_ENDIAN_BITFIELD)
  121. struct cmdQ_e {
  122. u32 len_gen;
  123. u32 addr_lo;
  124. u32 addr_hi;
  125. u32 flags;
  126. };
  127. struct freelQ_e {
  128. u32 len_gen;
  129. u32 addr_lo;
  130. u32 addr_hi;
  131. u32 gen2;
  132. };
  133. struct respQ_e {
  134. u32 BufferLength;
  135. u32 GenerationBit : 1;
  136. u32 Sop : 1;
  137. u32 Eop : 1;
  138. u32 Offload : 1;
  139. u32 DataValid : 1;
  140. u32 CreditValid : 1;
  141. u32 FreelistQid : 2;
  142. u32 Cmdq0DmaComplete : 5;
  143. u32 Cmdq0CreditReturn : 5;
  144. u32 Cmdq1DmaComplete : 5;
  145. u32 Cmdq1CreditReturn : 5;
  146. u32 Qsleeping : 4;
  147. } ;
  148. #endif
  149. /*
  150. * SW Context Command and Freelist Queue Descriptors
  151. */
  152. struct cmdQ_ce {
  153. struct sk_buff *skb;
  154. DECLARE_PCI_UNMAP_ADDR(dma_addr);
  155. DECLARE_PCI_UNMAP_LEN(dma_len);
  156. };
  157. struct freelQ_ce {
  158. struct sk_buff *skb;
  159. DECLARE_PCI_UNMAP_ADDR(dma_addr);
  160. DECLARE_PCI_UNMAP_LEN(dma_len);
  161. };
  162. /*
  163. * SW command, freelist and response rings
  164. */
  165. struct cmdQ {
  166. unsigned long status; /* HW DMA fetch status */
  167. unsigned int in_use; /* # of in-use command descriptors */
  168. unsigned int size; /* # of descriptors */
  169. unsigned int processed; /* total # of descs HW has processed */
  170. unsigned int cleaned; /* total # of descs SW has reclaimed */
  171. unsigned int stop_thres; /* SW TX queue suspend threshold */
  172. u16 pidx; /* producer index (SW) */
  173. u16 cidx; /* consumer index (HW) */
  174. u8 genbit; /* current generation (=valid) bit */
  175. u8 sop; /* is next entry start of packet? */
  176. struct cmdQ_e *entries; /* HW command descriptor Q */
  177. struct cmdQ_ce *centries; /* SW command context descriptor Q */
  178. spinlock_t lock; /* Lock to protect cmdQ enqueuing */
  179. dma_addr_t dma_addr; /* DMA addr HW command descriptor Q */
  180. };
  181. struct freelQ {
  182. unsigned int credits; /* # of available RX buffers */
  183. unsigned int size; /* free list capacity */
  184. u16 pidx; /* producer index (SW) */
  185. u16 cidx; /* consumer index (HW) */
  186. u16 rx_buffer_size; /* Buffer size on this free list */
  187. u16 dma_offset; /* DMA offset to align IP headers */
  188. u16 recycleq_idx; /* skb recycle q to use */
  189. u8 genbit; /* current generation (=valid) bit */
  190. struct freelQ_e *entries; /* HW freelist descriptor Q */
  191. struct freelQ_ce *centries; /* SW freelist context descriptor Q */
  192. dma_addr_t dma_addr; /* DMA addr HW freelist descriptor Q */
  193. };
  194. struct respQ {
  195. unsigned int credits; /* credits to be returned to SGE */
  196. unsigned int size; /* # of response Q descriptors */
  197. u16 cidx; /* consumer index (SW) */
  198. u8 genbit; /* current generation(=valid) bit */
  199. struct respQ_e *entries; /* HW response descriptor Q */
  200. dma_addr_t dma_addr; /* DMA addr HW response descriptor Q */
  201. };
  202. /* Bit flags for cmdQ.status */
  203. enum {
  204. CMDQ_STAT_RUNNING = 1, /* fetch engine is running */
  205. CMDQ_STAT_LAST_PKT_DB = 2 /* last packet rung the doorbell */
  206. };
  207. /*
  208. * Main SGE data structure
  209. *
  210. * Interrupts are handled by a single CPU and it is likely that on a MP system
  211. * the application is migrated to another CPU. In that scenario, we try to
  212. * seperate the RX(in irq context) and TX state in order to decrease memory
  213. * contention.
  214. */
  215. struct sge {
  216. struct adapter *adapter; /* adapter backpointer */
  217. struct net_device *netdev; /* netdevice backpointer */
  218. struct freelQ freelQ[SGE_FREELQ_N]; /* buffer free lists */
  219. struct respQ respQ; /* response Q */
  220. unsigned long stopped_tx_queues; /* bitmap of suspended Tx queues */
  221. unsigned int rx_pkt_pad; /* RX padding for L2 packets */
  222. unsigned int jumbo_fl; /* jumbo freelist Q index */
  223. unsigned int intrtimer_nres; /* no-resource interrupt timer */
  224. unsigned int fixed_intrtimer;/* non-adaptive interrupt timer */
  225. struct timer_list tx_reclaim_timer; /* reclaims TX buffers */
  226. struct timer_list espibug_timer;
  227. unsigned int espibug_timeout;
  228. struct sk_buff *espibug_skb;
  229. u32 sge_control; /* shadow value of sge control reg */
  230. struct sge_intr_counts stats;
  231. struct sge_port_stats port_stats[MAX_NPORTS];
  232. struct cmdQ cmdQ[SGE_CMDQ_N] ____cacheline_aligned_in_smp;
  233. };
  234. /*
  235. * PIO to indicate that memory mapped Q contains valid descriptor(s).
  236. */
  237. static inline void doorbell_pio(struct adapter *adapter, u32 val)
  238. {
  239. wmb();
  240. writel(val, adapter->regs + A_SG_DOORBELL);
  241. }
  242. /*
  243. * Frees all RX buffers on the freelist Q. The caller must make sure that
  244. * the SGE is turned off before calling this function.
  245. */
  246. static void free_freelQ_buffers(struct pci_dev *pdev, struct freelQ *q)
  247. {
  248. unsigned int cidx = q->cidx;
  249. while (q->credits--) {
  250. struct freelQ_ce *ce = &q->centries[cidx];
  251. pci_unmap_single(pdev, pci_unmap_addr(ce, dma_addr),
  252. pci_unmap_len(ce, dma_len),
  253. PCI_DMA_FROMDEVICE);
  254. dev_kfree_skb(ce->skb);
  255. ce->skb = NULL;
  256. if (++cidx == q->size)
  257. cidx = 0;
  258. }
  259. }
  260. /*
  261. * Free RX free list and response queue resources.
  262. */
  263. static void free_rx_resources(struct sge *sge)
  264. {
  265. struct pci_dev *pdev = sge->adapter->pdev;
  266. unsigned int size, i;
  267. if (sge->respQ.entries) {
  268. size = sizeof(struct respQ_e) * sge->respQ.size;
  269. pci_free_consistent(pdev, size, sge->respQ.entries,
  270. sge->respQ.dma_addr);
  271. }
  272. for (i = 0; i < SGE_FREELQ_N; i++) {
  273. struct freelQ *q = &sge->freelQ[i];
  274. if (q->centries) {
  275. free_freelQ_buffers(pdev, q);
  276. kfree(q->centries);
  277. }
  278. if (q->entries) {
  279. size = sizeof(struct freelQ_e) * q->size;
  280. pci_free_consistent(pdev, size, q->entries,
  281. q->dma_addr);
  282. }
  283. }
  284. }
  285. /*
  286. * Allocates basic RX resources, consisting of memory mapped freelist Qs and a
  287. * response queue.
  288. */
  289. static int alloc_rx_resources(struct sge *sge, struct sge_params *p)
  290. {
  291. struct pci_dev *pdev = sge->adapter->pdev;
  292. unsigned int size, i;
  293. for (i = 0; i < SGE_FREELQ_N; i++) {
  294. struct freelQ *q = &sge->freelQ[i];
  295. q->genbit = 1;
  296. q->size = p->freelQ_size[i];
  297. q->dma_offset = sge->rx_pkt_pad ? 0 : NET_IP_ALIGN;
  298. size = sizeof(struct freelQ_e) * q->size;
  299. q->entries = (struct freelQ_e *)
  300. pci_alloc_consistent(pdev, size, &q->dma_addr);
  301. if (!q->entries)
  302. goto err_no_mem;
  303. memset(q->entries, 0, size);
  304. size = sizeof(struct freelQ_ce) * q->size;
  305. q->centries = kmalloc(size, GFP_KERNEL);
  306. if (!q->centries)
  307. goto err_no_mem;
  308. memset(q->centries, 0, size);
  309. }
  310. /*
  311. * Calculate the buffer sizes for the two free lists. FL0 accommodates
  312. * regular sized Ethernet frames, FL1 is sized not to exceed 16K,
  313. * including all the sk_buff overhead.
  314. *
  315. * Note: For T2 FL0 and FL1 are reversed.
  316. */
  317. sge->freelQ[!sge->jumbo_fl].rx_buffer_size = SGE_RX_SM_BUF_SIZE +
  318. sizeof(struct cpl_rx_data) +
  319. sge->freelQ[!sge->jumbo_fl].dma_offset;
  320. sge->freelQ[sge->jumbo_fl].rx_buffer_size = (16 * 1024) -
  321. SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
  322. /*
  323. * Setup which skb recycle Q should be used when recycling buffers from
  324. * each free list.
  325. */
  326. sge->freelQ[!sge->jumbo_fl].recycleq_idx = 0;
  327. sge->freelQ[sge->jumbo_fl].recycleq_idx = 1;
  328. sge->respQ.genbit = 1;
  329. sge->respQ.size = SGE_RESPQ_E_N;
  330. sge->respQ.credits = 0;
  331. size = sizeof(struct respQ_e) * sge->respQ.size;
  332. sge->respQ.entries = (struct respQ_e *)
  333. pci_alloc_consistent(pdev, size, &sge->respQ.dma_addr);
  334. if (!sge->respQ.entries)
  335. goto err_no_mem;
  336. memset(sge->respQ.entries, 0, size);
  337. return 0;
  338. err_no_mem:
  339. free_rx_resources(sge);
  340. return -ENOMEM;
  341. }
  342. /*
  343. * Reclaims n TX descriptors and frees the buffers associated with them.
  344. */
  345. static void free_cmdQ_buffers(struct sge *sge, struct cmdQ *q, unsigned int n)
  346. {
  347. struct cmdQ_ce *ce;
  348. struct pci_dev *pdev = sge->adapter->pdev;
  349. unsigned int cidx = q->cidx;
  350. q->in_use -= n;
  351. ce = &q->centries[cidx];
  352. while (n--) {
  353. if (q->sop)
  354. pci_unmap_single(pdev, pci_unmap_addr(ce, dma_addr),
  355. pci_unmap_len(ce, dma_len),
  356. PCI_DMA_TODEVICE);
  357. else
  358. pci_unmap_page(pdev, pci_unmap_addr(ce, dma_addr),
  359. pci_unmap_len(ce, dma_len),
  360. PCI_DMA_TODEVICE);
  361. q->sop = 0;
  362. if (ce->skb) {
  363. dev_kfree_skb(ce->skb);
  364. q->sop = 1;
  365. }
  366. ce++;
  367. if (++cidx == q->size) {
  368. cidx = 0;
  369. ce = q->centries;
  370. }
  371. }
  372. q->cidx = cidx;
  373. }
  374. /*
  375. * Free TX resources.
  376. *
  377. * Assumes that SGE is stopped and all interrupts are disabled.
  378. */
  379. static void free_tx_resources(struct sge *sge)
  380. {
  381. struct pci_dev *pdev = sge->adapter->pdev;
  382. unsigned int size, i;
  383. for (i = 0; i < SGE_CMDQ_N; i++) {
  384. struct cmdQ *q = &sge->cmdQ[i];
  385. if (q->centries) {
  386. if (q->in_use)
  387. free_cmdQ_buffers(sge, q, q->in_use);
  388. kfree(q->centries);
  389. }
  390. if (q->entries) {
  391. size = sizeof(struct cmdQ_e) * q->size;
  392. pci_free_consistent(pdev, size, q->entries,
  393. q->dma_addr);
  394. }
  395. }
  396. }
  397. /*
  398. * Allocates basic TX resources, consisting of memory mapped command Qs.
  399. */
  400. static int alloc_tx_resources(struct sge *sge, struct sge_params *p)
  401. {
  402. struct pci_dev *pdev = sge->adapter->pdev;
  403. unsigned int size, i;
  404. for (i = 0; i < SGE_CMDQ_N; i++) {
  405. struct cmdQ *q = &sge->cmdQ[i];
  406. q->genbit = 1;
  407. q->sop = 1;
  408. q->size = p->cmdQ_size[i];
  409. q->in_use = 0;
  410. q->status = 0;
  411. q->processed = q->cleaned = 0;
  412. q->stop_thres = 0;
  413. spin_lock_init(&q->lock);
  414. size = sizeof(struct cmdQ_e) * q->size;
  415. q->entries = (struct cmdQ_e *)
  416. pci_alloc_consistent(pdev, size, &q->dma_addr);
  417. if (!q->entries)
  418. goto err_no_mem;
  419. memset(q->entries, 0, size);
  420. size = sizeof(struct cmdQ_ce) * q->size;
  421. q->centries = kmalloc(size, GFP_KERNEL);
  422. if (!q->centries)
  423. goto err_no_mem;
  424. memset(q->centries, 0, size);
  425. }
  426. /*
  427. * CommandQ 0 handles Ethernet and TOE packets, while queue 1 is TOE
  428. * only. For queue 0 set the stop threshold so we can handle one more
  429. * packet from each port, plus reserve an additional 24 entries for
  430. * Ethernet packets only. Queue 1 never suspends nor do we reserve
  431. * space for Ethernet packets.
  432. */
  433. sge->cmdQ[0].stop_thres = sge->adapter->params.nports *
  434. (MAX_SKB_FRAGS + 1);
  435. return 0;
  436. err_no_mem:
  437. free_tx_resources(sge);
  438. return -ENOMEM;
  439. }
  440. static inline void setup_ring_params(struct adapter *adapter, u64 addr,
  441. u32 size, int base_reg_lo,
  442. int base_reg_hi, int size_reg)
  443. {
  444. writel((u32)addr, adapter->regs + base_reg_lo);
  445. writel(addr >> 32, adapter->regs + base_reg_hi);
  446. writel(size, adapter->regs + size_reg);
  447. }
  448. /*
  449. * Enable/disable VLAN acceleration.
  450. */
  451. void t1_set_vlan_accel(struct adapter *adapter, int on_off)
  452. {
  453. struct sge *sge = adapter->sge;
  454. sge->sge_control &= ~F_VLAN_XTRACT;
  455. if (on_off)
  456. sge->sge_control |= F_VLAN_XTRACT;
  457. if (adapter->open_device_map) {
  458. writel(sge->sge_control, adapter->regs + A_SG_CONTROL);
  459. readl(adapter->regs + A_SG_CONTROL); /* flush */
  460. }
  461. }
  462. /*
  463. * Programs the various SGE registers. However, the engine is not yet enabled,
  464. * but sge->sge_control is setup and ready to go.
  465. */
  466. static void configure_sge(struct sge *sge, struct sge_params *p)
  467. {
  468. struct adapter *ap = sge->adapter;
  469. writel(0, ap->regs + A_SG_CONTROL);
  470. setup_ring_params(ap, sge->cmdQ[0].dma_addr, sge->cmdQ[0].size,
  471. A_SG_CMD0BASELWR, A_SG_CMD0BASEUPR, A_SG_CMD0SIZE);
  472. setup_ring_params(ap, sge->cmdQ[1].dma_addr, sge->cmdQ[1].size,
  473. A_SG_CMD1BASELWR, A_SG_CMD1BASEUPR, A_SG_CMD1SIZE);
  474. setup_ring_params(ap, sge->freelQ[0].dma_addr,
  475. sge->freelQ[0].size, A_SG_FL0BASELWR,
  476. A_SG_FL0BASEUPR, A_SG_FL0SIZE);
  477. setup_ring_params(ap, sge->freelQ[1].dma_addr,
  478. sge->freelQ[1].size, A_SG_FL1BASELWR,
  479. A_SG_FL1BASEUPR, A_SG_FL1SIZE);
  480. /* The threshold comparison uses <. */
  481. writel(SGE_RX_SM_BUF_SIZE + 1, ap->regs + A_SG_FLTHRESHOLD);
  482. setup_ring_params(ap, sge->respQ.dma_addr, sge->respQ.size,
  483. A_SG_RSPBASELWR, A_SG_RSPBASEUPR, A_SG_RSPSIZE);
  484. writel((u32)sge->respQ.size - 1, ap->regs + A_SG_RSPQUEUECREDIT);
  485. sge->sge_control = F_CMDQ0_ENABLE | F_CMDQ1_ENABLE | F_FL0_ENABLE |
  486. F_FL1_ENABLE | F_CPL_ENABLE | F_RESPONSE_QUEUE_ENABLE |
  487. V_CMDQ_PRIORITY(2) | F_DISABLE_CMDQ1_GTS | F_ISCSI_COALESCE |
  488. F_DISABLE_FL0_GTS | F_DISABLE_FL1_GTS |
  489. V_RX_PKT_OFFSET(sge->rx_pkt_pad);
  490. #if defined(__BIG_ENDIAN_BITFIELD)
  491. sge->sge_control |= F_ENABLE_BIG_ENDIAN;
  492. #endif
  493. /* Initialize no-resource timer */
  494. sge->intrtimer_nres = SGE_INTRTIMER_NRES * core_ticks_per_usec(ap);
  495. t1_sge_set_coalesce_params(sge, p);
  496. }
  497. /*
  498. * Return the payload capacity of the jumbo free-list buffers.
  499. */
  500. static inline unsigned int jumbo_payload_capacity(const struct sge *sge)
  501. {
  502. return sge->freelQ[sge->jumbo_fl].rx_buffer_size -
  503. sge->freelQ[sge->jumbo_fl].dma_offset -
  504. sizeof(struct cpl_rx_data);
  505. }
  506. /*
  507. * Frees all SGE related resources and the sge structure itself
  508. */
  509. void t1_sge_destroy(struct sge *sge)
  510. {
  511. if (sge->espibug_skb)
  512. kfree_skb(sge->espibug_skb);
  513. free_tx_resources(sge);
  514. free_rx_resources(sge);
  515. kfree(sge);
  516. }
  517. /*
  518. * Allocates new RX buffers on the freelist Q (and tracks them on the freelist
  519. * context Q) until the Q is full or alloc_skb fails.
  520. *
  521. * It is possible that the generation bits already match, indicating that the
  522. * buffer is already valid and nothing needs to be done. This happens when we
  523. * copied a received buffer into a new sk_buff during the interrupt processing.
  524. *
  525. * If the SGE doesn't automatically align packets properly (!sge->rx_pkt_pad),
  526. * we specify a RX_OFFSET in order to make sure that the IP header is 4B
  527. * aligned.
  528. */
  529. static void refill_free_list(struct sge *sge, struct freelQ *q)
  530. {
  531. struct pci_dev *pdev = sge->adapter->pdev;
  532. struct freelQ_ce *ce = &q->centries[q->pidx];
  533. struct freelQ_e *e = &q->entries[q->pidx];
  534. unsigned int dma_len = q->rx_buffer_size - q->dma_offset;
  535. while (q->credits < q->size) {
  536. struct sk_buff *skb;
  537. dma_addr_t mapping;
  538. skb = alloc_skb(q->rx_buffer_size, GFP_ATOMIC);
  539. if (!skb)
  540. break;
  541. skb_reserve(skb, q->dma_offset);
  542. mapping = pci_map_single(pdev, skb->data, dma_len,
  543. PCI_DMA_FROMDEVICE);
  544. ce->skb = skb;
  545. pci_unmap_addr_set(ce, dma_addr, mapping);
  546. pci_unmap_len_set(ce, dma_len, dma_len);
  547. e->addr_lo = (u32)mapping;
  548. e->addr_hi = (u64)mapping >> 32;
  549. e->len_gen = V_CMD_LEN(dma_len) | V_CMD_GEN1(q->genbit);
  550. wmb();
  551. e->gen2 = V_CMD_GEN2(q->genbit);
  552. e++;
  553. ce++;
  554. if (++q->pidx == q->size) {
  555. q->pidx = 0;
  556. q->genbit ^= 1;
  557. ce = q->centries;
  558. e = q->entries;
  559. }
  560. q->credits++;
  561. }
  562. }
  563. /*
  564. * Calls refill_free_list for both free lists. If we cannot fill at least 1/4
  565. * of both rings, we go into 'few interrupt mode' in order to give the system
  566. * time to free up resources.
  567. */
  568. static void freelQs_empty(struct sge *sge)
  569. {
  570. struct adapter *adapter = sge->adapter;
  571. u32 irq_reg = readl(adapter->regs + A_SG_INT_ENABLE);
  572. u32 irqholdoff_reg;
  573. refill_free_list(sge, &sge->freelQ[0]);
  574. refill_free_list(sge, &sge->freelQ[1]);
  575. if (sge->freelQ[0].credits > (sge->freelQ[0].size >> 2) &&
  576. sge->freelQ[1].credits > (sge->freelQ[1].size >> 2)) {
  577. irq_reg |= F_FL_EXHAUSTED;
  578. irqholdoff_reg = sge->fixed_intrtimer;
  579. } else {
  580. /* Clear the F_FL_EXHAUSTED interrupts for now */
  581. irq_reg &= ~F_FL_EXHAUSTED;
  582. irqholdoff_reg = sge->intrtimer_nres;
  583. }
  584. writel(irqholdoff_reg, adapter->regs + A_SG_INTRTIMER);
  585. writel(irq_reg, adapter->regs + A_SG_INT_ENABLE);
  586. /* We reenable the Qs to force a freelist GTS interrupt later */
  587. doorbell_pio(adapter, F_FL0_ENABLE | F_FL1_ENABLE);
  588. }
  589. #define SGE_PL_INTR_MASK (F_PL_INTR_SGE_ERR | F_PL_INTR_SGE_DATA)
  590. #define SGE_INT_FATAL (F_RESPQ_OVERFLOW | F_PACKET_TOO_BIG | F_PACKET_MISMATCH)
  591. #define SGE_INT_ENABLE (F_RESPQ_EXHAUSTED | F_RESPQ_OVERFLOW | \
  592. F_FL_EXHAUSTED | F_PACKET_TOO_BIG | F_PACKET_MISMATCH)
  593. /*
  594. * Disable SGE Interrupts
  595. */
  596. void t1_sge_intr_disable(struct sge *sge)
  597. {
  598. u32 val = readl(sge->adapter->regs + A_PL_ENABLE);
  599. writel(val & ~SGE_PL_INTR_MASK, sge->adapter->regs + A_PL_ENABLE);
  600. writel(0, sge->adapter->regs + A_SG_INT_ENABLE);
  601. }
  602. /*
  603. * Enable SGE interrupts.
  604. */
  605. void t1_sge_intr_enable(struct sge *sge)
  606. {
  607. u32 en = SGE_INT_ENABLE;
  608. u32 val = readl(sge->adapter->regs + A_PL_ENABLE);
  609. if (sge->adapter->flags & TSO_CAPABLE)
  610. en &= ~F_PACKET_TOO_BIG;
  611. writel(en, sge->adapter->regs + A_SG_INT_ENABLE);
  612. writel(val | SGE_PL_INTR_MASK, sge->adapter->regs + A_PL_ENABLE);
  613. }
  614. /*
  615. * Clear SGE interrupts.
  616. */
  617. void t1_sge_intr_clear(struct sge *sge)
  618. {
  619. writel(SGE_PL_INTR_MASK, sge->adapter->regs + A_PL_CAUSE);
  620. writel(0xffffffff, sge->adapter->regs + A_SG_INT_CAUSE);
  621. }
  622. /*
  623. * SGE 'Error' interrupt handler
  624. */
  625. int t1_sge_intr_error_handler(struct sge *sge)
  626. {
  627. struct adapter *adapter = sge->adapter;
  628. u32 cause = readl(adapter->regs + A_SG_INT_CAUSE);
  629. if (adapter->flags & TSO_CAPABLE)
  630. cause &= ~F_PACKET_TOO_BIG;
  631. if (cause & F_RESPQ_EXHAUSTED)
  632. sge->stats.respQ_empty++;
  633. if (cause & F_RESPQ_OVERFLOW) {
  634. sge->stats.respQ_overflow++;
  635. CH_ALERT("%s: SGE response queue overflow\n",
  636. adapter->name);
  637. }
  638. if (cause & F_FL_EXHAUSTED) {
  639. sge->stats.freelistQ_empty++;
  640. freelQs_empty(sge);
  641. }
  642. if (cause & F_PACKET_TOO_BIG) {
  643. sge->stats.pkt_too_big++;
  644. CH_ALERT("%s: SGE max packet size exceeded\n",
  645. adapter->name);
  646. }
  647. if (cause & F_PACKET_MISMATCH) {
  648. sge->stats.pkt_mismatch++;
  649. CH_ALERT("%s: SGE packet mismatch\n", adapter->name);
  650. }
  651. if (cause & SGE_INT_FATAL)
  652. t1_fatal_err(adapter);
  653. writel(cause, adapter->regs + A_SG_INT_CAUSE);
  654. return 0;
  655. }
  656. const struct sge_intr_counts *t1_sge_get_intr_counts(struct sge *sge)
  657. {
  658. return &sge->stats;
  659. }
  660. const struct sge_port_stats *t1_sge_get_port_stats(struct sge *sge, int port)
  661. {
  662. return &sge->port_stats[port];
  663. }
  664. /**
  665. * recycle_fl_buf - recycle a free list buffer
  666. * @fl: the free list
  667. * @idx: index of buffer to recycle
  668. *
  669. * Recycles the specified buffer on the given free list by adding it at
  670. * the next available slot on the list.
  671. */
  672. static void recycle_fl_buf(struct freelQ *fl, int idx)
  673. {
  674. struct freelQ_e *from = &fl->entries[idx];
  675. struct freelQ_e *to = &fl->entries[fl->pidx];
  676. fl->centries[fl->pidx] = fl->centries[idx];
  677. to->addr_lo = from->addr_lo;
  678. to->addr_hi = from->addr_hi;
  679. to->len_gen = G_CMD_LEN(from->len_gen) | V_CMD_GEN1(fl->genbit);
  680. wmb();
  681. to->gen2 = V_CMD_GEN2(fl->genbit);
  682. fl->credits++;
  683. if (++fl->pidx == fl->size) {
  684. fl->pidx = 0;
  685. fl->genbit ^= 1;
  686. }
  687. }
  688. /**
  689. * get_packet - return the next ingress packet buffer
  690. * @pdev: the PCI device that received the packet
  691. * @fl: the SGE free list holding the packet
  692. * @len: the actual packet length, excluding any SGE padding
  693. * @dma_pad: padding at beginning of buffer left by SGE DMA
  694. * @skb_pad: padding to be used if the packet is copied
  695. * @copy_thres: length threshold under which a packet should be copied
  696. * @drop_thres: # of remaining buffers before we start dropping packets
  697. *
  698. * Get the next packet from a free list and complete setup of the
  699. * sk_buff. If the packet is small we make a copy and recycle the
  700. * original buffer, otherwise we use the original buffer itself. If a
  701. * positive drop threshold is supplied packets are dropped and their
  702. * buffers recycled if (a) the number of remaining buffers is under the
  703. * threshold and the packet is too big to copy, or (b) the packet should
  704. * be copied but there is no memory for the copy.
  705. */
  706. static inline struct sk_buff *get_packet(struct pci_dev *pdev,
  707. struct freelQ *fl, unsigned int len,
  708. int dma_pad, int skb_pad,
  709. unsigned int copy_thres,
  710. unsigned int drop_thres)
  711. {
  712. struct sk_buff *skb;
  713. struct freelQ_ce *ce = &fl->centries[fl->cidx];
  714. if (len < copy_thres) {
  715. skb = alloc_skb(len + skb_pad, GFP_ATOMIC);
  716. if (likely(skb != NULL)) {
  717. skb_reserve(skb, skb_pad);
  718. skb_put(skb, len);
  719. pci_dma_sync_single_for_cpu(pdev,
  720. pci_unmap_addr(ce, dma_addr),
  721. pci_unmap_len(ce, dma_len),
  722. PCI_DMA_FROMDEVICE);
  723. memcpy(skb->data, ce->skb->data + dma_pad, len);
  724. pci_dma_sync_single_for_device(pdev,
  725. pci_unmap_addr(ce, dma_addr),
  726. pci_unmap_len(ce, dma_len),
  727. PCI_DMA_FROMDEVICE);
  728. } else if (!drop_thres)
  729. goto use_orig_buf;
  730. recycle_fl_buf(fl, fl->cidx);
  731. return skb;
  732. }
  733. if (fl->credits < drop_thres) {
  734. recycle_fl_buf(fl, fl->cidx);
  735. return NULL;
  736. }
  737. use_orig_buf:
  738. pci_unmap_single(pdev, pci_unmap_addr(ce, dma_addr),
  739. pci_unmap_len(ce, dma_len), PCI_DMA_FROMDEVICE);
  740. skb = ce->skb;
  741. skb_reserve(skb, dma_pad);
  742. skb_put(skb, len);
  743. return skb;
  744. }
  745. /**
  746. * unexpected_offload - handle an unexpected offload packet
  747. * @adapter: the adapter
  748. * @fl: the free list that received the packet
  749. *
  750. * Called when we receive an unexpected offload packet (e.g., the TOE
  751. * function is disabled or the card is a NIC). Prints a message and
  752. * recycles the buffer.
  753. */
  754. static void unexpected_offload(struct adapter *adapter, struct freelQ *fl)
  755. {
  756. struct freelQ_ce *ce = &fl->centries[fl->cidx];
  757. struct sk_buff *skb = ce->skb;
  758. pci_dma_sync_single_for_cpu(adapter->pdev, pci_unmap_addr(ce, dma_addr),
  759. pci_unmap_len(ce, dma_len), PCI_DMA_FROMDEVICE);
  760. CH_ERR("%s: unexpected offload packet, cmd %u\n",
  761. adapter->name, *skb->data);
  762. recycle_fl_buf(fl, fl->cidx);
  763. }
  764. /*
  765. * Write the command descriptors to transmit the given skb starting at
  766. * descriptor pidx with the given generation.
  767. */
  768. static inline void write_tx_descs(struct adapter *adapter, struct sk_buff *skb,
  769. unsigned int pidx, unsigned int gen,
  770. struct cmdQ *q)
  771. {
  772. dma_addr_t mapping;
  773. struct cmdQ_e *e, *e1;
  774. struct cmdQ_ce *ce;
  775. unsigned int i, flags, nfrags = skb_shinfo(skb)->nr_frags;
  776. mapping = pci_map_single(adapter->pdev, skb->data,
  777. skb->len - skb->data_len, PCI_DMA_TODEVICE);
  778. ce = &q->centries[pidx];
  779. ce->skb = NULL;
  780. pci_unmap_addr_set(ce, dma_addr, mapping);
  781. pci_unmap_len_set(ce, dma_len, skb->len - skb->data_len);
  782. flags = F_CMD_DATAVALID | F_CMD_SOP | V_CMD_EOP(nfrags == 0) |
  783. V_CMD_GEN2(gen);
  784. e = &q->entries[pidx];
  785. e->addr_lo = (u32)mapping;
  786. e->addr_hi = (u64)mapping >> 32;
  787. e->len_gen = V_CMD_LEN(skb->len - skb->data_len) | V_CMD_GEN1(gen);
  788. for (e1 = e, i = 0; nfrags--; i++) {
  789. skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
  790. ce++;
  791. e1++;
  792. if (++pidx == q->size) {
  793. pidx = 0;
  794. gen ^= 1;
  795. ce = q->centries;
  796. e1 = q->entries;
  797. }
  798. mapping = pci_map_page(adapter->pdev, frag->page,
  799. frag->page_offset, frag->size,
  800. PCI_DMA_TODEVICE);
  801. ce->skb = NULL;
  802. pci_unmap_addr_set(ce, dma_addr, mapping);
  803. pci_unmap_len_set(ce, dma_len, frag->size);
  804. e1->addr_lo = (u32)mapping;
  805. e1->addr_hi = (u64)mapping >> 32;
  806. e1->len_gen = V_CMD_LEN(frag->size) | V_CMD_GEN1(gen);
  807. e1->flags = F_CMD_DATAVALID | V_CMD_EOP(nfrags == 0) |
  808. V_CMD_GEN2(gen);
  809. }
  810. ce->skb = skb;
  811. wmb();
  812. e->flags = flags;
  813. }
  814. /*
  815. * Clean up completed Tx buffers.
  816. */
  817. static inline void reclaim_completed_tx(struct sge *sge, struct cmdQ *q)
  818. {
  819. unsigned int reclaim = q->processed - q->cleaned;
  820. if (reclaim) {
  821. free_cmdQ_buffers(sge, q, reclaim);
  822. q->cleaned += reclaim;
  823. }
  824. }
  825. #ifndef SET_ETHTOOL_OPS
  826. # define __netif_rx_complete(dev) netif_rx_complete(dev)
  827. #endif
  828. /*
  829. * We cannot use the standard netif_rx_schedule_prep() because we have multiple
  830. * ports plus the TOE all multiplexing onto a single response queue, therefore
  831. * accepting new responses cannot depend on the state of any particular port.
  832. * So define our own equivalent that omits the netif_running() test.
  833. */
  834. static inline int napi_schedule_prep(struct net_device *dev)
  835. {
  836. return !test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state);
  837. }
  838. /**
  839. * sge_rx - process an ingress ethernet packet
  840. * @sge: the sge structure
  841. * @fl: the free list that contains the packet buffer
  842. * @len: the packet length
  843. *
  844. * Process an ingress ethernet pakcet and deliver it to the stack.
  845. */
  846. static int sge_rx(struct sge *sge, struct freelQ *fl, unsigned int len)
  847. {
  848. struct sk_buff *skb;
  849. struct cpl_rx_pkt *p;
  850. struct adapter *adapter = sge->adapter;
  851. sge->stats.ethernet_pkts++;
  852. skb = get_packet(adapter->pdev, fl, len - sge->rx_pkt_pad,
  853. sge->rx_pkt_pad, 2, SGE_RX_COPY_THRES,
  854. SGE_RX_DROP_THRES);
  855. if (!skb) {
  856. sge->port_stats[0].rx_drops++; /* charge only port 0 for now */
  857. return 0;
  858. }
  859. p = (struct cpl_rx_pkt *)skb->data;
  860. skb_pull(skb, sizeof(*p));
  861. skb->dev = adapter->port[p->iff].dev;
  862. skb->dev->last_rx = jiffies;
  863. skb->protocol = eth_type_trans(skb, skb->dev);
  864. if ((adapter->flags & RX_CSUM_ENABLED) && p->csum == 0xffff &&
  865. skb->protocol == htons(ETH_P_IP) &&
  866. (skb->data[9] == IPPROTO_TCP || skb->data[9] == IPPROTO_UDP)) {
  867. sge->port_stats[p->iff].rx_cso_good++;
  868. skb->ip_summed = CHECKSUM_UNNECESSARY;
  869. } else
  870. skb->ip_summed = CHECKSUM_NONE;
  871. if (unlikely(adapter->vlan_grp && p->vlan_valid)) {
  872. sge->port_stats[p->iff].vlan_xtract++;
  873. if (adapter->params.sge.polling)
  874. vlan_hwaccel_receive_skb(skb, adapter->vlan_grp,
  875. ntohs(p->vlan));
  876. else
  877. vlan_hwaccel_rx(skb, adapter->vlan_grp,
  878. ntohs(p->vlan));
  879. } else if (adapter->params.sge.polling)
  880. netif_receive_skb(skb);
  881. else
  882. netif_rx(skb);
  883. return 0;
  884. }
  885. /*
  886. * Returns true if a command queue has enough available descriptors that
  887. * we can resume Tx operation after temporarily disabling its packet queue.
  888. */
  889. static inline int enough_free_Tx_descs(const struct cmdQ *q)
  890. {
  891. unsigned int r = q->processed - q->cleaned;
  892. return q->in_use - r < (q->size >> 1);
  893. }
  894. /*
  895. * Called when sufficient space has become available in the SGE command queues
  896. * after the Tx packet schedulers have been suspended to restart the Tx path.
  897. */
  898. static void restart_tx_queues(struct sge *sge)
  899. {
  900. struct adapter *adap = sge->adapter;
  901. if (enough_free_Tx_descs(&sge->cmdQ[0])) {
  902. int i;
  903. for_each_port(adap, i) {
  904. struct net_device *nd = adap->port[i].dev;
  905. if (test_and_clear_bit(nd->if_port,
  906. &sge->stopped_tx_queues) &&
  907. netif_running(nd)) {
  908. sge->stats.cmdQ_restarted[3]++;
  909. netif_wake_queue(nd);
  910. }
  911. }
  912. }
  913. }
  914. /*
  915. * update_tx_info is called from the interrupt handler/NAPI to return cmdQ0
  916. * information.
  917. */
  918. static unsigned int update_tx_info(struct adapter *adapter,
  919. unsigned int flags,
  920. unsigned int pr0)
  921. {
  922. struct sge *sge = adapter->sge;
  923. struct cmdQ *cmdq = &sge->cmdQ[0];
  924. cmdq->processed += pr0;
  925. if (flags & F_CMDQ0_ENABLE) {
  926. clear_bit(CMDQ_STAT_RUNNING, &cmdq->status);
  927. if (cmdq->cleaned + cmdq->in_use != cmdq->processed &&
  928. !test_and_set_bit(CMDQ_STAT_LAST_PKT_DB, &cmdq->status)) {
  929. set_bit(CMDQ_STAT_RUNNING, &cmdq->status);
  930. writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
  931. }
  932. flags &= ~F_CMDQ0_ENABLE;
  933. }
  934. if (unlikely(sge->stopped_tx_queues != 0))
  935. restart_tx_queues(sge);
  936. return flags;
  937. }
  938. /*
  939. * Process SGE responses, up to the supplied budget. Returns the number of
  940. * responses processed. A negative budget is effectively unlimited.
  941. */
  942. static int process_responses(struct adapter *adapter, int budget)
  943. {
  944. struct sge *sge = adapter->sge;
  945. struct respQ *q = &sge->respQ;
  946. struct respQ_e *e = &q->entries[q->cidx];
  947. int budget_left = budget;
  948. unsigned int flags = 0;
  949. unsigned int cmdq_processed[SGE_CMDQ_N] = {0, 0};
  950. while (likely(budget_left && e->GenerationBit == q->genbit)) {
  951. flags |= e->Qsleeping;
  952. cmdq_processed[0] += e->Cmdq0CreditReturn;
  953. cmdq_processed[1] += e->Cmdq1CreditReturn;
  954. /* We batch updates to the TX side to avoid cacheline
  955. * ping-pong of TX state information on MP where the sender
  956. * might run on a different CPU than this function...
  957. */
  958. if (unlikely(flags & F_CMDQ0_ENABLE || cmdq_processed[0] > 64)) {
  959. flags = update_tx_info(adapter, flags, cmdq_processed[0]);
  960. cmdq_processed[0] = 0;
  961. }
  962. if (unlikely(cmdq_processed[1] > 16)) {
  963. sge->cmdQ[1].processed += cmdq_processed[1];
  964. cmdq_processed[1] = 0;
  965. }
  966. if (likely(e->DataValid)) {
  967. struct freelQ *fl = &sge->freelQ[e->FreelistQid];
  968. if (unlikely(!e->Sop || !e->Eop))
  969. BUG();
  970. if (unlikely(e->Offload))
  971. unexpected_offload(adapter, fl);
  972. else
  973. sge_rx(sge, fl, e->BufferLength);
  974. /*
  975. * Note: this depends on each packet consuming a
  976. * single free-list buffer; cf. the BUG above.
  977. */
  978. if (++fl->cidx == fl->size)
  979. fl->cidx = 0;
  980. if (unlikely(--fl->credits <
  981. fl->size - SGE_FREEL_REFILL_THRESH))
  982. refill_free_list(sge, fl);
  983. } else
  984. sge->stats.pure_rsps++;
  985. e++;
  986. if (unlikely(++q->cidx == q->size)) {
  987. q->cidx = 0;
  988. q->genbit ^= 1;
  989. e = q->entries;
  990. }
  991. prefetch(e);
  992. if (++q->credits > SGE_RESPQ_REPLENISH_THRES) {
  993. writel(q->credits, adapter->regs + A_SG_RSPQUEUECREDIT);
  994. q->credits = 0;
  995. }
  996. --budget_left;
  997. }
  998. flags = update_tx_info(adapter, flags, cmdq_processed[0]);
  999. sge->cmdQ[1].processed += cmdq_processed[1];
  1000. budget -= budget_left;
  1001. return budget;
  1002. }
  1003. /*
  1004. * A simpler version of process_responses() that handles only pure (i.e.,
  1005. * non data-carrying) responses. Such respones are too light-weight to justify
  1006. * calling a softirq when using NAPI, so we handle them specially in hard
  1007. * interrupt context. The function is called with a pointer to a response,
  1008. * which the caller must ensure is a valid pure response. Returns 1 if it
  1009. * encounters a valid data-carrying response, 0 otherwise.
  1010. */
  1011. static int process_pure_responses(struct adapter *adapter, struct respQ_e *e)
  1012. {
  1013. struct sge *sge = adapter->sge;
  1014. struct respQ *q = &sge->respQ;
  1015. unsigned int flags = 0;
  1016. unsigned int cmdq_processed[SGE_CMDQ_N] = {0, 0};
  1017. do {
  1018. flags |= e->Qsleeping;
  1019. cmdq_processed[0] += e->Cmdq0CreditReturn;
  1020. cmdq_processed[1] += e->Cmdq1CreditReturn;
  1021. e++;
  1022. if (unlikely(++q->cidx == q->size)) {
  1023. q->cidx = 0;
  1024. q->genbit ^= 1;
  1025. e = q->entries;
  1026. }
  1027. prefetch(e);
  1028. if (++q->credits > SGE_RESPQ_REPLENISH_THRES) {
  1029. writel(q->credits, adapter->regs + A_SG_RSPQUEUECREDIT);
  1030. q->credits = 0;
  1031. }
  1032. sge->stats.pure_rsps++;
  1033. } while (e->GenerationBit == q->genbit && !e->DataValid);
  1034. flags = update_tx_info(adapter, flags, cmdq_processed[0]);
  1035. sge->cmdQ[1].processed += cmdq_processed[1];
  1036. return e->GenerationBit == q->genbit;
  1037. }
  1038. /*
  1039. * Handler for new data events when using NAPI. This does not need any locking
  1040. * or protection from interrupts as data interrupts are off at this point and
  1041. * other adapter interrupts do not interfere.
  1042. */
  1043. static int t1_poll(struct net_device *dev, int *budget)
  1044. {
  1045. struct adapter *adapter = dev->priv;
  1046. int effective_budget = min(*budget, dev->quota);
  1047. int work_done = process_responses(adapter, effective_budget);
  1048. *budget -= work_done;
  1049. dev->quota -= work_done;
  1050. if (work_done >= effective_budget)
  1051. return 1;
  1052. __netif_rx_complete(dev);
  1053. /*
  1054. * Because we don't atomically flush the following write it is
  1055. * possible that in very rare cases it can reach the device in a way
  1056. * that races with a new response being written plus an error interrupt
  1057. * causing the NAPI interrupt handler below to return unhandled status
  1058. * to the OS. To protect against this would require flushing the write
  1059. * and doing both the write and the flush with interrupts off. Way too
  1060. * expensive and unjustifiable given the rarity of the race.
  1061. */
  1062. writel(adapter->sge->respQ.cidx, adapter->regs + A_SG_SLEEPING);
  1063. return 0;
  1064. }
  1065. /*
  1066. * Returns true if the device is already scheduled for polling.
  1067. */
  1068. static inline int napi_is_scheduled(struct net_device *dev)
  1069. {
  1070. return test_bit(__LINK_STATE_RX_SCHED, &dev->state);
  1071. }
  1072. /*
  1073. * NAPI version of the main interrupt handler.
  1074. */
  1075. static irqreturn_t t1_interrupt_napi(int irq, void *data, struct pt_regs *regs)
  1076. {
  1077. int handled;
  1078. struct adapter *adapter = data;
  1079. struct sge *sge = adapter->sge;
  1080. struct respQ *q = &adapter->sge->respQ;
  1081. /*
  1082. * Clear the SGE_DATA interrupt first thing. Normally the NAPI
  1083. * handler has control of the response queue and the interrupt handler
  1084. * can look at the queue reliably only once it knows NAPI is off.
  1085. * We can't wait that long to clear the SGE_DATA interrupt because we
  1086. * could race with t1_poll rearming the SGE interrupt, so we need to
  1087. * clear the interrupt speculatively and really early on.
  1088. */
  1089. writel(F_PL_INTR_SGE_DATA, adapter->regs + A_PL_CAUSE);
  1090. spin_lock(&adapter->async_lock);
  1091. if (!napi_is_scheduled(sge->netdev)) {
  1092. struct respQ_e *e = &q->entries[q->cidx];
  1093. if (e->GenerationBit == q->genbit) {
  1094. if (e->DataValid ||
  1095. process_pure_responses(adapter, e)) {
  1096. if (likely(napi_schedule_prep(sge->netdev)))
  1097. __netif_rx_schedule(sge->netdev);
  1098. else
  1099. printk(KERN_CRIT
  1100. "NAPI schedule failure!\n");
  1101. } else
  1102. writel(q->cidx, adapter->regs + A_SG_SLEEPING);
  1103. handled = 1;
  1104. goto unlock;
  1105. } else
  1106. writel(q->cidx, adapter->regs + A_SG_SLEEPING);
  1107. } else
  1108. if (readl(adapter->regs + A_PL_CAUSE) & F_PL_INTR_SGE_DATA)
  1109. printk(KERN_ERR "data interrupt while NAPI running\n");
  1110. handled = t1_slow_intr_handler(adapter);
  1111. if (!handled)
  1112. sge->stats.unhandled_irqs++;
  1113. unlock:
  1114. spin_unlock(&adapter->async_lock);
  1115. return IRQ_RETVAL(handled != 0);
  1116. }
  1117. /*
  1118. * Main interrupt handler, optimized assuming that we took a 'DATA'
  1119. * interrupt.
  1120. *
  1121. * 1. Clear the interrupt
  1122. * 2. Loop while we find valid descriptors and process them; accumulate
  1123. * information that can be processed after the loop
  1124. * 3. Tell the SGE at which index we stopped processing descriptors
  1125. * 4. Bookkeeping; free TX buffers, ring doorbell if there are any
  1126. * outstanding TX buffers waiting, replenish RX buffers, potentially
  1127. * reenable upper layers if they were turned off due to lack of TX
  1128. * resources which are available again.
  1129. * 5. If we took an interrupt, but no valid respQ descriptors was found we
  1130. * let the slow_intr_handler run and do error handling.
  1131. */
  1132. static irqreturn_t t1_interrupt(int irq, void *cookie, struct pt_regs *regs)
  1133. {
  1134. int work_done;
  1135. struct respQ_e *e;
  1136. struct adapter *adapter = cookie;
  1137. struct respQ *Q = &adapter->sge->respQ;
  1138. spin_lock(&adapter->async_lock);
  1139. e = &Q->entries[Q->cidx];
  1140. prefetch(e);
  1141. writel(F_PL_INTR_SGE_DATA, adapter->regs + A_PL_CAUSE);
  1142. if (likely(e->GenerationBit == Q->genbit))
  1143. work_done = process_responses(adapter, -1);
  1144. else
  1145. work_done = t1_slow_intr_handler(adapter);
  1146. /*
  1147. * The unconditional clearing of the PL_CAUSE above may have raced
  1148. * with DMA completion and the corresponding generation of a response
  1149. * to cause us to miss the resulting data interrupt. The next write
  1150. * is also unconditional to recover the missed interrupt and render
  1151. * this race harmless.
  1152. */
  1153. writel(Q->cidx, adapter->regs + A_SG_SLEEPING);
  1154. if (!work_done)
  1155. adapter->sge->stats.unhandled_irqs++;
  1156. spin_unlock(&adapter->async_lock);
  1157. return IRQ_RETVAL(work_done != 0);
  1158. }
  1159. intr_handler_t t1_select_intr_handler(adapter_t *adapter)
  1160. {
  1161. return adapter->params.sge.polling ? t1_interrupt_napi : t1_interrupt;
  1162. }
  1163. /*
  1164. * Enqueues the sk_buff onto the cmdQ[qid] and has hardware fetch it.
  1165. *
  1166. * The code figures out how many entries the sk_buff will require in the
  1167. * cmdQ and updates the cmdQ data structure with the state once the enqueue
  1168. * has complete. Then, it doesn't access the global structure anymore, but
  1169. * uses the corresponding fields on the stack. In conjuction with a spinlock
  1170. * around that code, we can make the function reentrant without holding the
  1171. * lock when we actually enqueue (which might be expensive, especially on
  1172. * architectures with IO MMUs).
  1173. *
  1174. * This runs with softirqs disabled.
  1175. */
  1176. static int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
  1177. unsigned int qid, struct net_device *dev)
  1178. {
  1179. struct sge *sge = adapter->sge;
  1180. struct cmdQ *q = &sge->cmdQ[qid];
  1181. unsigned int credits, pidx, genbit, count;
  1182. spin_lock(&q->lock);
  1183. reclaim_completed_tx(sge, q);
  1184. pidx = q->pidx;
  1185. credits = q->size - q->in_use;
  1186. count = 1 + skb_shinfo(skb)->nr_frags;
  1187. { /* Ethernet packet */
  1188. if (unlikely(credits < count)) {
  1189. netif_stop_queue(dev);
  1190. set_bit(dev->if_port, &sge->stopped_tx_queues);
  1191. sge->stats.cmdQ_full[3]++;
  1192. spin_unlock(&q->lock);
  1193. if (!netif_queue_stopped(dev))
  1194. CH_ERR("%s: Tx ring full while queue awake!\n",
  1195. adapter->name);
  1196. return NETDEV_TX_BUSY;
  1197. }
  1198. if (unlikely(credits - count < q->stop_thres)) {
  1199. sge->stats.cmdQ_full[3]++;
  1200. netif_stop_queue(dev);
  1201. set_bit(dev->if_port, &sge->stopped_tx_queues);
  1202. }
  1203. }
  1204. q->in_use += count;
  1205. genbit = q->genbit;
  1206. q->pidx += count;
  1207. if (q->pidx >= q->size) {
  1208. q->pidx -= q->size;
  1209. q->genbit ^= 1;
  1210. }
  1211. spin_unlock(&q->lock);
  1212. write_tx_descs(adapter, skb, pidx, genbit, q);
  1213. /*
  1214. * We always ring the doorbell for cmdQ1. For cmdQ0, we only ring
  1215. * the doorbell if the Q is asleep. There is a natural race, where
  1216. * the hardware is going to sleep just after we checked, however,
  1217. * then the interrupt handler will detect the outstanding TX packet
  1218. * and ring the doorbell for us.
  1219. */
  1220. if (qid)
  1221. doorbell_pio(adapter, F_CMDQ1_ENABLE);
  1222. else {
  1223. clear_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
  1224. if (test_and_set_bit(CMDQ_STAT_RUNNING, &q->status) == 0) {
  1225. set_bit(CMDQ_STAT_LAST_PKT_DB, &q->status);
  1226. writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
  1227. }
  1228. }
  1229. return NETDEV_TX_OK;
  1230. }
  1231. #define MK_ETH_TYPE_MSS(type, mss) (((mss) & 0x3FFF) | ((type) << 14))
  1232. /*
  1233. * eth_hdr_len - return the length of an Ethernet header
  1234. * @data: pointer to the start of the Ethernet header
  1235. *
  1236. * Returns the length of an Ethernet header, including optional VLAN tag.
  1237. */
  1238. static inline int eth_hdr_len(const void *data)
  1239. {
  1240. const struct ethhdr *e = data;
  1241. return e->h_proto == htons(ETH_P_8021Q) ? VLAN_ETH_HLEN : ETH_HLEN;
  1242. }
  1243. /*
  1244. * Adds the CPL header to the sk_buff and passes it to t1_sge_tx.
  1245. */
  1246. int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
  1247. {
  1248. struct adapter *adapter = dev->priv;
  1249. struct sge_port_stats *st = &adapter->sge->port_stats[dev->if_port];
  1250. struct sge *sge = adapter->sge;
  1251. struct cpl_tx_pkt *cpl;
  1252. #ifdef NETIF_F_TSO
  1253. if (skb_shinfo(skb)->tso_size) {
  1254. int eth_type;
  1255. struct cpl_tx_pkt_lso *hdr;
  1256. st->tso++;
  1257. eth_type = skb->nh.raw - skb->data == ETH_HLEN ?
  1258. CPL_ETH_II : CPL_ETH_II_VLAN;
  1259. hdr = (struct cpl_tx_pkt_lso *)skb_push(skb, sizeof(*hdr));
  1260. hdr->opcode = CPL_TX_PKT_LSO;
  1261. hdr->ip_csum_dis = hdr->l4_csum_dis = 0;
  1262. hdr->ip_hdr_words = skb->nh.iph->ihl;
  1263. hdr->tcp_hdr_words = skb->h.th->doff;
  1264. hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
  1265. skb_shinfo(skb)->tso_size));
  1266. hdr->len = htonl(skb->len - sizeof(*hdr));
  1267. cpl = (struct cpl_tx_pkt *)hdr;
  1268. sge->stats.tx_lso_pkts++;
  1269. } else
  1270. #endif
  1271. {
  1272. /*
  1273. * Packets shorter than ETH_HLEN can break the MAC, drop them
  1274. * early. Also, we may get oversized packets because some
  1275. * parts of the kernel don't handle our unusual hard_header_len
  1276. * right, drop those too.
  1277. */
  1278. if (unlikely(skb->len < ETH_HLEN ||
  1279. skb->len > dev->mtu + eth_hdr_len(skb->data))) {
  1280. dev_kfree_skb_any(skb);
  1281. return NETDEV_TX_OK;
  1282. }
  1283. /*
  1284. * We are using a non-standard hard_header_len and some kernel
  1285. * components, such as pktgen, do not handle it right.
  1286. * Complain when this happens but try to fix things up.
  1287. */
  1288. if (unlikely(skb_headroom(skb) <
  1289. dev->hard_header_len - ETH_HLEN)) {
  1290. struct sk_buff *orig_skb = skb;
  1291. if (net_ratelimit())
  1292. printk(KERN_ERR "%s: inadequate headroom in "
  1293. "Tx packet\n", dev->name);
  1294. skb = skb_realloc_headroom(skb, sizeof(*cpl));
  1295. dev_kfree_skb_any(orig_skb);
  1296. if (!skb)
  1297. return NETDEV_TX_OK;
  1298. }
  1299. if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
  1300. skb->ip_summed == CHECKSUM_HW &&
  1301. skb->nh.iph->protocol == IPPROTO_UDP)
  1302. if (unlikely(skb_checksum_help(skb, 0))) {
  1303. dev_kfree_skb_any(skb);
  1304. return NETDEV_TX_OK;
  1305. }
  1306. /* Hmmm, assuming to catch the gratious arp... and we'll use
  1307. * it to flush out stuck espi packets...
  1308. */
  1309. if (unlikely(!adapter->sge->espibug_skb)) {
  1310. if (skb->protocol == htons(ETH_P_ARP) &&
  1311. skb->nh.arph->ar_op == htons(ARPOP_REQUEST)) {
  1312. adapter->sge->espibug_skb = skb;
  1313. /* We want to re-use this skb later. We
  1314. * simply bump the reference count and it
  1315. * will not be freed...
  1316. */
  1317. skb = skb_get(skb);
  1318. }
  1319. }
  1320. cpl = (struct cpl_tx_pkt *)__skb_push(skb, sizeof(*cpl));
  1321. cpl->opcode = CPL_TX_PKT;
  1322. cpl->ip_csum_dis = 1; /* SW calculates IP csum */
  1323. cpl->l4_csum_dis = skb->ip_summed == CHECKSUM_HW ? 0 : 1;
  1324. /* the length field isn't used so don't bother setting it */
  1325. st->tx_cso += (skb->ip_summed == CHECKSUM_HW);
  1326. sge->stats.tx_do_cksum += (skb->ip_summed == CHECKSUM_HW);
  1327. sge->stats.tx_reg_pkts++;
  1328. }
  1329. cpl->iff = dev->if_port;
  1330. #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
  1331. if (adapter->vlan_grp && vlan_tx_tag_present(skb)) {
  1332. cpl->vlan_valid = 1;
  1333. cpl->vlan = htons(vlan_tx_tag_get(skb));
  1334. st->vlan_insert++;
  1335. } else
  1336. #endif
  1337. cpl->vlan_valid = 0;
  1338. dev->trans_start = jiffies;
  1339. return t1_sge_tx(skb, adapter, 0, dev);
  1340. }
  1341. /*
  1342. * Callback for the Tx buffer reclaim timer. Runs with softirqs disabled.
  1343. */
  1344. static void sge_tx_reclaim_cb(unsigned long data)
  1345. {
  1346. int i;
  1347. struct sge *sge = (struct sge *)data;
  1348. for (i = 0; i < SGE_CMDQ_N; ++i) {
  1349. struct cmdQ *q = &sge->cmdQ[i];
  1350. if (!spin_trylock(&q->lock))
  1351. continue;
  1352. reclaim_completed_tx(sge, q);
  1353. if (i == 0 && q->in_use) /* flush pending credits */
  1354. writel(F_CMDQ0_ENABLE,
  1355. sge->adapter->regs + A_SG_DOORBELL);
  1356. spin_unlock(&q->lock);
  1357. }
  1358. mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
  1359. }
  1360. /*
  1361. * Propagate changes of the SGE coalescing parameters to the HW.
  1362. */
  1363. int t1_sge_set_coalesce_params(struct sge *sge, struct sge_params *p)
  1364. {
  1365. sge->netdev->poll = t1_poll;
  1366. sge->fixed_intrtimer = p->rx_coalesce_usecs *
  1367. core_ticks_per_usec(sge->adapter);
  1368. writel(sge->fixed_intrtimer, sge->adapter->regs + A_SG_INTRTIMER);
  1369. return 0;
  1370. }
  1371. /*
  1372. * Allocates both RX and TX resources and configures the SGE. However,
  1373. * the hardware is not enabled yet.
  1374. */
  1375. int t1_sge_configure(struct sge *sge, struct sge_params *p)
  1376. {
  1377. if (alloc_rx_resources(sge, p))
  1378. return -ENOMEM;
  1379. if (alloc_tx_resources(sge, p)) {
  1380. free_rx_resources(sge);
  1381. return -ENOMEM;
  1382. }
  1383. configure_sge(sge, p);
  1384. /*
  1385. * Now that we have sized the free lists calculate the payload
  1386. * capacity of the large buffers. Other parts of the driver use
  1387. * this to set the max offload coalescing size so that RX packets
  1388. * do not overflow our large buffers.
  1389. */
  1390. p->large_buf_capacity = jumbo_payload_capacity(sge);
  1391. return 0;
  1392. }
  1393. /*
  1394. * Disables the DMA engine.
  1395. */
  1396. void t1_sge_stop(struct sge *sge)
  1397. {
  1398. writel(0, sge->adapter->regs + A_SG_CONTROL);
  1399. (void) readl(sge->adapter->regs + A_SG_CONTROL); /* flush */
  1400. if (is_T2(sge->adapter))
  1401. del_timer_sync(&sge->espibug_timer);
  1402. del_timer_sync(&sge->tx_reclaim_timer);
  1403. }
  1404. /*
  1405. * Enables the DMA engine.
  1406. */
  1407. void t1_sge_start(struct sge *sge)
  1408. {
  1409. refill_free_list(sge, &sge->freelQ[0]);
  1410. refill_free_list(sge, &sge->freelQ[1]);
  1411. writel(sge->sge_control, sge->adapter->regs + A_SG_CONTROL);
  1412. doorbell_pio(sge->adapter, F_FL0_ENABLE | F_FL1_ENABLE);
  1413. (void) readl(sge->adapter->regs + A_SG_CONTROL); /* flush */
  1414. mod_timer(&sge->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
  1415. if (is_T2(sge->adapter))
  1416. mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
  1417. }
  1418. /*
  1419. * Callback for the T2 ESPI 'stuck packet feature' workaorund
  1420. */
  1421. static void espibug_workaround(void *data)
  1422. {
  1423. struct adapter *adapter = (struct adapter *)data;
  1424. struct sge *sge = adapter->sge;
  1425. if (netif_running(adapter->port[0].dev)) {
  1426. struct sk_buff *skb = sge->espibug_skb;
  1427. u32 seop = t1_espi_get_mon(adapter, 0x930, 0);
  1428. if ((seop & 0xfff0fff) == 0xfff && skb) {
  1429. if (!skb->cb[0]) {
  1430. u8 ch_mac_addr[ETH_ALEN] =
  1431. {0x0, 0x7, 0x43, 0x0, 0x0, 0x0};
  1432. memcpy(skb->data + sizeof(struct cpl_tx_pkt),
  1433. ch_mac_addr, ETH_ALEN);
  1434. memcpy(skb->data + skb->len - 10, ch_mac_addr,
  1435. ETH_ALEN);
  1436. skb->cb[0] = 0xff;
  1437. }
  1438. /* bump the reference count to avoid freeing of the
  1439. * skb once the DMA has completed.
  1440. */
  1441. skb = skb_get(skb);
  1442. t1_sge_tx(skb, adapter, 0, adapter->port[0].dev);
  1443. }
  1444. }
  1445. mod_timer(&sge->espibug_timer, jiffies + sge->espibug_timeout);
  1446. }
  1447. /*
  1448. * Creates a t1_sge structure and returns suggested resource parameters.
  1449. */
  1450. struct sge * __devinit t1_sge_create(struct adapter *adapter,
  1451. struct sge_params *p)
  1452. {
  1453. struct sge *sge = kmalloc(sizeof(*sge), GFP_KERNEL);
  1454. if (!sge)
  1455. return NULL;
  1456. memset(sge, 0, sizeof(*sge));
  1457. sge->adapter = adapter;
  1458. sge->netdev = adapter->port[0].dev;
  1459. sge->rx_pkt_pad = t1_is_T1B(adapter) ? 0 : 2;
  1460. sge->jumbo_fl = t1_is_T1B(adapter) ? 1 : 0;
  1461. init_timer(&sge->tx_reclaim_timer);
  1462. sge->tx_reclaim_timer.data = (unsigned long)sge;
  1463. sge->tx_reclaim_timer.function = sge_tx_reclaim_cb;
  1464. if (is_T2(sge->adapter)) {
  1465. init_timer(&sge->espibug_timer);
  1466. sge->espibug_timer.function = (void *)&espibug_workaround;
  1467. sge->espibug_timer.data = (unsigned long)sge->adapter;
  1468. sge->espibug_timeout = 1;
  1469. }
  1470. p->cmdQ_size[0] = SGE_CMDQ0_E_N;
  1471. p->cmdQ_size[1] = SGE_CMDQ1_E_N;
  1472. p->freelQ_size[!sge->jumbo_fl] = SGE_FREEL_SIZE;
  1473. p->freelQ_size[sge->jumbo_fl] = SGE_JUMBO_FREEL_SIZE;
  1474. p->rx_coalesce_usecs = 50;
  1475. p->coalesce_enable = 0;
  1476. p->sample_interval_usecs = 0;
  1477. p->polling = 0;
  1478. return sge;
  1479. }