forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/chelsio/cxgb3/sge.c
....@@ -372,7 +372,7 @@
372372 /**
373373 * free_rx_bufs - free the Rx buffers on an SGE free list
374374 * @pdev: the PCI device associated with the adapter
375
- * @rxq: the SGE free list to clean up
375
+ * @q: the SGE free list to clean up
376376 *
377377 * Release the buffers on an SGE free-buffer Rx queue. HW fetching from
378378 * this queue should be stopped before calling this function.
....@@ -493,7 +493,7 @@
493493
494494 /**
495495 * refill_fl - refill an SGE free-buffer list
496
- * @adapter: the adapter
496
+ * @adap: the adapter
497497 * @q: the free-list to refill
498498 * @n: the number of new buffers to allocate
499499 * @gfp: the gfp flags for allocating new buffers
....@@ -568,7 +568,7 @@
568568
569569 /**
570570 * recycle_rx_buf - recycle a receive buffer
571
- * @adapter: the adapter
571
+ * @adap: the adapter
572572 * @q: the SGE free list
573573 * @idx: index of buffer to recycle
574574 *
....@@ -620,7 +620,7 @@
620620 {
621621 size_t len = nelem * elem_size;
622622 void *s = NULL;
623
- void *p = dma_zalloc_coherent(&pdev->dev, len, phys, GFP_KERNEL);
623
+ void *p = dma_alloc_coherent(&pdev->dev, len, phys, GFP_KERNEL);
624624
625625 if (!p)
626626 return NULL;
....@@ -825,6 +825,7 @@
825825 * get_packet_pg - return the next ingress packet buffer from a free list
826826 * @adap: the adapter that received the packet
827827 * @fl: the SGE free list holding the packet
828
+ * @q: the queue
828829 * @len: the packet length including any SGE padding
829830 * @drop_thres: # of remaining buffers before we start dropping packets
830831 *
....@@ -1173,6 +1174,7 @@
11731174 * @q: the Tx queue
11741175 * @ndesc: number of descriptors the packet will occupy
11751176 * @compl: the value of the COMPL bit to use
1177
+ * @addr: address
11761178 *
11771179 * Generate a TX_PKT work request to send the supplied packet.
11781180 */
....@@ -1516,14 +1518,14 @@
15161518
15171519 /**
15181520 * restart_ctrlq - restart a suspended control queue
1519
- * @qs: the queue set cotaining the control queue
1521
+ * @t: pointer to the tasklet associated with this handler
15201522 *
15211523 * Resumes transmission on a suspended Tx control queue.
15221524 */
1523
-static void restart_ctrlq(unsigned long data)
1525
+static void restart_ctrlq(struct tasklet_struct *t)
15241526 {
15251527 struct sk_buff *skb;
1526
- struct sge_qset *qs = (struct sge_qset *)data;
1528
+ struct sge_qset *qs = from_tasklet(qs, t, txq[TXQ_CTRL].qresume_tsk);
15271529 struct sge_txq *q = &qs->txq[TXQ_CTRL];
15281530
15291531 spin_lock(&q->lock);
....@@ -1622,6 +1624,7 @@
16221624 * @pidx: index of the first Tx descriptor to write
16231625 * @gen: the generation value to use
16241626 * @ndesc: number of descriptors the packet will occupy
1627
+ * @addr: the address
16251628 *
16261629 * Write an offload work request to send the supplied packet. The packet
16271630 * data already carry the work request with most fields populated.
....@@ -1733,14 +1736,14 @@
17331736
17341737 /**
17351738 * restart_offloadq - restart a suspended offload queue
1736
- * @qs: the queue set cotaining the offload queue
1739
+ * @t: pointer to the tasklet associated with this handler
17371740 *
17381741 * Resumes transmission on a suspended Tx offload queue.
17391742 */
1740
-static void restart_offloadq(unsigned long data)
1743
+static void restart_offloadq(struct tasklet_struct *t)
17411744 {
17421745 struct sk_buff *skb;
1743
- struct sge_qset *qs = (struct sge_qset *)data;
1746
+ struct sge_qset *qs = from_tasklet(qs, t, txq[TXQ_OFLD].qresume_tsk);
17441747 struct sge_txq *q = &qs->txq[TXQ_OFLD];
17451748 const struct port_info *pi = netdev_priv(qs->netdev);
17461749 struct adapter *adap = pi->adapter;
....@@ -1883,7 +1886,7 @@
18831886
18841887 /**
18851888 * ofld_poll - NAPI handler for offload packets in interrupt mode
1886
- * @dev: the network device doing the polling
1889
+ * @napi: the network device doing the polling
18871890 * @budget: polling budget
18881891 *
18891892 * The NAPI handler for offload packets when a response queue is serviced
....@@ -2007,7 +2010,7 @@
20072010
20082011 /**
20092012 * cxgb3_arp_process - process an ARP request probing a private IP address
2010
- * @adapter: the adapter
2013
+ * @pi: the port info
20112014 * @skb: the skbuff containing the ARP request
20122015 *
20132016 * Check if the ARP request is probing the private IP address
....@@ -2069,7 +2072,8 @@
20692072 * @adap: the adapter
20702073 * @rq: the response queue that received the packet
20712074 * @skb: the packet
2072
- * @pad: amount of padding at the start of the buffer
2075
+ * @pad: padding
2076
+ * @lro: large receive offload
20732077 *
20742078 * Process an ingress ethernet pakcet and deliver it to the stack.
20752079 * The padding is 2 if the packet was delivered in an Rx buffer and 0
....@@ -2132,7 +2136,7 @@
21322136 struct port_info *pi = netdev_priv(qs->netdev);
21332137 struct sk_buff *skb = NULL;
21342138 struct cpl_rx_pkt *cpl;
2135
- struct skb_frag_struct *rx_frag;
2139
+ skb_frag_t *rx_frag;
21362140 int nr_frags;
21372141 int offset = 0;
21382142
....@@ -2182,7 +2186,7 @@
21822186
21832187 rx_frag += nr_frags;
21842188 __skb_frag_set_page(rx_frag, sd->pg_chunk.page);
2185
- rx_frag->page_offset = sd->pg_chunk.offset + offset;
2189
+ skb_frag_off_set(rx_frag, sd->pg_chunk.offset + offset);
21862190 skb_frag_size_set(rx_frag, len);
21872191
21882192 skb->len += len;
....@@ -2239,7 +2243,7 @@
22392243
22402244 /**
22412245 * check_ring_db - check if we need to ring any doorbells
2242
- * @adapter: the adapter
2246
+ * @adap: the adapter
22432247 * @qs: the queue set whose Tx queues are to be examined
22442248 * @sleeping: indicates which Tx queue sent GTS
22452249 *
....@@ -2372,16 +2376,13 @@
23722376 if (fl->use_pages) {
23732377 void *addr = fl->sdesc[fl->cidx].pg_chunk.va;
23742378
2375
- prefetch(addr);
2376
-#if L1_CACHE_BYTES < 128
2377
- prefetch(addr + L1_CACHE_BYTES);
2378
-#endif
2379
+ net_prefetch(addr);
23792380 __refill_fl(adap, fl);
23802381 if (lro > 0) {
23812382 lro_add_page(adap, qs, fl,
23822383 G_RSPD_LEN(len),
23832384 flags & F_RSPD_EOP);
2384
- goto next_fl;
2385
+ goto next_fl;
23852386 }
23862387
23872388 skb = get_packet_pg(adap, fl, q,
....@@ -2902,7 +2903,7 @@
29022903
29032904 /**
29042905 * sge_timer_tx - perform periodic maintenance of an SGE qset
2905
- * @data: the SGE queue set to maintain
2906
+ * @t: a timer list containing the SGE queue set to maintain
29062907 *
29072908 * Runs periodically from a timer to perform maintenance of an SGE queue
29082909 * set. It performs two tasks:
....@@ -2946,7 +2947,7 @@
29462947
29472948 /**
29482949 * sge_timer_rx - perform periodic maintenance of an SGE qset
2949
- * @data: the SGE queue set to maintain
2950
+ * @t: the timer list containing the SGE queue set to maintain
29502951 *
29512952 * a) Replenishes Rx queues that have run out due to memory shortage.
29522953 * Normally new Rx buffers are added when existing ones are consumed but
....@@ -3024,7 +3025,7 @@
30243025 * @irq_vec_idx: the IRQ vector index for response queue interrupts
30253026 * @p: configuration parameters for this queue set
30263027 * @ntxq: number of Tx queues for the queue set
3027
- * @netdev: net device associated with this queue set
3028
+ * @dev: net device associated with this queue set
30283029 * @netdevq: net device TX queue associated with this queue set
30293030 *
30303031 * Allocate resources and initialize an SGE queue set. A queue set
....@@ -3084,10 +3085,8 @@
30843085 skb_queue_head_init(&q->txq[i].sendq);
30853086 }
30863087
3087
- tasklet_init(&q->txq[TXQ_OFLD].qresume_tsk, restart_offloadq,
3088
- (unsigned long)q);
3089
- tasklet_init(&q->txq[TXQ_CTRL].qresume_tsk, restart_ctrlq,
3090
- (unsigned long)q);
3088
+ tasklet_setup(&q->txq[TXQ_OFLD].qresume_tsk, restart_offloadq);
3089
+ tasklet_setup(&q->txq[TXQ_CTRL].qresume_tsk, restart_ctrlq);
30913090
30923091 q->fl[0].gen = q->fl[1].gen = 1;
30933092 q->fl[0].size = p->fl_size;
....@@ -3215,11 +3214,13 @@
32153214 for (i = 0; i < SGE_QSETS; ++i) {
32163215 struct sge_qset *q = &adap->sge.qs[i];
32173216
3218
- if (q->tx_reclaim_timer.function)
3219
- mod_timer(&q->tx_reclaim_timer, jiffies + TX_RECLAIM_PERIOD);
3217
+ if (q->tx_reclaim_timer.function)
3218
+ mod_timer(&q->tx_reclaim_timer,
3219
+ jiffies + TX_RECLAIM_PERIOD);
32203220
3221
- if (q->rx_reclaim_timer.function)
3222
- mod_timer(&q->rx_reclaim_timer, jiffies + RX_RECLAIM_PERIOD);
3221
+ if (q->rx_reclaim_timer.function)
3222
+ mod_timer(&q->rx_reclaim_timer,
3223
+ jiffies + RX_RECLAIM_PERIOD);
32233224 }
32243225 }
32253226
....@@ -3270,30 +3271,40 @@
32703271 }
32713272
32723273 /**
3273
- * t3_sge_stop - disable SGE operation
3274
+ * t3_sge_stop_dma - Disable SGE DMA engine operation
32743275 * @adap: the adapter
32753276 *
3276
- * Disables the DMA engine. This can be called in emeregencies (e.g.,
3277
- * from error interrupts) or from normal process context. In the latter
3278
- * case it also disables any pending queue restart tasklets. Note that
3279
- * if it is called in interrupt context it cannot disable the restart
3280
- * tasklets as it cannot wait, however the tasklets will have no effect
3281
- * since the doorbells are disabled and the driver will call this again
3282
- * later from process context, at which time the tasklets will be stopped
3283
- * if they are still running.
3277
+ * Can be invoked from interrupt context e.g. error handler.
3278
+ *
3279
+ * Note that this function cannot disable the restart of tasklets as
3280
+ * it cannot wait if called from interrupt context, however the
3281
+ * tasklets will have no effect since the doorbells are disabled. The
3282
+ * driver will call tg3_sge_stop() later from process context, at
3283
+ * which time the tasklets will be stopped if they are still running.
3284
+ */
3285
+void t3_sge_stop_dma(struct adapter *adap)
3286
+{
3287
+ t3_set_reg_field(adap, A_SG_CONTROL, F_GLOBALENABLE, 0);
3288
+}
3289
+
3290
+/**
3291
+ * t3_sge_stop - disable SGE operation completly
3292
+ * @adap: the adapter
3293
+ *
3294
+ * Called from process context. Disables the DMA engine and any
3295
+ * pending queue restart tasklets.
32843296 */
32853297 void t3_sge_stop(struct adapter *adap)
32863298 {
3287
- t3_set_reg_field(adap, A_SG_CONTROL, F_GLOBALENABLE, 0);
3288
- if (!in_interrupt()) {
3289
- int i;
3299
+ int i;
32903300
3291
- for (i = 0; i < SGE_QSETS; ++i) {
3292
- struct sge_qset *qs = &adap->sge.qs[i];
3301
+ t3_sge_stop_dma(adap);
32933302
3294
- tasklet_kill(&qs->txq[TXQ_OFLD].qresume_tsk);
3295
- tasklet_kill(&qs->txq[TXQ_CTRL].qresume_tsk);
3296
- }
3303
+ for (i = 0; i < SGE_QSETS; ++i) {
3304
+ struct sge_qset *qs = &adap->sge.qs[i];
3305
+
3306
+ tasklet_kill(&qs->txq[TXQ_OFLD].qresume_tsk);
3307
+ tasklet_kill(&qs->txq[TXQ_CTRL].qresume_tsk);
32973308 }
32983309 }
32993310