.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /**************************************************************************** |
---|
2 | 3 | * Driver for Solarflare network controllers and boards |
---|
3 | 4 | * Copyright 2005-2006 Fen Systems Ltd. |
---|
4 | 5 | * Copyright 2005-2013 Solarflare Communications Inc. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms of the GNU General Public License version 2 as published |
---|
8 | | - * by the Free Software Foundation, incorporated herein by reference. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | /* Common definitions for all Efx net driver code */ |
---|
.. | .. |
---|
27 | 24 | #include <linux/mutex.h> |
---|
28 | 25 | #include <linux/rwsem.h> |
---|
29 | 26 | #include <linux/vmalloc.h> |
---|
30 | | -#include <linux/i2c.h> |
---|
31 | 27 | #include <linux/mtd/mtd.h> |
---|
32 | 28 | #include <net/busy_poll.h> |
---|
| 29 | +#include <net/xdp.h> |
---|
33 | 30 | |
---|
34 | 31 | #include "enum.h" |
---|
35 | 32 | #include "bitfield.h" |
---|
.. | .. |
---|
40 | 37 | * Build definitions |
---|
41 | 38 | * |
---|
42 | 39 | **************************************************************************/ |
---|
43 | | - |
---|
44 | | -#define EFX_DRIVER_VERSION "4.1" |
---|
45 | 40 | |
---|
46 | 41 | #ifdef DEBUG |
---|
47 | 42 | #define EFX_WARN_ON_ONCE_PARANOID(x) WARN_ON_ONCE(x) |
---|
.. | .. |
---|
68 | 63 | * queues. */ |
---|
69 | 64 | #define EFX_MAX_TX_TC 2 |
---|
70 | 65 | #define EFX_MAX_CORE_TX_QUEUES (EFX_MAX_TX_TC * EFX_MAX_CHANNELS) |
---|
71 | | -#define EFX_TXQ_TYPE_OFFLOAD 1 /* flag */ |
---|
72 | | -#define EFX_TXQ_TYPE_HIGHPRI 2 /* flag */ |
---|
73 | | -#define EFX_TXQ_TYPES 4 |
---|
74 | | -#define EFX_MAX_TX_QUEUES (EFX_TXQ_TYPES * EFX_MAX_CHANNELS) |
---|
| 66 | +#define EFX_TXQ_TYPE_OUTER_CSUM 1 /* Outer checksum offload */ |
---|
| 67 | +#define EFX_TXQ_TYPE_INNER_CSUM 2 /* Inner checksum offload */ |
---|
| 68 | +#define EFX_TXQ_TYPE_HIGHPRI 4 /* High-priority (for TC) */ |
---|
| 69 | +#define EFX_TXQ_TYPES 8 |
---|
| 70 | +/* HIGHPRI is Siena-only, and INNER_CSUM is EF10, so no need for both */ |
---|
| 71 | +#define EFX_MAX_TXQ_PER_CHANNEL 4 |
---|
| 72 | +#define EFX_MAX_TX_QUEUES (EFX_MAX_TXQ_PER_CHANNEL * EFX_MAX_CHANNELS) |
---|
75 | 73 | |
---|
76 | 74 | /* Maximum possible MTU the driver supports */ |
---|
77 | 75 | #define EFX_MAX_MTU (9 * 1024) |
---|
78 | 76 | |
---|
79 | 77 | /* Minimum MTU, from RFC791 (IP) */ |
---|
80 | 78 | #define EFX_MIN_MTU 68 |
---|
| 79 | + |
---|
| 80 | +/* Maximum total header length for TSOv2 */ |
---|
| 81 | +#define EFX_TSO2_MAX_HDRLEN 208 |
---|
81 | 82 | |
---|
82 | 83 | /* Size of an RX scatter buffer. Small enough to pack 2 into a 4K page, |
---|
83 | 84 | * and should be a multiple of the cache line size. |
---|
.. | .. |
---|
93 | 94 | #else |
---|
94 | 95 | #define EFX_RX_BUF_ALIGNMENT 4 |
---|
95 | 96 | #endif |
---|
| 97 | + |
---|
| 98 | +/* Non-standard XDP_PACKET_HEADROOM and tailroom to satisfy XDP_REDIRECT and |
---|
| 99 | + * still fit two standard MTU size packets into a single 4K page. |
---|
| 100 | + */ |
---|
| 101 | +#define EFX_XDP_HEADROOM 128 |
---|
| 102 | +#define EFX_XDP_TAILROOM SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) |
---|
96 | 103 | |
---|
97 | 104 | /* Forward declare Precision Time Protocol (PTP) support structure. */ |
---|
98 | 105 | struct efx_ptp_data; |
---|
.. | .. |
---|
139 | 146 | * struct efx_tx_buffer - buffer state for a TX descriptor |
---|
140 | 147 | * @skb: When @flags & %EFX_TX_BUF_SKB, the associated socket buffer to be |
---|
141 | 148 | * freed when descriptor completes |
---|
142 | | - * @option: When @flags & %EFX_TX_BUF_OPTION, a NIC-specific option descriptor. |
---|
| 149 | + * @xdpf: When @flags & %EFX_TX_BUF_XDP, the XDP frame information; its @data |
---|
| 150 | + * member is the associated buffer to drop a page reference on. |
---|
| 151 | + * @option: When @flags & %EFX_TX_BUF_OPTION, an EF10-specific option |
---|
| 152 | + * descriptor. |
---|
143 | 153 | * @dma_addr: DMA address of the fragment. |
---|
144 | 154 | * @flags: Flags for allocation and DMA mapping type |
---|
145 | 155 | * @len: Length of this fragment. |
---|
.. | .. |
---|
149 | 159 | * Only valid if @unmap_len != 0. |
---|
150 | 160 | */ |
---|
151 | 161 | struct efx_tx_buffer { |
---|
152 | | - const struct sk_buff *skb; |
---|
153 | 162 | union { |
---|
154 | | - efx_qword_t option; |
---|
| 163 | + const struct sk_buff *skb; |
---|
| 164 | + struct xdp_frame *xdpf; |
---|
| 165 | + }; |
---|
| 166 | + union { |
---|
| 167 | + efx_qword_t option; /* EF10 */ |
---|
155 | 168 | dma_addr_t dma_addr; |
---|
156 | 169 | }; |
---|
157 | 170 | unsigned short flags; |
---|
.. | .. |
---|
163 | 176 | #define EFX_TX_BUF_SKB 2 /* buffer is last part of skb */ |
---|
164 | 177 | #define EFX_TX_BUF_MAP_SINGLE 8 /* buffer was mapped with dma_map_single() */ |
---|
165 | 178 | #define EFX_TX_BUF_OPTION 0x10 /* empty buffer for option descriptor */ |
---|
| 179 | +#define EFX_TX_BUF_XDP 0x20 /* buffer was sent with XDP */ |
---|
| 180 | +#define EFX_TX_BUF_TSO_V3 0x40 /* empty buffer for a TSO_V3 descriptor */ |
---|
166 | 181 | |
---|
167 | 182 | /** |
---|
168 | 183 | * struct efx_tx_queue - An Efx TX queue |
---|
.. | .. |
---|
179 | 194 | * |
---|
180 | 195 | * @efx: The associated Efx NIC |
---|
181 | 196 | * @queue: DMA queue number |
---|
| 197 | + * @label: Label for TX completion events. |
---|
| 198 | + * Is our index within @channel->tx_queue array. |
---|
| 199 | + * @type: configuration type of this TX queue. A bitmask of %EFX_TXQ_TYPE_* flags. |
---|
182 | 200 | * @tso_version: Version of TSO in use for this queue. |
---|
| 201 | + * @tso_encap: Is encapsulated TSO supported? Supported in TSOv2 on 8000 series. |
---|
183 | 202 | * @channel: The associated channel |
---|
184 | 203 | * @core_txq: The networking core TX queue structure |
---|
185 | 204 | * @buffer: The software buffer ring |
---|
.. | .. |
---|
192 | 211 | * @piobuf_offset: Buffer offset to be specified in PIO descriptors |
---|
193 | 212 | * @initialised: Has hardware queue been initialised? |
---|
194 | 213 | * @timestamping: Is timestamping enabled for this channel? |
---|
195 | | - * @handle_tso: TSO xmit preparation handler. Sets up the TSO metadata and |
---|
196 | | - * may also map tx data, depending on the nature of the TSO implementation. |
---|
| 214 | + * @xdp_tx: Is this an XDP tx queue? |
---|
197 | 215 | * @read_count: Current read pointer. |
---|
198 | 216 | * This is the number of buffers that have been removed from both rings. |
---|
199 | 217 | * @old_write_count: The value of @write_count when last checked. |
---|
.. | .. |
---|
203 | 221 | * avoid cache-line ping-pong between the xmit path and the |
---|
204 | 222 | * completion path. |
---|
205 | 223 | * @merge_events: Number of TX merged completion events |
---|
206 | | - * @completed_desc_ptr: Most recent completed pointer - only used with |
---|
207 | | - * timestamping. |
---|
208 | 224 | * @completed_timestamp_major: Top part of the most recent tx timestamp. |
---|
209 | 225 | * @completed_timestamp_minor: Low part of the most recent tx timestamp. |
---|
210 | 226 | * @insert_count: Current insert pointer |
---|
.. | .. |
---|
232 | 248 | * @tso_fallbacks: Number of times TSO fallback used |
---|
233 | 249 | * @pushes: Number of times the TX push feature has been used |
---|
234 | 250 | * @pio_packets: Number of times the TX PIO feature has been used |
---|
235 | | - * @xmit_more_available: Are any packets waiting to be pushed to the NIC |
---|
| 251 | + * @xmit_pending: Are any packets waiting to be pushed to the NIC |
---|
236 | 252 | * @cb_packets: Number of times the TX copybreak feature has been used |
---|
| 253 | + * @notify_count: Count of notified descriptors to the NIC |
---|
237 | 254 | * @empty_read_count: If the completion path has seen the queue as empty |
---|
238 | 255 | * and the transmission path has not yet checked this, the value of |
---|
239 | 256 | * @read_count bitwise-added to %EFX_EMPTY_COUNT_VALID; otherwise 0. |
---|
.. | .. |
---|
241 | 258 | struct efx_tx_queue { |
---|
242 | 259 | /* Members which don't change on the fast path */ |
---|
243 | 260 | struct efx_nic *efx ____cacheline_aligned_in_smp; |
---|
244 | | - unsigned queue; |
---|
| 261 | + unsigned int queue; |
---|
| 262 | + unsigned int label; |
---|
| 263 | + unsigned int type; |
---|
245 | 264 | unsigned int tso_version; |
---|
| 265 | + bool tso_encap; |
---|
246 | 266 | struct efx_channel *channel; |
---|
247 | 267 | struct netdev_queue *core_txq; |
---|
248 | 268 | struct efx_tx_buffer *buffer; |
---|
.. | .. |
---|
253 | 273 | unsigned int piobuf_offset; |
---|
254 | 274 | bool initialised; |
---|
255 | 275 | bool timestamping; |
---|
256 | | - |
---|
257 | | - /* Function pointers used in the fast path. */ |
---|
258 | | - int (*handle_tso)(struct efx_tx_queue*, struct sk_buff*, bool *); |
---|
| 276 | + bool xdp_tx; |
---|
259 | 277 | |
---|
260 | 278 | /* Members used mainly on the completion path */ |
---|
261 | 279 | unsigned int read_count ____cacheline_aligned_in_smp; |
---|
.. | .. |
---|
263 | 281 | unsigned int merge_events; |
---|
264 | 282 | unsigned int bytes_compl; |
---|
265 | 283 | unsigned int pkts_compl; |
---|
266 | | - unsigned int completed_desc_ptr; |
---|
267 | 284 | u32 completed_timestamp_major; |
---|
268 | 285 | u32 completed_timestamp_minor; |
---|
269 | 286 | |
---|
.. | .. |
---|
278 | 295 | unsigned int tso_fallbacks; |
---|
279 | 296 | unsigned int pushes; |
---|
280 | 297 | unsigned int pio_packets; |
---|
281 | | - bool xmit_more_available; |
---|
| 298 | + bool xmit_pending; |
---|
282 | 299 | unsigned int cb_packets; |
---|
| 300 | + unsigned int notify_count; |
---|
283 | 301 | /* Statistics to supplement MAC stats */ |
---|
284 | 302 | unsigned long tx_packets; |
---|
285 | 303 | |
---|
.. | .. |
---|
330 | 348 | struct efx_rx_page_state { |
---|
331 | 349 | dma_addr_t dma_addr; |
---|
332 | 350 | |
---|
333 | | - unsigned int __pad[0] ____cacheline_aligned; |
---|
| 351 | + unsigned int __pad[] ____cacheline_aligned; |
---|
334 | 352 | }; |
---|
335 | 353 | |
---|
336 | 354 | /** |
---|
.. | .. |
---|
366 | 384 | * refill was triggered. |
---|
367 | 385 | * @recycle_count: RX buffer recycle counter. |
---|
368 | 386 | * @slow_fill: Timer used to defer efx_nic_generate_fill_event(). |
---|
| 387 | + * @xdp_rxq_info: XDP specific RX queue information. |
---|
| 388 | + * @xdp_rxq_info_valid: Is xdp_rxq_info valid data?. |
---|
369 | 389 | */ |
---|
370 | 390 | struct efx_rx_queue { |
---|
371 | 391 | struct efx_nic *efx; |
---|
.. | .. |
---|
397 | 417 | unsigned int slow_fill_count; |
---|
398 | 418 | /* Statistics to supplement MAC stats */ |
---|
399 | 419 | unsigned long rx_packets; |
---|
| 420 | + struct xdp_rxq_info xdp_rxq_info; |
---|
| 421 | + bool xdp_rxq_info_valid; |
---|
400 | 422 | }; |
---|
401 | 423 | |
---|
402 | 424 | enum efx_sync_events_state { |
---|
.. | .. |
---|
430 | 452 | * @event_test_cpu: Last CPU to handle interrupt or test event for this channel |
---|
431 | 453 | * @irq_count: Number of IRQs since last adaptive moderation decision |
---|
432 | 454 | * @irq_mod_score: IRQ moderation score |
---|
| 455 | + * @rfs_filter_count: number of accelerated RFS filters currently in place; |
---|
| 456 | + * equals the count of @rps_flow_id slots filled |
---|
| 457 | + * @rfs_last_expiry: value of jiffies last time some accelerated RFS filters |
---|
| 458 | + * were checked for expiry |
---|
| 459 | + * @rfs_expire_index: next accelerated RFS filter ID to check for expiry |
---|
| 460 | + * @n_rfs_succeeded: number of successful accelerated RFS filter insertions |
---|
| 461 | + * @n_rfs_failed: number of failed accelerated RFS filter insertions |
---|
433 | 462 | * @filter_work: Work item for efx_filter_rfs_expire() |
---|
434 | 463 | * @rps_flow_id: Flow IDs of filters allocated for accelerated RFS, |
---|
435 | 464 | * indexed by filter ID |
---|
.. | .. |
---|
444 | 473 | * lack of descriptors |
---|
445 | 474 | * @n_rx_merge_events: Number of RX merged completion events |
---|
446 | 475 | * @n_rx_merge_packets: Number of RX packets completed by merged events |
---|
| 476 | + * @n_rx_xdp_drops: Count of RX packets intentionally dropped due to XDP |
---|
| 477 | + * @n_rx_xdp_bad_drops: Count of RX packets dropped due to XDP errors |
---|
| 478 | + * @n_rx_xdp_tx: Count of RX packets retransmitted due to XDP |
---|
| 479 | + * @n_rx_xdp_redirect: Count of RX packets redirected to a different NIC by XDP |
---|
447 | 480 | * @rx_pkt_n_frags: Number of fragments in next packet to be delivered by |
---|
448 | 481 | * __efx_rx_packet(), or zero if there is none |
---|
449 | 482 | * @rx_pkt_index: Ring index of first buffer for next packet to be delivered |
---|
.. | .. |
---|
451 | 484 | * @rx_list: list of SKBs from current RX, awaiting processing |
---|
452 | 485 | * @rx_queue: RX queue for this channel |
---|
453 | 486 | * @tx_queue: TX queues for this channel |
---|
| 487 | + * @tx_queue_by_type: pointers into @tx_queue, or %NULL, indexed by txq type |
---|
454 | 488 | * @sync_events_state: Current state of sync events on this channel |
---|
455 | 489 | * @sync_timestamp_major: Major part of the last ptp sync event |
---|
456 | 490 | * @sync_timestamp_minor: Minor part of the last ptp sync event |
---|
.. | .. |
---|
476 | 510 | unsigned int irq_count; |
---|
477 | 511 | unsigned int irq_mod_score; |
---|
478 | 512 | #ifdef CONFIG_RFS_ACCEL |
---|
479 | | - unsigned int rfs_filters_added; |
---|
480 | | - struct work_struct filter_work; |
---|
| 513 | + unsigned int rfs_filter_count; |
---|
| 514 | + unsigned int rfs_last_expiry; |
---|
| 515 | + unsigned int rfs_expire_index; |
---|
| 516 | + unsigned int n_rfs_succeeded; |
---|
| 517 | + unsigned int n_rfs_failed; |
---|
| 518 | + struct delayed_work filter_work; |
---|
481 | 519 | #define RPS_FLOW_ID_INVALID 0xFFFFFFFF |
---|
482 | 520 | u32 *rps_flow_id; |
---|
483 | 521 | #endif |
---|
.. | .. |
---|
497 | 535 | unsigned int n_rx_nodesc_trunc; |
---|
498 | 536 | unsigned int n_rx_merge_events; |
---|
499 | 537 | unsigned int n_rx_merge_packets; |
---|
| 538 | + unsigned int n_rx_xdp_drops; |
---|
| 539 | + unsigned int n_rx_xdp_bad_drops; |
---|
| 540 | + unsigned int n_rx_xdp_tx; |
---|
| 541 | + unsigned int n_rx_xdp_redirect; |
---|
500 | 542 | |
---|
501 | 543 | unsigned int rx_pkt_n_frags; |
---|
502 | 544 | unsigned int rx_pkt_index; |
---|
.. | .. |
---|
504 | 546 | struct list_head *rx_list; |
---|
505 | 547 | |
---|
506 | 548 | struct efx_rx_queue rx_queue; |
---|
507 | | - struct efx_tx_queue tx_queue[EFX_TXQ_TYPES]; |
---|
| 549 | + struct efx_tx_queue tx_queue[EFX_MAX_TXQ_PER_CHANNEL]; |
---|
| 550 | + struct efx_tx_queue *tx_queue_by_type[EFX_TXQ_TYPES]; |
---|
508 | 551 | |
---|
509 | 552 | enum efx_sync_events_state sync_events_state; |
---|
510 | 553 | u32 sync_timestamp_major; |
---|
.. | .. |
---|
574 | 617 | #define RESET_TYPE(type) \ |
---|
575 | 618 | STRING_TABLE_LOOKUP(type, efx_reset_type) |
---|
576 | 619 | |
---|
577 | | -void efx_get_udp_tunnel_type_name(u16 type, char *buf, size_t buflen); |
---|
578 | | - |
---|
579 | 620 | enum efx_int_mode { |
---|
580 | 621 | /* Be careful if altering to correct macro below */ |
---|
581 | 622 | EFX_INT_MODE_MSIX = 0, |
---|
.. | .. |
---|
586 | 627 | #define EFX_INT_MODE_USE_MSI(x) (((x)->interrupt_mode) <= EFX_INT_MODE_MSI) |
---|
587 | 628 | |
---|
588 | 629 | enum nic_state { |
---|
589 | | - STATE_UNINIT = 0, /* device being probed/removed or is frozen */ |
---|
590 | | - STATE_READY = 1, /* hardware ready and netdev registered */ |
---|
591 | | - STATE_DISABLED = 2, /* device disabled due to hardware errors */ |
---|
592 | | - STATE_RECOVERY = 3, /* device recovering from PCI error */ |
---|
| 630 | + STATE_UNINIT = 0, /* device being probed/removed */ |
---|
| 631 | + STATE_NET_DOWN, /* hardware probed and netdev registered */ |
---|
| 632 | + STATE_NET_UP, /* ready for traffic */ |
---|
| 633 | + STATE_DISABLED, /* device disabled due to hardware errors */ |
---|
| 634 | + |
---|
| 635 | + STATE_RECOVERY = 0x100,/* recovering from PCI error */ |
---|
| 636 | + STATE_FROZEN = 0x200, /* frozen by power management */ |
---|
593 | 637 | }; |
---|
| 638 | + |
---|
| 639 | +static inline bool efx_net_active(enum nic_state state) |
---|
| 640 | +{ |
---|
| 641 | + return state == STATE_NET_DOWN || state == STATE_NET_UP; |
---|
| 642 | +} |
---|
| 643 | + |
---|
| 644 | +static inline bool efx_frozen(enum nic_state state) |
---|
| 645 | +{ |
---|
| 646 | + return state & STATE_FROZEN; |
---|
| 647 | +} |
---|
| 648 | + |
---|
| 649 | +static inline bool efx_recovering(enum nic_state state) |
---|
| 650 | +{ |
---|
| 651 | + return state & STATE_RECOVERY; |
---|
| 652 | +} |
---|
| 653 | + |
---|
| 654 | +static inline enum nic_state efx_freeze(enum nic_state state) |
---|
| 655 | +{ |
---|
| 656 | + WARN_ON(!efx_net_active(state)); |
---|
| 657 | + return state | STATE_FROZEN; |
---|
| 658 | +} |
---|
| 659 | + |
---|
| 660 | +static inline enum nic_state efx_thaw(enum nic_state state) |
---|
| 661 | +{ |
---|
| 662 | + WARN_ON(!efx_frozen(state)); |
---|
| 663 | + return state & ~STATE_FROZEN; |
---|
| 664 | +} |
---|
| 665 | + |
---|
| 666 | +static inline enum nic_state efx_recover(enum nic_state state) |
---|
| 667 | +{ |
---|
| 668 | + WARN_ON(!efx_net_active(state)); |
---|
| 669 | + return state | STATE_RECOVERY; |
---|
| 670 | +} |
---|
| 671 | + |
---|
| 672 | +static inline enum nic_state efx_recovered(enum nic_state state) |
---|
| 673 | +{ |
---|
| 674 | + WARN_ON(!efx_recovering(state)); |
---|
| 675 | + return state & ~STATE_RECOVERY; |
---|
| 676 | +} |
---|
594 | 677 | |
---|
595 | 678 | /* Forward declaration */ |
---|
596 | 679 | struct efx_nic; |
---|
.. | .. |
---|
620 | 703 | return left->up == right->up && left->fd == right->fd && |
---|
621 | 704 | left->fc == right->fc && left->speed == right->speed; |
---|
622 | 705 | } |
---|
623 | | - |
---|
624 | | -/** |
---|
625 | | - * struct efx_phy_operations - Efx PHY operations table |
---|
626 | | - * @probe: Probe PHY and initialise efx->mdio.mode_support, efx->mdio.mmds, |
---|
627 | | - * efx->loopback_modes. |
---|
628 | | - * @init: Initialise PHY |
---|
629 | | - * @fini: Shut down PHY |
---|
630 | | - * @reconfigure: Reconfigure PHY (e.g. for new link parameters) |
---|
631 | | - * @poll: Update @link_state and report whether it changed. |
---|
632 | | - * Serialised by the mac_lock. |
---|
633 | | - * @get_link_ksettings: Get ethtool settings. Serialised by the mac_lock. |
---|
634 | | - * @set_link_ksettings: Set ethtool settings. Serialised by the mac_lock. |
---|
635 | | - * @get_fecparam: Get Forward Error Correction settings. Serialised by mac_lock. |
---|
636 | | - * @set_fecparam: Set Forward Error Correction settings. Serialised by mac_lock. |
---|
637 | | - * @set_npage_adv: Set abilities advertised in (Extended) Next Page |
---|
638 | | - * (only needed where AN bit is set in mmds) |
---|
639 | | - * @test_alive: Test that PHY is 'alive' (online) |
---|
640 | | - * @test_name: Get the name of a PHY-specific test/result |
---|
641 | | - * @run_tests: Run tests and record results as appropriate (offline). |
---|
642 | | - * Flags are the ethtool tests flags. |
---|
643 | | - */ |
---|
644 | | -struct efx_phy_operations { |
---|
645 | | - int (*probe) (struct efx_nic *efx); |
---|
646 | | - int (*init) (struct efx_nic *efx); |
---|
647 | | - void (*fini) (struct efx_nic *efx); |
---|
648 | | - void (*remove) (struct efx_nic *efx); |
---|
649 | | - int (*reconfigure) (struct efx_nic *efx); |
---|
650 | | - bool (*poll) (struct efx_nic *efx); |
---|
651 | | - void (*get_link_ksettings)(struct efx_nic *efx, |
---|
652 | | - struct ethtool_link_ksettings *cmd); |
---|
653 | | - int (*set_link_ksettings)(struct efx_nic *efx, |
---|
654 | | - const struct ethtool_link_ksettings *cmd); |
---|
655 | | - int (*get_fecparam)(struct efx_nic *efx, struct ethtool_fecparam *fec); |
---|
656 | | - int (*set_fecparam)(struct efx_nic *efx, |
---|
657 | | - const struct ethtool_fecparam *fec); |
---|
658 | | - void (*set_npage_adv) (struct efx_nic *efx, u32); |
---|
659 | | - int (*test_alive) (struct efx_nic *efx); |
---|
660 | | - const char *(*test_name) (struct efx_nic *efx, unsigned int index); |
---|
661 | | - int (*run_tests) (struct efx_nic *efx, int *results, unsigned flags); |
---|
662 | | - int (*get_module_eeprom) (struct efx_nic *efx, |
---|
663 | | - struct ethtool_eeprom *ee, |
---|
664 | | - u8 *data); |
---|
665 | | - int (*get_module_info) (struct efx_nic *efx, |
---|
666 | | - struct ethtool_modinfo *modinfo); |
---|
667 | | -}; |
---|
668 | 706 | |
---|
669 | 707 | /** |
---|
670 | 708 | * enum efx_phy_mode - PHY operating mode flags |
---|
.. | .. |
---|
715 | 753 | struct vfdi_status; |
---|
716 | 754 | |
---|
717 | 755 | /* The reserved RSS context value */ |
---|
718 | | -#define EFX_EF10_RSS_CONTEXT_INVALID 0xffffffff |
---|
| 756 | +#define EFX_MCDI_RSS_CONTEXT_INVALID 0xffffffff |
---|
719 | 757 | /** |
---|
720 | 758 | * struct efx_rss_context - A user-defined RSS context for filtering |
---|
721 | 759 | * @list: node of linked list on which this struct is stored |
---|
722 | 760 | * @context_id: the RSS_CONTEXT_ID returned by MC firmware, or |
---|
723 | | - * %EFX_EF10_RSS_CONTEXT_INVALID if this context is not present on the NIC. |
---|
724 | | - * For Siena, 0 if RSS is active, else %EFX_EF10_RSS_CONTEXT_INVALID. |
---|
| 761 | + * %EFX_MCDI_RSS_CONTEXT_INVALID if this context is not present on the NIC. |
---|
| 762 | + * For Siena, 0 if RSS is active, else %EFX_MCDI_RSS_CONTEXT_INVALID. |
---|
725 | 763 | * @user_id: the rss_context ID exposed to userspace over ethtool. |
---|
726 | 764 | * @rx_hash_udp_4tuple: UDP 4-tuple hashing enabled |
---|
727 | 765 | * @rx_hash_key: Toeplitz hash key for this RSS context |
---|
.. | .. |
---|
810 | 848 | * @timer_quantum_ns: Interrupt timer quantum, in nanoseconds |
---|
811 | 849 | * @timer_max_ns: Interrupt timer maximum value, in nanoseconds |
---|
812 | 850 | * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues |
---|
| 851 | + * @irqs_hooked: Channel interrupts are hooked |
---|
813 | 852 | * @irq_rx_mod_step_us: Step size for IRQ moderation for RX event queues |
---|
814 | 853 | * @irq_rx_moderation_us: IRQ moderation time for RX event queues |
---|
815 | 854 | * @msg_enable: Log message enable flags |
---|
.. | .. |
---|
821 | 860 | * @msi_context: Context for each MSI |
---|
822 | 861 | * @extra_channel_types: Types of extra (non-traffic) channels that |
---|
823 | 862 | * should be allocated for this NIC |
---|
| 863 | + * @xdp_tx_queue_count: Number of entries in %xdp_tx_queues. |
---|
| 864 | + * @xdp_tx_queues: Array of pointers to tx queues used for XDP transmit. |
---|
824 | 865 | * @rxq_entries: Size of receive queues requested by user. |
---|
825 | 866 | * @txq_entries: Size of transmit queues requested by user. |
---|
826 | 867 | * @txq_stop_thresh: TX queue fill level at or above which we stop it. |
---|
.. | .. |
---|
833 | 874 | * @n_rx_channels: Number of channels used for RX (= number of RX queues) |
---|
834 | 875 | * @n_tx_channels: Number of channels used for TX |
---|
835 | 876 | * @n_extra_tx_channels: Number of extra channels with TX queues |
---|
| 877 | + * @tx_queues_per_channel: number of TX queues probed on each channel |
---|
| 878 | + * @n_xdp_channels: Number of channels used for XDP TX |
---|
| 879 | + * @xdp_channel_offset: Offset of zeroth channel used for XPD TX. |
---|
| 880 | + * @xdp_tx_per_channel: Max number of TX queues on an XDP TX channel. |
---|
836 | 881 | * @rx_ip_align: RX DMA address offset to have IP header aligned in |
---|
837 | 882 | * in accordance with NET_IP_ALIGN |
---|
838 | 883 | * @rx_dma_len: Current maximum RX DMA length |
---|
.. | .. |
---|
850 | 895 | * @rss_context: Main RSS context. Its @list member is the head of the list of |
---|
851 | 896 | * RSS contexts created by user requests |
---|
852 | 897 | * @rss_lock: Protects custom RSS context software state in @rss_context.list |
---|
| 898 | + * @vport_id: The function's vport ID, only relevant for PFs |
---|
853 | 899 | * @int_error_count: Number of internal errors seen recently |
---|
854 | 900 | * @int_error_expire: Time at which error count will be expired |
---|
| 901 | + * @must_realloc_vis: Flag: VIs have yet to be reallocated after MC reboot |
---|
855 | 902 | * @irq_soft_enabled: Are IRQs soft-enabled? If not, IRQ handler will |
---|
856 | 903 | * acknowledge but do nothing else. |
---|
857 | 904 | * @irq_status: Interrupt status buffer |
---|
.. | .. |
---|
875 | 922 | * field of %MC_CMD_GET_CAPABILITIES_V4 response, or %MC_CMD_MAC_NSTATS) |
---|
876 | 923 | * @stats_buffer: DMA buffer for statistics |
---|
877 | 924 | * @phy_type: PHY type |
---|
878 | | - * @phy_op: PHY interface |
---|
879 | 925 | * @phy_data: PHY private data (including PHY-specific stats) |
---|
880 | 926 | * @mdio: PHY MDIO interface |
---|
881 | 927 | * @mdio_bus: PHY MDIO bus ID (only used by Siena) |
---|
.. | .. |
---|
897 | 943 | * @loopback_mode: Loopback status |
---|
898 | 944 | * @loopback_modes: Supported loopback mode bitmask |
---|
899 | 945 | * @loopback_selftest: Offline self-test private state |
---|
| 946 | + * @xdp_prog: Current XDP programme for this interface |
---|
900 | 947 | * @filter_sem: Filter table rw_semaphore, protects existence of @filter_state |
---|
901 | 948 | * @filter_state: Architecture-dependent filter table state |
---|
902 | 949 | * @rps_mutex: Protects RPS state of all channels |
---|
903 | | - * @rps_expire_channel: Next channel to check for expiry |
---|
904 | | - * @rps_expire_index: Next index to check for expiry in |
---|
905 | | - * @rps_expire_channel's @rps_flow_id |
---|
906 | 950 | * @rps_slot_map: bitmap of in-flight entries in @rps_slot |
---|
907 | 951 | * @rps_slot: array of ARFS insertion requests for efx_filter_rfs_work() |
---|
908 | 952 | * @rps_hash_lock: Protects ARFS filter mapping state (@rps_hash_table and |
---|
.. | .. |
---|
922 | 966 | * @ptp_data: PTP state data |
---|
923 | 967 | * @ptp_warned: has this NIC seen and warned about unexpected PTP events? |
---|
924 | 968 | * @vpd_sn: Serial number read from VPD |
---|
| 969 | + * @xdp_rxq_info_failed: Have any of the rx queues failed to initialise their |
---|
| 970 | + * xdp_rxq_info structures? |
---|
| 971 | + * @netdev_notifier: Netdevice notifier. |
---|
| 972 | + * @mem_bar: The BAR that is mapped into membase. |
---|
| 973 | + * @reg_base: Offset from the start of the bar to the function control window. |
---|
925 | 974 | * @monitor_work: Hardware monitor workitem |
---|
926 | 975 | * @biu_lock: BIU (bus interface unit) lock |
---|
927 | 976 | * @last_irq_cpu: Last CPU to handle a possible test interrupt. This |
---|
.. | .. |
---|
957 | 1006 | unsigned int timer_quantum_ns; |
---|
958 | 1007 | unsigned int timer_max_ns; |
---|
959 | 1008 | bool irq_rx_adaptive; |
---|
| 1009 | + bool irqs_hooked; |
---|
960 | 1010 | unsigned int irq_mod_step_us; |
---|
961 | 1011 | unsigned int irq_rx_moderation_us; |
---|
962 | 1012 | u32 msg_enable; |
---|
.. | .. |
---|
969 | 1019 | const struct efx_channel_type * |
---|
970 | 1020 | extra_channel_type[EFX_MAX_EXTRA_CHANNELS]; |
---|
971 | 1021 | |
---|
| 1022 | + unsigned int xdp_tx_queue_count; |
---|
| 1023 | + struct efx_tx_queue **xdp_tx_queues; |
---|
| 1024 | + |
---|
972 | 1025 | unsigned rxq_entries; |
---|
973 | 1026 | unsigned txq_entries; |
---|
974 | 1027 | unsigned int txq_stop_thresh; |
---|
.. | .. |
---|
980 | 1033 | unsigned next_buffer_table; |
---|
981 | 1034 | |
---|
982 | 1035 | unsigned int max_channels; |
---|
| 1036 | + unsigned int max_vis; |
---|
983 | 1037 | unsigned int max_tx_channels; |
---|
984 | 1038 | unsigned n_channels; |
---|
985 | 1039 | unsigned n_rx_channels; |
---|
.. | .. |
---|
987 | 1041 | unsigned tx_channel_offset; |
---|
988 | 1042 | unsigned n_tx_channels; |
---|
989 | 1043 | unsigned n_extra_tx_channels; |
---|
| 1044 | + unsigned int tx_queues_per_channel; |
---|
| 1045 | + unsigned int n_xdp_channels; |
---|
| 1046 | + unsigned int xdp_channel_offset; |
---|
| 1047 | + unsigned int xdp_tx_per_channel; |
---|
990 | 1048 | unsigned int rx_ip_align; |
---|
991 | 1049 | unsigned int rx_dma_len; |
---|
992 | 1050 | unsigned int rx_buffer_order; |
---|
.. | .. |
---|
1001 | 1059 | bool rx_scatter; |
---|
1002 | 1060 | struct efx_rss_context rss_context; |
---|
1003 | 1061 | struct mutex rss_lock; |
---|
| 1062 | + u32 vport_id; |
---|
1004 | 1063 | |
---|
1005 | 1064 | unsigned int_error_count; |
---|
1006 | 1065 | unsigned long int_error_expire; |
---|
1007 | 1066 | |
---|
| 1067 | + bool must_realloc_vis; |
---|
1008 | 1068 | bool irq_soft_enabled; |
---|
1009 | 1069 | struct efx_buffer irq_status; |
---|
1010 | 1070 | unsigned irq_zero_count; |
---|
.. | .. |
---|
1035 | 1095 | bool rx_nodesc_drops_prev_state; |
---|
1036 | 1096 | |
---|
1037 | 1097 | unsigned int phy_type; |
---|
1038 | | - const struct efx_phy_operations *phy_op; |
---|
1039 | 1098 | void *phy_data; |
---|
1040 | 1099 | struct mdio_if_info mdio; |
---|
1041 | 1100 | unsigned int mdio_bus; |
---|
.. | .. |
---|
1056 | 1115 | u64 loopback_modes; |
---|
1057 | 1116 | |
---|
1058 | 1117 | void *loopback_selftest; |
---|
| 1118 | + /* We access loopback_selftest immediately before running XDP, |
---|
| 1119 | + * so we want them next to each other. |
---|
| 1120 | + */ |
---|
| 1121 | + struct bpf_prog __rcu *xdp_prog; |
---|
1059 | 1122 | |
---|
1060 | 1123 | struct rw_semaphore filter_sem; |
---|
1061 | 1124 | void *filter_state; |
---|
1062 | 1125 | #ifdef CONFIG_RFS_ACCEL |
---|
1063 | 1126 | struct mutex rps_mutex; |
---|
1064 | | - unsigned int rps_expire_channel; |
---|
1065 | | - unsigned int rps_expire_index; |
---|
1066 | 1127 | unsigned long rps_slot_map; |
---|
1067 | 1128 | struct efx_async_filter_insertion rps_slot[EFX_RPS_MAX_IN_FLIGHT]; |
---|
1068 | 1129 | spinlock_t rps_hash_lock; |
---|
.. | .. |
---|
1085 | 1146 | bool ptp_warned; |
---|
1086 | 1147 | |
---|
1087 | 1148 | char *vpd_sn; |
---|
| 1149 | + bool xdp_rxq_info_failed; |
---|
| 1150 | + |
---|
| 1151 | + struct notifier_block netdev_notifier; |
---|
| 1152 | + |
---|
| 1153 | + unsigned int mem_bar; |
---|
| 1154 | + u32 reg_base; |
---|
1088 | 1155 | |
---|
1089 | 1156 | /* The following fields may be written more often */ |
---|
1090 | 1157 | |
---|
.. | .. |
---|
1114 | 1181 | }; |
---|
1115 | 1182 | |
---|
1116 | 1183 | struct efx_udp_tunnel { |
---|
| 1184 | +#define TUNNEL_ENCAP_UDP_PORT_ENTRY_INVALID 0xffff |
---|
1117 | 1185 | u16 type; /* TUNNEL_ENCAP_UDP_PORT_ENTRY_foo, see mcdi_pcol.h */ |
---|
1118 | 1186 | __be16 port; |
---|
1119 | | - /* Count of repeated adds of the same port. Used only inside the list, |
---|
1120 | | - * not in request arguments. |
---|
1121 | | - */ |
---|
1122 | | - u16 count; |
---|
1123 | 1187 | }; |
---|
1124 | 1188 | |
---|
1125 | 1189 | /** |
---|
.. | .. |
---|
1150 | 1214 | * @describe_stats: Describe statistics for ethtool |
---|
1151 | 1215 | * @update_stats: Update statistics not provided by event handling. |
---|
1152 | 1216 | * Either argument may be %NULL. |
---|
| 1217 | + * @update_stats_atomic: Update statistics while in atomic context, if that |
---|
| 1218 | + * is more limiting than @update_stats. Otherwise, leave %NULL and |
---|
| 1219 | + * driver core will call @update_stats. |
---|
1153 | 1220 | * @start_stats: Start the regular fetching of statistics |
---|
1154 | 1221 | * @pull_stats: Pull stats from the NIC and wait until they arrive. |
---|
1155 | 1222 | * @stop_stats: Stop the regular fetching of statistics |
---|
1156 | | - * @set_id_led: Set state of identifying LED or revert to automatic function |
---|
1157 | 1223 | * @push_irq_moderation: Apply interrupt moderation value |
---|
1158 | 1224 | * @reconfigure_port: Push loopback/power/txdis changes to the MAC and PHY |
---|
1159 | 1225 | * @prepare_enable_fc_tx: Prepare MAC to enable pause frame TX (may be %NULL) |
---|
.. | .. |
---|
1186 | 1252 | * a pointer to the &struct efx_msi_context for the channel. |
---|
1187 | 1253 | * @irq_handle_legacy: Handle legacy interrupt. The @dev_id argument |
---|
1188 | 1254 | * is a pointer to the &struct efx_nic. |
---|
1189 | | - * @tx_probe: Allocate resources for TX queue |
---|
| 1255 | + * @tx_probe: Allocate resources for TX queue (and select TXQ type) |
---|
1190 | 1256 | * @tx_init: Initialise TX queue on the NIC |
---|
1191 | 1257 | * @tx_remove: Free resources for TX queue |
---|
1192 | 1258 | * @tx_write: Write TX descriptors and doorbell |
---|
| 1259 | + * @tx_enqueue: Add an SKB to TX queue |
---|
1193 | 1260 | * @rx_push_rss_config: Write RSS hash key and indirection table to the NIC |
---|
1194 | 1261 | * @rx_pull_rss_config: Read RSS hash key and indirection table back from the NIC |
---|
1195 | 1262 | * @rx_push_rss_context_config: Write RSS hash key and indirection table for |
---|
.. | .. |
---|
1201 | 1268 | * @rx_remove: Free resources for RX queue |
---|
1202 | 1269 | * @rx_write: Write RX descriptors and doorbell |
---|
1203 | 1270 | * @rx_defer_refill: Generate a refill reminder event |
---|
| 1271 | + * @rx_packet: Receive the queued RX buffer on a channel |
---|
| 1272 | + * @rx_buf_hash_valid: Determine whether the RX prefix contains a valid hash |
---|
1204 | 1273 | * @ev_probe: Allocate resources for event queue |
---|
1205 | 1274 | * @ev_init: Initialise event queue on the NIC |
---|
1206 | 1275 | * @ev_fini: Deinitialise event queue on the NIC |
---|
.. | .. |
---|
1243 | 1312 | * @tso_versions: Returns mask of firmware-assisted TSO versions supported. |
---|
1244 | 1313 | * If %NULL, then device does not support any TSO version. |
---|
1245 | 1314 | * @udp_tnl_push_ports: Push the list of UDP tunnel ports to the NIC if required. |
---|
1246 | | - * @udp_tnl_add_port: Add a UDP tunnel port |
---|
1247 | 1315 | * @udp_tnl_has_port: Check if a port has been added as UDP tunnel |
---|
1248 | | - * @udp_tnl_del_port: Remove a UDP tunnel port |
---|
| 1316 | + * @print_additional_fwver: Dump NIC-specific additional FW version info |
---|
| 1317 | + * @sensor_event: Handle a sensor event from MCDI |
---|
1249 | 1318 | * @revision: Hardware architecture revision |
---|
1250 | 1319 | * @txd_ptr_tbl_base: TX descriptor ring base address |
---|
1251 | 1320 | * @rxd_ptr_tbl_base: RX descriptor ring base address |
---|
.. | .. |
---|
1261 | 1330 | * @always_rx_scatter: NIC will always scatter packets to multiple buffers |
---|
1262 | 1331 | * @option_descriptors: NIC supports TX option descriptors |
---|
1263 | 1332 | * @min_interrupt_mode: Lowest capability interrupt mode supported |
---|
1264 | | - * from &enum efx_int_mode. |
---|
1265 | | - * @max_interrupt_mode: Highest capability interrupt mode supported |
---|
1266 | 1333 | * from &enum efx_int_mode. |
---|
1267 | 1334 | * @timer_period_max: Maximum period of interrupt timer (in ticks) |
---|
1268 | 1335 | * @offload_features: net_device feature flags for protocol offload |
---|
.. | .. |
---|
1294 | 1361 | size_t (*describe_stats)(struct efx_nic *efx, u8 *names); |
---|
1295 | 1362 | size_t (*update_stats)(struct efx_nic *efx, u64 *full_stats, |
---|
1296 | 1363 | struct rtnl_link_stats64 *core_stats); |
---|
| 1364 | + size_t (*update_stats_atomic)(struct efx_nic *efx, u64 *full_stats, |
---|
| 1365 | + struct rtnl_link_stats64 *core_stats); |
---|
1297 | 1366 | void (*start_stats)(struct efx_nic *efx); |
---|
1298 | 1367 | void (*pull_stats)(struct efx_nic *efx); |
---|
1299 | 1368 | void (*stop_stats)(struct efx_nic *efx); |
---|
1300 | | - void (*set_id_led)(struct efx_nic *efx, enum efx_led_mode mode); |
---|
1301 | 1369 | void (*push_irq_moderation)(struct efx_channel *channel); |
---|
1302 | 1370 | int (*reconfigure_port)(struct efx_nic *efx); |
---|
1303 | 1371 | void (*prepare_enable_fc_tx)(struct efx_nic *efx); |
---|
1304 | | - int (*reconfigure_mac)(struct efx_nic *efx); |
---|
| 1372 | + int (*reconfigure_mac)(struct efx_nic *efx, bool mtu_only); |
---|
1305 | 1373 | bool (*check_mac_fault)(struct efx_nic *efx); |
---|
1306 | 1374 | void (*get_wol)(struct efx_nic *efx, struct ethtool_wolinfo *wol); |
---|
1307 | 1375 | int (*set_wol)(struct efx_nic *efx, u32 type); |
---|
1308 | 1376 | void (*resume_wol)(struct efx_nic *efx); |
---|
| 1377 | + unsigned int (*check_caps)(const struct efx_nic *efx, |
---|
| 1378 | + u8 flag, |
---|
| 1379 | + u32 offset); |
---|
1309 | 1380 | int (*test_chip)(struct efx_nic *efx, struct efx_self_tests *tests); |
---|
1310 | 1381 | int (*test_nvram)(struct efx_nic *efx); |
---|
1311 | 1382 | void (*mcdi_request)(struct efx_nic *efx, |
---|
.. | .. |
---|
1325 | 1396 | void (*tx_init)(struct efx_tx_queue *tx_queue); |
---|
1326 | 1397 | void (*tx_remove)(struct efx_tx_queue *tx_queue); |
---|
1327 | 1398 | void (*tx_write)(struct efx_tx_queue *tx_queue); |
---|
| 1399 | + netdev_tx_t (*tx_enqueue)(struct efx_tx_queue *tx_queue, struct sk_buff *skb); |
---|
1328 | 1400 | unsigned int (*tx_limit_len)(struct efx_tx_queue *tx_queue, |
---|
1329 | 1401 | dma_addr_t dma_addr, unsigned int len); |
---|
1330 | 1402 | int (*rx_push_rss_config)(struct efx_nic *efx, bool user, |
---|
.. | .. |
---|
1342 | 1414 | void (*rx_remove)(struct efx_rx_queue *rx_queue); |
---|
1343 | 1415 | void (*rx_write)(struct efx_rx_queue *rx_queue); |
---|
1344 | 1416 | void (*rx_defer_refill)(struct efx_rx_queue *rx_queue); |
---|
| 1417 | + void (*rx_packet)(struct efx_channel *channel); |
---|
| 1418 | + bool (*rx_buf_hash_valid)(const u8 *prefix); |
---|
1345 | 1419 | int (*ev_probe)(struct efx_channel *channel); |
---|
1346 | 1420 | int (*ev_init)(struct efx_channel *channel); |
---|
1347 | 1421 | void (*ev_fini)(struct efx_channel *channel); |
---|
.. | .. |
---|
1413 | 1487 | int (*set_mac_address)(struct efx_nic *efx); |
---|
1414 | 1488 | u32 (*tso_versions)(struct efx_nic *efx); |
---|
1415 | 1489 | int (*udp_tnl_push_ports)(struct efx_nic *efx); |
---|
1416 | | - int (*udp_tnl_add_port)(struct efx_nic *efx, struct efx_udp_tunnel tnl); |
---|
1417 | 1490 | bool (*udp_tnl_has_port)(struct efx_nic *efx, __be16 port); |
---|
1418 | | - int (*udp_tnl_del_port)(struct efx_nic *efx, struct efx_udp_tunnel tnl); |
---|
| 1491 | + size_t (*print_additional_fwver)(struct efx_nic *efx, char *buf, |
---|
| 1492 | + size_t len); |
---|
| 1493 | + void (*sensor_event)(struct efx_nic *efx, efx_qword_t *ev); |
---|
1419 | 1494 | |
---|
1420 | 1495 | int revision; |
---|
1421 | 1496 | unsigned int txd_ptr_tbl_base; |
---|
.. | .. |
---|
1432 | 1507 | bool always_rx_scatter; |
---|
1433 | 1508 | bool option_descriptors; |
---|
1434 | 1509 | unsigned int min_interrupt_mode; |
---|
1435 | | - unsigned int max_interrupt_mode; |
---|
1436 | 1510 | unsigned int timer_period_max; |
---|
1437 | 1511 | netdev_features_t offload_features; |
---|
1438 | 1512 | int mcdi_max_ver; |
---|
.. | .. |
---|
1468 | 1542 | _channel = _channel->channel ? \ |
---|
1469 | 1543 | (_efx)->channel[_channel->channel - 1] : NULL) |
---|
1470 | 1544 | |
---|
1471 | | -static inline struct efx_tx_queue * |
---|
1472 | | -efx_get_tx_queue(struct efx_nic *efx, unsigned index, unsigned type) |
---|
| 1545 | +static inline struct efx_channel * |
---|
| 1546 | +efx_get_tx_channel(struct efx_nic *efx, unsigned int index) |
---|
1473 | 1547 | { |
---|
1474 | | - EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_tx_channels || |
---|
1475 | | - type >= EFX_TXQ_TYPES); |
---|
1476 | | - return &efx->channel[efx->tx_channel_offset + index]->tx_queue[type]; |
---|
| 1548 | + EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_tx_channels); |
---|
| 1549 | + return efx->channel[efx->tx_channel_offset + index]; |
---|
| 1550 | +} |
---|
| 1551 | + |
---|
| 1552 | +static inline struct efx_channel * |
---|
| 1553 | +efx_get_xdp_channel(struct efx_nic *efx, unsigned int index) |
---|
| 1554 | +{ |
---|
| 1555 | + EFX_WARN_ON_ONCE_PARANOID(index >= efx->n_xdp_channels); |
---|
| 1556 | + return efx->channel[efx->xdp_channel_offset + index]; |
---|
| 1557 | +} |
---|
| 1558 | + |
---|
| 1559 | +static inline bool efx_channel_is_xdp_tx(struct efx_channel *channel) |
---|
| 1560 | +{ |
---|
| 1561 | + return channel->channel - channel->efx->xdp_channel_offset < |
---|
| 1562 | + channel->efx->n_xdp_channels; |
---|
1477 | 1563 | } |
---|
1478 | 1564 | |
---|
1479 | 1565 | static inline bool efx_channel_has_tx_queues(struct efx_channel *channel) |
---|
1480 | 1566 | { |
---|
1481 | | - return channel->type && channel->type->want_txqs && |
---|
1482 | | - channel->type->want_txqs(channel); |
---|
| 1567 | + return channel && channel->channel >= channel->efx->tx_channel_offset; |
---|
| 1568 | +} |
---|
| 1569 | + |
---|
| 1570 | +static inline unsigned int efx_channel_num_tx_queues(struct efx_channel *channel) |
---|
| 1571 | +{ |
---|
| 1572 | + if (efx_channel_is_xdp_tx(channel)) |
---|
| 1573 | + return channel->efx->xdp_tx_per_channel; |
---|
| 1574 | + return channel->efx->tx_queues_per_channel; |
---|
1483 | 1575 | } |
---|
1484 | 1576 | |
---|
1485 | 1577 | static inline struct efx_tx_queue * |
---|
1486 | | -efx_channel_get_tx_queue(struct efx_channel *channel, unsigned type) |
---|
| 1578 | +efx_channel_get_tx_queue(struct efx_channel *channel, unsigned int type) |
---|
1487 | 1579 | { |
---|
1488 | | - EFX_WARN_ON_ONCE_PARANOID(!efx_channel_has_tx_queues(channel) || |
---|
1489 | | - type >= EFX_TXQ_TYPES); |
---|
1490 | | - return &channel->tx_queue[type]; |
---|
| 1580 | + EFX_WARN_ON_ONCE_PARANOID(type >= EFX_TXQ_TYPES); |
---|
| 1581 | + return channel->tx_queue_by_type[type]; |
---|
1491 | 1582 | } |
---|
1492 | 1583 | |
---|
1493 | | -static inline bool efx_tx_queue_used(struct efx_tx_queue *tx_queue) |
---|
| 1584 | +static inline struct efx_tx_queue * |
---|
| 1585 | +efx_get_tx_queue(struct efx_nic *efx, unsigned int index, unsigned int type) |
---|
1494 | 1586 | { |
---|
1495 | | - return !(tx_queue->efx->net_dev->num_tc < 2 && |
---|
1496 | | - tx_queue->queue & EFX_TXQ_TYPE_HIGHPRI); |
---|
| 1587 | + struct efx_channel *channel = efx_get_tx_channel(efx, index); |
---|
| 1588 | + |
---|
| 1589 | + return efx_channel_get_tx_queue(channel, type); |
---|
1497 | 1590 | } |
---|
1498 | 1591 | |
---|
1499 | 1592 | /* Iterate over all TX queues belonging to a channel */ |
---|
.. | .. |
---|
1502 | 1595 | ; \ |
---|
1503 | 1596 | else \ |
---|
1504 | 1597 | for (_tx_queue = (_channel)->tx_queue; \ |
---|
1505 | | - _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES && \ |
---|
1506 | | - efx_tx_queue_used(_tx_queue); \ |
---|
1507 | | - _tx_queue++) |
---|
1508 | | - |
---|
1509 | | -/* Iterate over all possible TX queues belonging to a channel */ |
---|
1510 | | -#define efx_for_each_possible_channel_tx_queue(_tx_queue, _channel) \ |
---|
1511 | | - if (!efx_channel_has_tx_queues(_channel)) \ |
---|
1512 | | - ; \ |
---|
1513 | | - else \ |
---|
1514 | | - for (_tx_queue = (_channel)->tx_queue; \ |
---|
1515 | | - _tx_queue < (_channel)->tx_queue + EFX_TXQ_TYPES; \ |
---|
| 1598 | + _tx_queue < (_channel)->tx_queue + \ |
---|
| 1599 | + efx_channel_num_tx_queues(_channel); \ |
---|
1516 | 1600 | _tx_queue++) |
---|
1517 | 1601 | |
---|
1518 | 1602 | static inline bool efx_channel_has_rx_queue(struct efx_channel *channel) |
---|
.. | .. |
---|
1556 | 1640 | return &rx_queue->buffer[index]; |
---|
1557 | 1641 | } |
---|
1558 | 1642 | |
---|
| 1643 | +static inline struct efx_rx_buffer * |
---|
| 1644 | +efx_rx_buf_next(struct efx_rx_queue *rx_queue, struct efx_rx_buffer *rx_buf) |
---|
| 1645 | +{ |
---|
| 1646 | + if (unlikely(rx_buf == efx_rx_buffer(rx_queue, rx_queue->ptr_mask))) |
---|
| 1647 | + return efx_rx_buffer(rx_queue, 0); |
---|
| 1648 | + else |
---|
| 1649 | + return rx_buf + 1; |
---|
| 1650 | +} |
---|
| 1651 | + |
---|
1559 | 1652 | /** |
---|
1560 | 1653 | * EFX_MAX_FRAME_LEN - calculate maximum frame length |
---|
1561 | 1654 | * |
---|
.. | .. |
---|
1586 | 1679 | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; |
---|
1587 | 1680 | } |
---|
1588 | 1681 | |
---|
| 1682 | +/* Get the max fill level of the TX queues on this channel */ |
---|
| 1683 | +static inline unsigned int |
---|
| 1684 | +efx_channel_tx_fill_level(struct efx_channel *channel) |
---|
| 1685 | +{ |
---|
| 1686 | + struct efx_tx_queue *tx_queue; |
---|
| 1687 | + unsigned int fill_level = 0; |
---|
| 1688 | + |
---|
| 1689 | + efx_for_each_channel_tx_queue(tx_queue, channel) |
---|
| 1690 | + fill_level = max(fill_level, |
---|
| 1691 | + tx_queue->insert_count - tx_queue->read_count); |
---|
| 1692 | + |
---|
| 1693 | + return fill_level; |
---|
| 1694 | +} |
---|
| 1695 | + |
---|
| 1696 | +/* Conservative approximation of efx_channel_tx_fill_level using cached value */ |
---|
| 1697 | +static inline unsigned int |
---|
| 1698 | +efx_channel_tx_old_fill_level(struct efx_channel *channel) |
---|
| 1699 | +{ |
---|
| 1700 | + struct efx_tx_queue *tx_queue; |
---|
| 1701 | + unsigned int fill_level = 0; |
---|
| 1702 | + |
---|
| 1703 | + efx_for_each_channel_tx_queue(tx_queue, channel) |
---|
| 1704 | + fill_level = max(fill_level, |
---|
| 1705 | + tx_queue->insert_count - tx_queue->old_read_count); |
---|
| 1706 | + |
---|
| 1707 | + return fill_level; |
---|
| 1708 | +} |
---|
| 1709 | + |
---|
1589 | 1710 | /* Get all supported features. |
---|
1590 | 1711 | * If a feature is not fixed, it is present in hw_features. |
---|
1591 | 1712 | * If a feature is fixed, it does not present in hw_features, but |
---|