cxgb_adapter.h (3e96c7e790c3d5388385ced9c80192fb6f08ecfc) cxgb_adapter.h (8090c9f504c0c19831713ab2392d0993a5fc5b36)
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 17 unchanged lines hidden (view full) ---

26POSSIBILITY OF SUCH DAMAGE.
27
28
29$FreeBSD$
30
31***************************************************************************/
32
33
1/**************************************************************************
2
3Copyright (c) 2007, Chelsio Inc.
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8

--- 17 unchanged lines hidden (view full) ---

26POSSIBILITY OF SUCH DAMAGE.
27
28
29$FreeBSD$
30
31***************************************************************************/
32
33
34
35#ifndef _CXGB_ADAPTER_H_
36#define _CXGB_ADAPTER_H_
37
38#include <sys/lock.h>
39#include <sys/mutex.h>
40#include <sys/sx.h>
41#include <sys/rman.h>
42#include <sys/mbuf.h>
43#include <sys/socket.h>
44#include <sys/sockio.h>
34#ifndef _CXGB_ADAPTER_H_
35#define _CXGB_ADAPTER_H_
36
37#include <sys/lock.h>
38#include <sys/mutex.h>
39#include <sys/sx.h>
40#include <sys/rman.h>
41#include <sys/mbuf.h>
42#include <sys/socket.h>
43#include <sys/sockio.h>
44#include <sys/condvar.h>
45
46#include <net/ethernet.h>
47#include <net/if.h>
48#include <net/if_media.h>
49
50#include <machine/bus.h>
51#include <machine/resource.h>
45
46#include <net/ethernet.h>
47#include <net/if.h>
48#include <net/if_media.h>
49
50#include <machine/bus.h>
51#include <machine/resource.h>
52
52#include <sys/bus_dma.h>
53#include <dev/pci/pcireg.h>
54#include <dev/pci/pcivar.h>
55
56#ifdef CONFIG_DEFINED
57#include <cxgb_osdep.h>
58#include <t3cdev.h>
53#include <sys/bus_dma.h>
54#include <dev/pci/pcireg.h>
55#include <dev/pci/pcivar.h>
56
57#ifdef CONFIG_DEFINED
58#include <cxgb_osdep.h>
59#include <t3cdev.h>
59#include <sys/mbufq.h>
60#include <ulp/toecore/cxgb_toedev.h>
60#include <ulp/toecore/cxgb_toedev.h>
61#include <sys/mbufq.h>
61#else
62#include <dev/cxgb/cxgb_osdep.h>
63#include <dev/cxgb/t3cdev.h>
64#include <dev/cxgb/sys/mbufq.h>
65#include <dev/cxgb/ulp/toecore/cxgb_toedev.h>
66#endif
67
68#define USE_SX

--- 54 unchanged lines hidden (view full) ---

123 uint8_t first_qset;
124
125 uint8_t hw_addr[ETHER_ADDR_LEN];
126 struct taskqueue *tq;
127 struct task start_task;
128 struct task timer_reclaim_task;
129 struct cdev *port_cdev;
130
62#else
63#include <dev/cxgb/cxgb_osdep.h>
64#include <dev/cxgb/t3cdev.h>
65#include <dev/cxgb/sys/mbufq.h>
66#include <dev/cxgb/ulp/toecore/cxgb_toedev.h>
67#endif
68
69#define USE_SX

--- 54 unchanged lines hidden (view full) ---

124 uint8_t first_qset;
125
126 uint8_t hw_addr[ETHER_ADDR_LEN];
127 struct taskqueue *tq;
128 struct task start_task;
129 struct task timer_reclaim_task;
130 struct cdev *port_cdev;
131
131#define PORT_NAME_LEN 32
132#define PORT_LOCK_NAME_LEN 32
132#define TASKQ_NAME_LEN 32
133#define TASKQ_NAME_LEN 32
133 char lockbuf[PORT_NAME_LEN];
134#define PORT_NAME_LEN 32
135 char lockbuf[PORT_LOCK_NAME_LEN];
134 char taskqbuf[TASKQ_NAME_LEN];
136 char taskqbuf[TASKQ_NAME_LEN];
137 char namebuf[PORT_NAME_LEN];
135};
136
137enum { /* adapter flags */
138 FULL_INIT_DONE = (1 << 0),
139 USING_MSI = (1 << 1),
140 USING_MSIX = (1 << 2),
141 QUEUES_BOUND = (1 << 3),
142 FW_UPTODATE = (1 << 4),
143 TPS_UPTODATE = (1 << 5),
144};
145
138};
139
140enum { /* adapter flags */
141 FULL_INIT_DONE = (1 << 0),
142 USING_MSI = (1 << 1),
143 USING_MSIX = (1 << 2),
144 QUEUES_BOUND = (1 << 3),
145 FW_UPTODATE = (1 << 4),
146 TPS_UPTODATE = (1 << 5),
147};
148
146
147#define FL_Q_SIZE 4096
149#define FL_Q_SIZE 4096
148#define JUMBO_Q_SIZE 512
150#define JUMBO_Q_SIZE 1024
149#define RSPQ_Q_SIZE 1024
150#define TX_ETH_Q_SIZE 1024
151
151#define RSPQ_Q_SIZE 1024
152#define TX_ETH_Q_SIZE 1024
153
154enum { TXQ_ETH = 0,
155 TXQ_OFLD = 1,
156 TXQ_CTRL = 2, };
152
153
157
158
154/*
155 * Types of Tx queues in each queue set. Order here matters, do not change.
156 * XXX TOE is not implemented yet, so the extra queues are just placeholders.
157 */
158enum { TXQ_ETH, TXQ_OFLD, TXQ_CTRL };
159
160
161/* careful, the following are set on priv_flags and must not collide with
162 * IFF_ flags!
163 */
164enum {
165 LRO_ACTIVE = (1 << 8),
166};
167
168/* Max concurrent LRO sessions per queue set */

--- 101 unchanged lines hidden (view full) ---

270 struct port_info *port;
271 uint32_t cntxt_id;
272 uint64_t stops;
273 uint64_t restarts;
274 bus_dma_tag_t desc_tag;
275 bus_dmamap_t desc_map;
276 bus_dma_tag_t entry_tag;
277 struct mbuf_head sendq;
159/* careful, the following are set on priv_flags and must not collide with
160 * IFF_ flags!
161 */
162enum {
163 LRO_ACTIVE = (1 << 8),
164};
165
166/* Max concurrent LRO sessions per queue set */

--- 101 unchanged lines hidden (view full) ---

268 struct port_info *port;
269 uint32_t cntxt_id;
270 uint64_t stops;
271 uint64_t restarts;
272 bus_dma_tag_t desc_tag;
273 bus_dmamap_t desc_map;
274 bus_dma_tag_t entry_tag;
275 struct mbuf_head sendq;
276 /*
277 * cleanq should really be an buf_ring to avoid extra
278 * mbuf touches
279 */
280 struct mbuf_head cleanq;
281 struct buf_ring txq_mr;
282 struct mbuf *immpkt;
283 uint32_t txq_drops;
284 uint32_t txq_skipped;
285 uint32_t txq_coalesced;
286 uint32_t txq_enqueued;
287 unsigned long txq_frees;
278 struct mtx lock;
288 struct mtx lock;
289 struct sg_ent txq_sgl[TX_MAX_SEGS / 2 + 1];
290 bus_dma_segment_t txq_segs[TX_MAX_SEGS];
291 struct mbuf *txq_m_vec[TX_WR_COUNT_MAX];
279#define TXQ_NAME_LEN 32
280 char lockbuf[TXQ_NAME_LEN];
281};
282
283
284enum {
285 SGE_PSTAT_TSO, /* # of TSO requests */
286 SGE_PSTAT_RX_CSUM_GOOD, /* # of successful RX csum offloads */
287 SGE_PSTAT_TX_CSUM, /* # of TX checksum offloads */
288 SGE_PSTAT_VLANEX, /* # of VLAN tag extractions */
289 SGE_PSTAT_VLANINS, /* # of VLAN tag insertions */
290 SGE_PSTATS_LRO_QUEUED, /* # of LRO appended packets */
291 SGE_PSTATS_LRO_FLUSHED, /* # of LRO flushed packets */
292 SGE_PSTATS_LRO_X_STREAMS, /* # of exceeded LRO contexts */
293};
294
295#define SGE_PSTAT_MAX (SGE_PSTATS_LRO_X_STREAMS+1)
296
292#define TXQ_NAME_LEN 32
293 char lockbuf[TXQ_NAME_LEN];
294};
295
296
297enum {
298 SGE_PSTAT_TSO, /* # of TSO requests */
299 SGE_PSTAT_RX_CSUM_GOOD, /* # of successful RX csum offloads */
300 SGE_PSTAT_TX_CSUM, /* # of TX checksum offloads */
301 SGE_PSTAT_VLANEX, /* # of VLAN tag extractions */
302 SGE_PSTAT_VLANINS, /* # of VLAN tag insertions */
303 SGE_PSTATS_LRO_QUEUED, /* # of LRO appended packets */
304 SGE_PSTATS_LRO_FLUSHED, /* # of LRO flushed packets */
305 SGE_PSTATS_LRO_X_STREAMS, /* # of exceeded LRO contexts */
306};
307
308#define SGE_PSTAT_MAX (SGE_PSTATS_LRO_X_STREAMS+1)
309
310#define QS_EXITING 0x1
311#define QS_RUNNING 0x2
312#define QS_BOUND 0x4
313
297struct sge_qset {
298 struct sge_rspq rspq;
299 struct sge_fl fl[SGE_RXQ_PER_SET];
300 struct lro_state lro;
301 struct sge_txq txq[SGE_TXQ_PER_SET];
302 uint32_t txq_stopped; /* which Tx queues are stopped */
303 uint64_t port_stats[SGE_PSTAT_MAX];
304 struct port_info *port;
305 int idx; /* qset # */
314struct sge_qset {
315 struct sge_rspq rspq;
316 struct sge_fl fl[SGE_RXQ_PER_SET];
317 struct lro_state lro;
318 struct sge_txq txq[SGE_TXQ_PER_SET];
319 uint32_t txq_stopped; /* which Tx queues are stopped */
320 uint64_t port_stats[SGE_PSTAT_MAX];
321 struct port_info *port;
322 int idx; /* qset # */
323 int qs_cpuid;
324 int qs_flags;
325 struct cv qs_cv;
326 struct mtx qs_mtx;
327#define QS_NAME_LEN 32
328 char namebuf[QS_NAME_LEN];
306};
307
308struct sge {
309 struct sge_qset qs[SGE_QSETS];
310 struct mtx reg_lock;
311};
312
313struct filter_info;

--- 25 unchanged lines hidden (view full) ---

339 uint32_t msix_regs_rid;
340 struct resource *msix_regs_res;
341
342 struct resource *msix_irq_res[SGE_QSETS];
343 int msix_irq_rid[SGE_QSETS];
344 void *msix_intr_tag[SGE_QSETS];
345 uint8_t rxpkt_map[8]; /* maps RX_PKT interface values to port ids */
346 uint8_t rrss_map[SGE_QSETS]; /* revers RSS map table */
329};
330
331struct sge {
332 struct sge_qset qs[SGE_QSETS];
333 struct mtx reg_lock;
334};
335
336struct filter_info;

--- 25 unchanged lines hidden (view full) ---

362 uint32_t msix_regs_rid;
363 struct resource *msix_regs_res;
364
365 struct resource *msix_irq_res[SGE_QSETS];
366 int msix_irq_rid[SGE_QSETS];
367 void *msix_intr_tag[SGE_QSETS];
368 uint8_t rxpkt_map[8]; /* maps RX_PKT interface values to port ids */
369 uint8_t rrss_map[SGE_QSETS]; /* revers RSS map table */
370 uint16_t rspq_map[RSS_TABLE_SIZE]; /* maps 7-bit cookie to qidx */
371 union {
372 uint8_t fill[SGE_QSETS];
373 uint64_t coalesce;
374 } u;
347
375
376#define tunq_fill u.fill
377#define tunq_coalesce u.coalesce
378
348 struct filter_info *filters;
349
350 /* Tasks */
351 struct task ext_intr_task;
352 struct task slow_intr_task;
353 struct task tick_task;
354 struct task process_responses_task;
355 struct taskqueue *tq;

--- 113 unchanged lines hidden (view full) ---

469}
470
471static __inline uint8_t *
472t3_get_next_mcaddr(struct t3_rx_mode *rm)
473{
474 uint8_t *macaddr = NULL;
475
476 if (rm->idx == 0)
379 struct filter_info *filters;
380
381 /* Tasks */
382 struct task ext_intr_task;
383 struct task slow_intr_task;
384 struct task tick_task;
385 struct task process_responses_task;
386 struct taskqueue *tq;

--- 113 unchanged lines hidden (view full) ---

500}
501
502static __inline uint8_t *
503t3_get_next_mcaddr(struct t3_rx_mode *rm)
504{
505 uint8_t *macaddr = NULL;
506
507 if (rm->idx == 0)
477 macaddr = rm->port->hw_addr;
508 macaddr = (uint8_t *)rm->port->hw_addr;
478
479 rm->idx++;
480 return (macaddr);
481}
482
483static __inline void
484t3_init_rx_mode(struct t3_rx_mode *rm, struct port_info *port)
485{

--- 24 unchanged lines hidden (view full) ---

510int t3_sge_alloc_qset(adapter_t *, uint32_t, int, int, const struct qset_params *,
511 int, struct port_info *);
512void t3_free_sge_resources(adapter_t *);
513void t3_sge_start(adapter_t *);
514void t3_sge_stop(adapter_t *);
515void t3b_intr(void *data);
516void t3_intr_msi(void *data);
517void t3_intr_msix(void *data);
509
510 rm->idx++;
511 return (macaddr);
512}
513
514static __inline void
515t3_init_rx_mode(struct t3_rx_mode *rm, struct port_info *port)
516{

--- 24 unchanged lines hidden (view full) ---

541int t3_sge_alloc_qset(adapter_t *, uint32_t, int, int, const struct qset_params *,
542 int, struct port_info *);
543void t3_free_sge_resources(adapter_t *);
544void t3_sge_start(adapter_t *);
545void t3_sge_stop(adapter_t *);
546void t3b_intr(void *data);
547void t3_intr_msi(void *data);
548void t3_intr_msix(void *data);
518int t3_encap(struct port_info *, struct mbuf **, int *free);
549int t3_encap(struct sge_qset *, struct mbuf **, int);
519
520int t3_sge_init_adapter(adapter_t *);
521int t3_sge_init_port(struct port_info *);
522void t3_sge_deinit_sw(adapter_t *);
550
551int t3_sge_init_adapter(adapter_t *);
552int t3_sge_init_port(struct port_info *);
553void t3_sge_deinit_sw(adapter_t *);
554void t3_free_tx_desc(struct sge_txq *q, int n);
555void t3_free_tx_desc_all(struct sge_txq *q);
523
524void t3_rx_eth_lro(adapter_t *adap, struct sge_rspq *rq, struct mbuf *m,
525 int ethpad, uint32_t rss_hash, uint32_t rss_csum, int lro);
526void t3_rx_eth(struct adapter *adap, struct sge_rspq *rq, struct mbuf *m, int ethpad);
527void t3_lro_flush(adapter_t *adap, struct sge_qset *qs, struct lro_state *state);
528
556
557void t3_rx_eth_lro(adapter_t *adap, struct sge_rspq *rq, struct mbuf *m,
558 int ethpad, uint32_t rss_hash, uint32_t rss_csum, int lro);
559void t3_rx_eth(struct adapter *adap, struct sge_rspq *rq, struct mbuf *m, int ethpad);
560void t3_lro_flush(adapter_t *adap, struct sge_qset *qs, struct lro_state *state);
561
529void t3_add_sysctls(adapter_t *sc);
562void t3_add_attach_sysctls(adapter_t *sc);
563void t3_add_configured_sysctls(adapter_t *sc);
530int t3_get_desc(const struct sge_qset *qs, unsigned int qnum, unsigned int idx,
531 unsigned char *data);
532void t3_update_qset_coalesce(struct sge_qset *qs, const struct qset_params *p);
533/*
534 * XXX figure out how we can return this to being private to sge
535 */
536#define desc_reclaimable(q) ((int)((q)->processed - (q)->cleaned - TX_MAX_DESC))
537
564int t3_get_desc(const struct sge_qset *qs, unsigned int qnum, unsigned int idx,
565 unsigned char *data);
566void t3_update_qset_coalesce(struct sge_qset *qs, const struct qset_params *p);
567/*
568 * XXX figure out how we can return this to being private to sge
569 */
570#define desc_reclaimable(q) ((int)((q)->processed - (q)->cleaned - TX_MAX_DESC))
571
538#define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field)))
572#define container_of(p, stype, field) ((stype *)(((uint8_t *)(p)) - offsetof(stype, field)))
539
540static __inline struct sge_qset *
541fl_to_qset(struct sge_fl *q, int qidx)
542{
543 return container_of(q, struct sge_qset, fl[qidx]);
544}
545
546static __inline struct sge_qset *

--- 17 unchanged lines hidden (view full) ---

564#undef container_of
565
566#define OFFLOAD_DEVMAP_BIT 15
567static inline int offload_running(adapter_t *adapter)
568{
569 return isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT);
570}
571
573
574static __inline struct sge_qset *
575fl_to_qset(struct sge_fl *q, int qidx)
576{
577 return container_of(q, struct sge_qset, fl[qidx]);
578}
579
580static __inline struct sge_qset *

--- 17 unchanged lines hidden (view full) ---

598#undef container_of
599
600#define OFFLOAD_DEVMAP_BIT 15
601static inline int offload_running(adapter_t *adapter)
602{
603 return isset(&adapter->open_device_map, OFFLOAD_DEVMAP_BIT);
604}
605
606#ifdef IFNET_MULTIQUEUE
607int cxgb_pcpu_enqueue_packet(struct ifnet *ifp, struct mbuf *m);
608int cxgb_pcpu_start(struct ifnet *ifp, struct mbuf *m);
609int32_t cxgb_pcpu_get_cookie(struct ifnet *ifp, struct in6_addr *lip, uint16_t lport,
610 struct in6_addr *rip, uint16_t rport, int ipv6);
611void cxgb_pcpu_shutdown_threads(struct adapter *sc);
612void cxgb_pcpu_startup_threads(struct adapter *sc);
613#endif
572
614
615int process_responses(adapter_t *adap, struct sge_qset *qs, int budget);
616int cxgb_tx_common(struct ifnet *ifp, struct sge_qset *qs, uint32_t txmax);
617void t3_free_qset(adapter_t *sc, struct sge_qset *q);
618int cxgb_dequeue_packet(struct ifnet *, struct sge_txq *, struct mbuf **);
619void cxgb_start(struct ifnet *ifp);
620void refill_fl_service(adapter_t *adap, struct sge_fl *fl);
621
573#endif
622#endif