idpf: add XDP support
Subsystems (6)
Alexander Lobakin
maintainerv3 cover idpf: add XDP support
Add XDP support (w/o XSk for now) to the idpf driver using the libeth_xdp sublib. All possible verdicts, .ndo_xdp_xmit(), multi-buffer etc. are here. In general, nothing outstanding comparing to ice, except performance -- let's say, up to 2x for .ndo_xdp_xmit() on certain platforms and scenarios.
idpf doesn't support VLAN Rx offload, so only the hash hint is available for now.
Patches 1-6 are prereqs, without which XDP would either not work at all or work slower/worse/...
Alexander Lobakin (8):
idpf: fix Rx descriptor ready check barrier in splitq
idpf: use a saner limit for default number of queues to allocate
idpf: link NAPIs to queues
idpf: add support for nointerrupt queues
idpf: use generic functions to build xdp_buff and skb
idpf: add support for XDP on Rx
idpf: add support for .ndo_xdp_xmit()
idpf: add XDP RSS hash hint
Joshua Hay (6):
idpf: add support for Tx refillqs in flow scheduling mode
idpf: improve when to set RE bit logic
idpf: simplify and fix splitq Tx packet rollback error path
idpf: replace flow scheduling buffer ring with buffer pool
idpf: stop Tx if there are insufficient buffer resources
idpf: remove obsolete stashing code
Michal Kubiak (4):
idpf: add 4-byte completion descriptor definition
idpf: remove SW marker handling from NAPI
idpf: prepare structures to support XDP
idpf: implement XDP_SETUP_PROG in ndo_bpf for splitq
drivers/net/ethernet/intel/idpf/Kconfig | 2 +- drivers/net/ethernet/intel/idpf/Makefile | 2 + drivers/net/ethernet/intel/idpf/idpf.h | 31 +- .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 6 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 217 ++-- .../net/ethernet/intel/idpf/idpf_virtchnl.h | 1 - drivers/net/ethernet/intel/idpf/xdp.h | 172 +++ drivers/net/ethernet/intel/idpf/idpf_dev.c | 11 +- .../net/ethernet/intel/idpf/idpf_ethtool.c | 6 +- drivers/net/ethernet/intel/idpf/idpf_lib.c | 67 +- drivers/net/ethernet/intel/idpf/idpf_main.c | 1 + .../ethernet/intel/idpf/idpf_singleq_txrx.c | 171 ++- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1142 +++++++---------- drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 11 +- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 173 +-- drivers/net/ethernet/intel/idpf/xdp.c | 452 +++++++ 16 files changed, 1541 insertions(+), 924 deletions(-) create mode 100644 drivers/net/ethernet/intel/idpf/xdp.h create mode 100644 drivers/net/ethernet/intel/idpf/xdp.c
---
Sending to get reviews and to trigger Intel's validation.
Joshua's series[0] is included and goes first to resolve conflicts. It is *not* a part of the actual series.
From v2[1]:
* rebase on top of [0] to resolve conflicts in Tony's tree;
* 02:
* harmonize maximum number of queues to not create more Tx queues than
completion queues or more Rx queues than buffer queues / 2;
* fix VC timeouts on certain steppings as there processing a lot of queues
can take more time than the minimum timeout of 2 seconds;* 03: fix RTNL assertion fail on PCI reset.
From v1[2]:
* drop the libeth_xdp part (submitted separately and accepted);
* fix some typos and kdocs (Jakub, Maciej);
* pick a couple RBs (Maciej);
* 03: create a convenience helper (Maciej), fix rtnl assertion fail;
* 04: since XDP uses its own queue cleaning routines, don't add 4-byte
completion support to the skb code;
* 05: don't use old weird logic with negative descriptor index (Maciej);
* 06: fix invalid interrupt vector counting in certain cases;
* 07: fix cleanup timer is fired after the queue buffers are already freed;
* 08: fix XDP program removal in corner cases such as PCI reset or
remove request when there's no active prog (from netdev_unregister());
* 10: fix rare queue stuck -- HW requires to always have at least one free Tx descriptor on the queue, otherwise it thinks the queue is empty and there's nothing to send (true Intel HW veteran bug).
Testing hints: basic Rx and Tx (TCP, UDP, VLAN, HW GRO on/off, trafficgen stress tests, performance comparison); xdp-tools with all possible actions (xdp-bench for PASS, DROP, TX, REDIRECT to cpumap, devmap (inc self-redirect); xdp-trafficgen to double-check XDP xmit). Would be nice to see a perf comparison against ice (in percent) (idpf must be plugged into a PCIe 5.x).
[0] https://lore.kernel.org/intel-wired-lan/[email protected]
[1] https://lore.kernel.org/intel-wired-lan/[email protected]
[2] https://lore.kernel.org/intel-wired-lan/[email protected]
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 1/18 idpf: add support for Tx refillqs in flow scheduling mode
From: Joshua Hay <[email protected]>
In certain production environments, it is possible for completion tags to collide, meaning N packets with the same completion tag are in flight at the same time. In this environment, any given Tx queue is effectively used to send both slower traffic and higher throughput traffic simultaneously. This is the result of a customer's specific configuration in the device pipeline, the details of which Intel cannot provide. This configuration results in a small number of out-of-order completions, i.e., a small number of packets in flight. The existing guardrails in the driver only protect against a large number of packets in flight. The slower flow completions are delayed which causes the out-of-order completions. The fast flow will continue sending traffic and generating tags. Because tags are generated on the fly, the fast flow eventually uses the same tag for a packet that is still in flight from the slower flow. The driver has no idea which packet it should clean when it processes the completion with that tag, but it will look for the packet on the buffer ring before the hash table. If the slower flow packet completion is processed first, it will end up cleaning the fast flow packet on the ring prematurely. This leaves the descriptor ring in a bad state resulting in a crashes or Tx timeout.
In summary, generating a tag when a packet is sent can lead to the same tag being associated with multiple packets. This can lead to resource leaks, crashes, and/or Tx timeouts.
Before we can replace the tag generation, we need a new mechanism for the send path to know what tag to use next. The driver will allocate and initialize a refillq for each TxQ with all of the possible free tag values. During send, the driver grabs the next free tag from the refillq from next_to_clean. While cleaning the packet, the clean routine posts the tag back to the refillq's next_to_use to indicate that it is now free to use.
This mechanism works exactly the same way as the existing Rx refill queues, which post the cleaned buffer IDs back to the buffer queue to be reposted to HW. Since we're using the refillqs for both Rx and Tx now, genercize some of the existing refillq support.
Note: the refillqs will not be used yet. This is only demonstrating how they will be used to pass free tags back to the send path.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 8 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 93 +++++++++++++++++++-- 2 files changed, 91 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +5 -3
@@ -108,8 +108,8 @@ do { \*/ #define IDPF_TX_SPLITQ_RE_MIN_GAP 64 -#define IDPF_RX_BI_GEN_M BIT(16) -#define IDPF_RX_BI_BUFID_M GENMASK(15, 0) +#define IDPF_RFL_BI_GEN_M BIT(16) +#define IDPF_RFL_BI_BUFID_M GENMASK(15, 0)#define IDPF_RXD_EOF_SPLITQ VIRTCHNL2_RX_FLEX_DESC_ADV_STATUS0_EOF_M#define IDPF_RXD_EOF_SINGLEQ VIRTCHNL2_RX_BASE_DESC_STATUS_EOF_M
@@ -622,6 +622,7 @@ libeth_cacheline_set_assert(struct idpf_rx_queue, 64,* @cleaned_pkts: Number of packets cleaned for the above said case * @tx_max_bufs: Max buffers that can be transmitted with scatter-gather * @stash: Tx buffer stash for Flow-based scheduling mode +* @refillq: Pointer to refill queue * @compl_tag_bufid_m: Completion tag buffer id mask * @compl_tag_cur_gen: Used to keep track of current completion tag generation * @compl_tag_gen_max: To determine when compl_tag_cur_gen should be reset
@@ -671,6 +672,7 @@ struct idpf_tx_queue {u16 tx_max_bufs;struct idpf_txq_stash *stash; +struct idpf_sw_queue *refillq;u16 compl_tag_bufid_m;u16 compl_tag_cur_gen;
@@ -692,7 +694,7 @@ struct idpf_tx_queue {__cacheline_group_end_aligned (cold); }; libeth_cacheline_set_assert(struct idpf_tx_queue, 64, -112 +sizeof (struct u64_stats_sync ), +120 +sizeof (struct u64_stats_sync ), 24);/**
drivers/net/ethernet/intel/idpf/idpf_txrx.c +86 -7
169 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 2/18 idpf: improve when to set RE bit logic
In reply to Alexander LobakinFrom: Joshua Hay <[email protected]>
Track the gap between next_to_use and the last RE index. Set RE again if the gap is large enough to ensure RE bit is set frequently. This is critical before removing the stashing mechanisms because the opportunistic descriptor ring cleaning from the out-of-order completions will go away. Previously the descriptors would be "cleaned" by both the descriptor (RE) completion and the out-of-order completions. Without the latter, we must ensure the RE bit is set more frequently. Otherwise, it's theoretically possible for the descriptor ring next_to_clean to never advance. The previous implementation was dependent on the start of a packet falling on a 64th index in the descriptor ring, which is not guaranteed with large packets.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 6 ++++-- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +4 -2
@@ -610,6 +610,8 @@ libeth_cacheline_set_assert(struct idpf_rx_queue, 64,* @netdev: &net_device corresponding to this queue * @next_to_use: Next descriptor to use * @next_to_clean: Next descriptor to clean +* @last_re: last descriptor index that RE bit was set +* @tx_max_bufs: Max buffers that can be transmitted with scatter-gather * @cleaned_bytes: Splitq only, TXQ only: When a TX completion is received on * the TX completion queue, it can be for any TXQ associated * with that completion queue. This means we can clean up to
@@ -620,7 +622,6 @@ libeth_cacheline_set_assert(struct idpf_rx_queue, 64,* only once at the end of the cleaning routine. * @clean_budget: singleq only, queue cleaning budget * @cleaned_pkts: Number of packets cleaned for the above said case -* @tx_max_bufs: Max buffers that can be transmitted with scatter-gather * @stash: Tx buffer stash for Flow-based scheduling mode * @refillq: Pointer to refill queue * @compl_tag_bufid_m: Completion tag buffer id mask
@@ -663,6 +664,8 @@ struct idpf_tx_queue {__cacheline_group_begin_aligned (read_write);u16 next_to_use;u16 next_to_clean; +u16 last_re; +u16 tx_max_bufs;union {u32 cleaned_bytes;
@@ -670,7 +673,6 @@ struct idpf_tx_queue { };u16 cleaned_pkts; -u16 tx_max_bufs;struct idpf_txq_stash *stash;struct idpf_sw_queue *refillq;
drivers/net/ethernet/intel/idpf/idpf_txrx.c +19 -1
@@ -294,6 +294,8 @@ static int idpf_tx_desc_alloc(const struct idpf_vport *vport,*/ idpf_queue_change (GEN_CHK , refillq); + tx_q->last_re = tx_q->desc_count -IDPF_TX_SPLITQ_RE_MIN_GAP ; +return 0 ; err_alloc:
@@ -2912,6 +2914,21 @@ static void idpf_tx_set_tstamp_desc(union idpf_flex_tx_ctx_desc *ctx_desc, { }#endif /* CONFIG_PTP_1588_CLOCK */ +/** +* idpf_tx_splitq_need_re - check whether RE bit needs to be set +* @tx_q: pointer to Tx queue +* +* Return: true if RE bit needs to be set, false otherwise +*/ +static bool idpf_tx_splitq_need_re (struct idpf_tx_queue *tx_q) +{ +int gap = tx_q->next_to_use - tx_q->last_re; + + gap += (gap <0 ) ? tx_q->desc_count :0 ; + +return gap >=IDPF_TX_SPLITQ_RE_MIN_GAP ; +} +/** * idpf_tx_splitq_frame - Sends buffer on Tx ring using flex descriptors * @skb: send buffer
@@ -2998,9 +3015,10 @@ static netdev_tx_t idpf_tx_splitq_frame(struct sk_buff *skb,* MIN_RING size to ensure it will be set at least once each * time around the ring. */ -if (!(tx_q->next_to_use %IDPF_TX_SPLITQ_RE_MIN_GAP )) { +if (idpf_tx_splitq_need_re (tx_q)) { tx_params.eop_cmd |=IDPF_TXD_FLEX_FLOW_CMD_RE ; tx_q->txq_grp->num_completions_pending++; + tx_q->last_re = tx_q->next_to_use; }if (skb->ip_summed ==CHECKSUM_PARTIAL )
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 3/18 idpf: simplify and fix splitq Tx packet rollback error path
In reply to Alexander LobakinFrom: Joshua Hay <[email protected]>
Move (and rename) the existing rollback logic to singleq.c since that will be the only consumer. Create a simplified splitq specific rollback function to loop through and unmap tx_bufs based on the completion tag. This is critical before replacing the Tx buffer ring with the buffer pool since the previous rollback indexing will not work to unmap the chained buffers from the pool.
Cache the next_to_use index before any portion of the packet is put on the descriptor ring. In case of an error, the rollback will bump tail to the correct next_to_use value. Because the splitq path now supports different types of context descriptors (and potentially multiple in the future), this will take care of rolling back any and all context descriptors encoded on the ring for the erroneous packet. The previous rollback logic was broken for PTP packets since it would not account for the PTP context descriptor.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 5 +- .../ethernet/intel/idpf/idpf_singleq_txrx.c | 57 +++++++++++- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 91 ++++++++----------- 3 files changed, 95 insertions(+), 58 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +3 -2
@@ -196,6 +196,7 @@ struct idpf_tx_offload_params {* @compl_tag: Associated tag for completion * @td_tag: Descriptor tunneling tag * @offload: Offload parameters +* @prev_ntu: stored TxQ next_to_use in case of rollback */ struct idpf_tx_splitq_params {enum idpf_tx_desc_dtype_value dtype;
@@ -206,6 +207,8 @@ struct idpf_tx_splitq_params { };struct idpf_tx_offload_params offload; + +u16 prev_ntu; };enum idpf_tx_ctx_desc_eipt_offload {
@@ -1042,8 +1045,6 @@ void idpf_tx_buf_hw_update(struct idpf_tx_queue *tx_q, u32 val, bool xmit_more);unsigned int idpf_size_to_txd_count (unsigned int size);netdev_tx_t idpf_tx_drop_skb (struct idpf_tx_queue *tx_q,struct sk_buff *skb); -void idpf_tx_dma_map_error (struct idpf_tx_queue *txq,struct sk_buff *skb, -struct idpf_tx_buf *first,u16 ring_idx);unsigned int idpf_tx_desc_count_required (struct idpf_tx_queue *txq,struct sk_buff *skb);void idpf_tx_timeout (struct net_device *netdev,unsigned int txqueue);
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c +55 -2
69 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.c +37 -54
115 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 4/18 idpf: replace flow scheduling buffer ring with buffer pool
In reply to Alexander LobakinFrom: Joshua Hay <[email protected]>
Replace the TxQ buffer ring with one large pool/array of buffers (only for flow scheduling). This eliminates the tag generation and makes it impossible for a tag to be associated with more than one packet.
The completion tag passed to HW through the descriptor is the index into the array. That same completion tag is posted back to the driver in the completion descriptor, and used to index into the array to quickly retrieve the buffer during cleaning. In this way, the tags are treated as a fix sized resource. If all tags are in use, no more packets can be sent on that particular queue (until some are freed up). The tag pool size is 64K since the completion tag width is 16 bits.
For each packet, the driver pulls a free tag from the refillq to get the next free buffer index. When cleaning is complete, the tag is posted back to the refillq. A multi-frag packet spans multiple buffers in the driver, therefore it uses multiple buffer indexes/tags from the pool. Each frag pulls from the refillq to get the next free buffer index. These are tracked in a next_buf field that replaces the completion tag field in the buffer struct. This chains the buffers together so that the packet can be cleaned from the starting completion tag taken from the completion descriptor, then from the next_buf field for each subsequent buffer.
In case of a dma_mapping_error occurs or the refillq runs out of free buf_ids, the packet will execute the rollback error path. This unmaps any buffers previously mapped for the packet. Since several free buf_ids could have already been pulled from the refillq, we need to restore its original state as well. Otherwise, the buf_ids/tags will be leaked and not used again until the queue is reallocated.
Descriptor completions only advance the descriptor ring index to "clean" the descriptors. The packet completions only clean the buffers associated with the given packet completion tag and do not update the descriptor ring index.
When operating in queue based scheduling mode, the array still acts as a ring and will only have TxQ descriptor count entries. The tx_bufs are still associated 1:1 with the descriptor ring entries and we can use the conventional indexing mechanisms.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 10 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 203 +++++++++----------- 2 files changed, 102 insertions(+), 111 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +9 -1
@@ -137,6 +137,8 @@ do { \ ((++(txq)->compl_tag_cur_gen) >= (txq)->compl_tag_gen_max ? \ 0 : (txq)->compl_tag_cur_gen) +#define IDPF_TXBUF_NULL U32_MAX +#define IDPF_TXD_LAST_DESC_CMD (IDPF_TX_DESC_CMD_EOP | IDPF_TX_DESC_CMD_RS)#define IDPF_TX_FLAGS_TSO BIT(0)
@@ -197,6 +199,8 @@ struct idpf_tx_offload_params {* @td_tag: Descriptor tunneling tag * @offload: Offload parameters * @prev_ntu: stored TxQ next_to_use in case of rollback +* @prev_refill_ntc: stored refillq next_to_clean in case of packet rollback +* @prev_refill_gen: stored refillq generation bit in case of packet rollback */ struct idpf_tx_splitq_params {enum idpf_tx_desc_dtype_value dtype;
@@ -209,6 +213,8 @@ struct idpf_tx_splitq_params {struct idpf_tx_offload_params offload;u16 prev_ntu; +u16 prev_refill_ntc; +bool prev_refill_gen; };enum idpf_tx_ctx_desc_eipt_offload {
@@ -638,6 +644,7 @@ libeth_cacheline_set_assert(struct idpf_rx_queue, 64,* @size: Length of descriptor ring in bytes * @dma: Physical address of ring * @q_vector: Backreference to associated vector +* @buf_pool_size: Total number of idpf_tx_buf */ struct idpf_tx_queue {__cacheline_group_begin_aligned (read_mostly);
@@ -696,11 +703,12 @@ struct idpf_tx_queue {dma_addr_t dma;struct idpf_q_vector *q_vector; +u32 buf_pool_size;__cacheline_group_end_aligned (cold); }; libeth_cacheline_set_assert(struct idpf_tx_queue, 64,120 +sizeof (struct u64_stats_sync ), - 24); + 32);/** * struct idpf_buf_queue - software structure representing a buffer queue
drivers/net/ethernet/intel/idpf/idpf_txrx.c +93 -110
390 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 5/18 idpf: stop Tx if there are insufficient buffer resources
In reply to Alexander LobakinFrom: Joshua Hay <[email protected]>
The Tx refillq logic will cause packets to be silently dropped if there are not enough buffer resources available to send a packet in flow scheduling mode. Instead, determine how many buffers are needed along with number of descriptors. Make sure there are enough of both resources to send the packet, and stop the queue if not.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 15 +++++- .../ethernet/intel/idpf/idpf_singleq_txrx.c | 4 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 47 +++++++++++++------ 3 files changed, 47 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +13 -2
@@ -1026,6 +1026,17 @@ static inline void idpf_vport_intr_set_wb_on_itr(struct idpf_q_vector *q_vector) reg->dyn_ctl); } +/** +* idpf_tx_splitq_get_free_bufs - get number of free buf_ids in refillq +* @refillq: pointer to refillq containing buf_ids +*/ +static inline u32 idpf_tx_splitq_get_free_bufs (struct idpf_sw_queue *refillq) +{ +return (refillq->next_to_use > refillq->next_to_clean ? +0 : refillq->desc_count) + + refillq->next_to_use - refillq->next_to_clean -1 ; +} +int idpf_vport_singleq_napi_poll (struct napi_struct *napi,int budget);void idpf_vport_init_num_qs (struct idpf_vport *vport,struct virtchnl2_create_vport *vport_msg);
@@ -1053,8 +1064,8 @@ void idpf_tx_buf_hw_update(struct idpf_tx_queue *tx_q, u32 val, bool xmit_more);unsigned int idpf_size_to_txd_count (unsigned int size);netdev_tx_t idpf_tx_drop_skb (struct idpf_tx_queue *tx_q,struct sk_buff *skb); -unsigned int idpf_tx_desc_count_required (struct idpf_tx_queue *txq, -struct sk_buff *skb); +unsigned int idpf_tx_res_count_required (struct idpf_tx_queue *txq, +struct sk_buff *skb,u32 *buf_count);void idpf_tx_timeout (struct net_device *netdev,unsigned int txqueue);netdev_tx_t idpf_tx_singleq_frame (struct sk_buff *skb,struct idpf_tx_queue *tx_q);
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c +2 -2
@@ -415,11 +415,11 @@ netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb, {struct idpf_tx_offload_params offload = { };struct idpf_tx_buf *first; +u32 count, buf_count =1 ;int csum, tso, needed; -unsigned int count;__be16 protocol; - count =idpf_tx_desc_count_required (tx_q, skb); + count =idpf_tx_res_count_required (tx_q, skb, &buf_count);if (unlikely (!count))return idpf_tx_drop_skb (tx_q, skb);
drivers/net/ethernet/intel/idpf/idpf_txrx.c +32 -15
99 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 6/18 idpf: remove obsolete stashing code
In reply to Alexander LobakinFrom: Joshua Hay <[email protected]>
With the new Tx buffer management scheme, there is no need for all of the stashing mechanisms, the hash table, the reserve buffer stack, etc. Remove all of that.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 47 +-- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 314 ++------------------ 2 files changed, 22 insertions(+), 339 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +1 -46
@@ -118,10 +118,6 @@ do { \ ((((txq)->next_to_clean > (txq)->next_to_use) ?0 : (txq)->desc_count) + \ (txq)->next_to_clean - (txq)->next_to_use - 1) -#define IDPF_TX_BUF_RSV_UNUSED (txq) ((txq)->stash->buf_stack.top) -#define IDPF_TX_BUF_RSV_LOW (txq) (IDPF_TX_BUF_RSV_UNUSED(txq) < \ - (txq)->desc_count >> 2) -#define IDPF_TX_COMPLQ_OVERFLOW_THRESH (txcq) ((txcq)->desc_count >> 1)/* Determine the absolute number of completions pending, i.e. the number of * completions that are expected to arrive on the TX completion queue.
@@ -131,12 +127,6 @@ do { \ 0 : U32_MAX) + \ (txq)->num_completions_pending - (txq)->complq->num_completions) -#define IDPF_TX_SPLITQ_COMPL_TAG_WIDTH 16 -/* Adjust the generation for the completion tag and wrap if necessary */ -#define IDPF_TX_ADJ_COMPL_TAG_GEN (txq) \ - ((++(txq)->compl_tag_cur_gen) >= (txq)->compl_tag_gen_max ? \ - 0 : (txq)->compl_tag_cur_gen) -#define IDPF_TXBUF_NULL U32_MAX#define IDPF_TXD_LAST_DESC_CMD (IDPF_TX_DESC_CMD_EOP | IDPF_TX_DESC_CMD_RS)
@@ -154,18 +144,6 @@ union idpf_tx_flex_desc {#define idpf_tx_buf libeth_sqe -/** -* struct idpf_buf_lifo - LIFO for managing OOO completions -* @top: Used to know how many buffers are left -* @size: Total size of LIFO -* @bufs: Backing array -*/ -struct idpf_buf_lifo { -u16 top; -u16 size; -struct idpf_tx_stash **bufs; -}; -/** * struct idpf_tx_offload_params - Offload parameters for a given packet * @tx_flags: Feature flags enabled for this packet
@@ -476,17 +454,6 @@ struct idpf_tx_queue_stats {#define IDPF_ITR_IDX_SPACING (spacing, dflt) (spacing ? spacing : dflt)#define IDPF_DIM_DEFAULT_PROFILE_IX 1 -/** -* struct idpf_txq_stash - Tx buffer stash for Flow-based scheduling mode -* @buf_stack: Stack of empty buffers to store buffer info for out of order -* buffer completions. See struct idpf_buf_lifo -* @sched_buf_hash: Hash table to store buffers -*/ -struct idpf_txq_stash { -struct idpf_buf_lifo buf_stack; - DECLARE_HASHTABLE(sched_buf_hash, 12); -}____cacheline_aligned ; -/** * struct idpf_rx_queue - software structure representing a receive queue * @rx: universal receive descriptor array
@@ -631,11 +598,7 @@ libeth_cacheline_set_assert(struct idpf_rx_queue, 64,* only once at the end of the cleaning routine. * @clean_budget: singleq only, queue cleaning budget * @cleaned_pkts: Number of packets cleaned for the above said case -* @stash: Tx buffer stash for Flow-based scheduling mode * @refillq: Pointer to refill queue -* @compl_tag_bufid_m: Completion tag buffer id mask -* @compl_tag_cur_gen: Used to keep track of current completion tag generation -* @compl_tag_gen_max: To determine when compl_tag_cur_gen should be reset * @cached_tstamp_caps: Tx timestamp capabilities negotiated with the CP * @tstamp_task: Work that handles Tx timestamp read * @stats_sync: See struct u64_stats_sync
@@ -666,7 +629,6 @@ struct idpf_tx_queue {u16 desc_count;u16 tx_min_pkt_len; -u16 compl_tag_gen_s;struct net_device *netdev;__cacheline_group_end_aligned (read_mostly);
@@ -683,13 +645,8 @@ struct idpf_tx_queue { };u16 cleaned_pkts; -struct idpf_txq_stash *stash;struct idpf_sw_queue *refillq; -u16 compl_tag_bufid_m; -u16 compl_tag_cur_gen; -u16 compl_tag_gen_max; -struct idpf_ptp_vport_tx_tstamp_caps *cached_tstamp_caps;struct work_struct *tstamp_task;
@@ -707,7 +664,7 @@ struct idpf_tx_queue {__cacheline_group_end_aligned (cold); }; libeth_cacheline_set_assert(struct idpf_tx_queue, 64, -120 +sizeof (struct u64_stats_sync ), +104 +sizeof (struct u64_stats_sync ), 32);/**
@@ -918,7 +875,6 @@ struct idpf_rxq_group {* @vport: Vport back pointer * @num_txq: Number of TX queues associated * @txqs: Array of TX queue pointers -* @stashes: array of OOO stashes for the queues * @complq: Associated completion queue pointer, split queue only * @num_completions_pending: Total number of completions pending for the * completion queue, acculumated for all TX queues
@@ -933,7 +889,6 @@ struct idpf_txq_group {u16 num_txq;struct idpf_tx_queue *txqs[IDPF_LARGE_MAX_Q ]; -struct idpf_txq_stash *stashes;struct idpf_compl_queue *complq;
drivers/net/ethernet/intel/idpf/idpf_txrx.c +21 -293
491 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 7/18 idpf: fix Rx descriptor ready check barrier in splitq
In reply to Alexander LobakinNo idea what the current barrier position was meant for. At that point, nothing is read from the descriptor, only the pointer to the actual one is fetched.
The correct barrier usage here is after the generation check, so that only the first qword is read if the descriptor is not yet ready and we need to stop polling. Debatable on coherent DMA as the Rx descriptor size is <= cacheline size, but anyway, the current barrier position only makes the codegen worse.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +2 -6
@@ -3186,18 +3186,14 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)/* get the Rx desc from Rx queue based on 'next_to_clean' */ rx_desc = &rxq->rx[ntc].flex_adv_nic_3_wb; -/* This memory barrier is needed to keep us from reading -* any other fields out of the rx_desc -*/ -dma_rmb (); -/* if the descriptor isn't done, no work yet to do */ gen_id =le16_get_bits (rx_desc->pktlen_gen_bufq_id,VIRTCHNL2_RX_FLEX_DESC_ADV_GEN_M ); -if (idpf_queue_has (GEN_CHK , rxq) != gen_id)break ; +dma_rmb (); + rxdid =FIELD_GET (VIRTCHNL2_RX_FLEX_DESC_ADV_RXDID_M , rx_desc->rxdid_ucast);if (rxdid !=VIRTCHNL2_RXDID_2_FLEX_SPLITQ ) {
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 8/18 idpf: use a saner limit for default number of queues to allocate
In reply to Alexander LobakinCurrently, the maximum number of queues available for one vport is 16. This is hardcoded, but then the function calculating the optimal number of queues takes min(16, num_online_cpus()).
In order to be able to allocate more queues, which will be then used for XDP, stop hardcoding 16 and rely on what the device gives us[*]. Instead of num_online_cpus(), which is considered suboptimal since at least 2013, use netif_get_num_default_rss_queues() to still have free queues in the pool.
[*] With the note:
Currently, idpf always allocates IDPF_MAX_BUFQS_PER_RXQ_GRP (== 2) buffer queues for each Rx queue and one completion queue for each Tx for best performance. But there was no check whether such number is availabe, IOW the assumption was not backed by any "harmonizing" / actual checks. Fix this while at it.
nr_cpu_ids number of Tx queues are needed only for lockless XDP sending, the regular stack doesn't benefit from that anyhow.
On a 128-thread Xeon, this now gives me 32 regular Tx queues and leaves 224 free for XDP (128 of which will handle XDP_TX, .ndo_xdp_xmit(), and XSk xmit when enabled).
Note 2:
Unfortunately, some CP/FW versions are not able to reconfigure/enable/disable large amount of queues within the minimum timeout (2 seconds). For now, fall back to the default timeout for every operation until this is resolved.
--- .../net/ethernet/intel/idpf/idpf_virtchnl.h | 1 - drivers/net/ethernet/intel/idpf/idpf_txrx.c | 8 +-- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 62 +++++++++++-------- 3 files changed, 38 insertions(+), 33 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_virtchnl.h +0 -1
@@ -4,7 +4,6 @@#ifndef _IDPF_VIRTCHNL_H_#define _IDPF_VIRTCHNL_H_ -#define IDPF_VC_XN_MIN_TIMEOUT_MSEC 2000#define IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC (60 * 1000)#define IDPF_VC_XN_IDX_M GENMASK(7, 0)#define IDPF_VC_XN_SALT_M GENMASK(15, 8)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +1 -7
@@ -1155,13 +1155,7 @@ int idpf_vport_calc_total_qs(struct idpf_adapter *adapter, u16 vport_idx, num_req_tx_qs = vport_config->user_config.num_req_tx_qs; num_req_rx_qs = vport_config->user_config.num_req_rx_qs; }else { -int num_cpus; - -/* Restrict num of queues to cpus online as a default -* configuration to give best performance. User can always -* override to a max number of queues via ethtool. -*/ - num_cpus =num_online_cpus (); +u32 num_cpus =netif_get_num_default_rss_queues (); dflt_splitq_txq_grps =min_t (int, max_q->max_txq, num_cpus); dflt_singleq_txqs =min_t (int, max_q->max_txq, num_cpus);
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +37 -25
126 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 9/18 idpf: link NAPIs to queues
In reply to Alexander LobakinAdd the missing linking of NAPIs to netdev queues when enabling interrupt vectors in order to support NAPI configuration and interfaces requiring get_rx_queue()->napi to be set (like XSk busy polling).
As currently, idpf_vport_{start,stop}() is called from several flows with inconsistent RTNL locking, we need to synchronize them to avoid runtime assertions. Notably:
* idpf_{open,stop}() -- regular NDOs, RTNL is always taken;
* idpf_initiate_soft_reset() -- usually called under RTNL;
* idpf_init_task -- called from the init work, needs RTNL;
* idpf_vport_dealloc -- called without RTNL taken, needs it.
Expand common idpf_vport_{start,stop}() to take an additional bool telling whether we need to manually take the RTNL lock.
--- drivers/net/ethernet/intel/idpf/idpf_lib.c | 38 +++++++++++++++------ drivers/net/ethernet/intel/idpf/idpf_txrx.c | 17 +++++++++ 2 files changed, 45 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_lib.c +28 -10
@@ -883,14 +883,18 @@ static void idpf_remove_features(struct idpf_vport *vport)/** * idpf_vport_stop - Disable a vport * @vport: vport to disable +* @rtnl: whether to take RTNL lock */ -static void idpf_vport_stop (struct idpf_vport *vport) +static void idpf_vport_stop (struct idpf_vport *vport,bool rtnl) {struct idpf_netdev_priv *np =netdev_priv (vport->netdev);if (np->state <= __IDPF_VPORT_DOWN)return ; +if (rtnl) +rtnl_lock (); +netif_carrier_off (vport->netdev);netif_tx_disable (vport->netdev);
@@ -912,6 +916,9 @@ static void idpf_vport_stop(struct idpf_vport *vport)idpf_vport_queues_rel (vport);idpf_vport_intr_rel (vport); np->state = __IDPF_VPORT_DOWN; + +if (rtnl) +rtnl_unlock (); }/**
@@ -935,7 +942,7 @@ static int idpf_stop(struct net_device *netdev)idpf_vport_ctrl_lock (netdev); vport =idpf_netdev_to_vport (netdev); -idpf_vport_stop (vport); +idpf_vport_stop (vport, false);idpf_vport_ctrl_unlock (netdev);
@@ -1028,7 +1035,7 @@ static void idpf_vport_dealloc(struct idpf_vport *vport)idpf_idc_deinit_vport_aux_device (vport->vdev_info);idpf_deinit_mac_addr (vport); -idpf_vport_stop (vport); +idpf_vport_stop (vport, true);if (!test_bit (IDPF_HR_RESET_IN_PROG , adapter->flags))idpf_decfg_netdev (vport);
@@ -1369,8 +1376,9 @@ static void idpf_rx_init_buf_tail(struct idpf_vport *vport)/** * idpf_vport_open - Bring up a vport * @vport: vport to bring up +* @rtnl: whether to take RTNL lock */ -static int idpf_vport_open (struct idpf_vport *vport) +static int idpf_vport_open (struct idpf_vport *vport,bool rtnl) {struct idpf_netdev_priv *np =netdev_priv (vport->netdev);struct idpf_adapter *adapter = vport->adapter;
@@ -1380,6 +1388,9 @@ static int idpf_vport_open(struct idpf_vport *vport)if (np->state != __IDPF_VPORT_DOWN)return -EBUSY ; +if (rtnl) +rtnl_lock (); +/* we do not allow interface up just yet */ netif_carrier_off (vport->netdev);
@@ -1387,7 +1398,7 @@ static int idpf_vport_open(struct idpf_vport *vport)if (err) {dev_err (&adapter->pdev->dev,"Failed to allocate interrupts for vport %u: %d\n" , vport->vport_id, err); -return err; + goto err_rtnl_unlock; } err =idpf_vport_queues_alloc (vport);
@@ -1474,6 +1485,9 @@ static int idpf_vport_open(struct idpf_vport *vport) goto deinit_rss; } +if (rtnl) +rtnl_unlock (); +return 0 ; deinit_rss:
@@ -1491,6 +1505,10 @@ static int idpf_vport_open(struct idpf_vport *vport) intr_rel:idpf_vport_intr_rel (vport); +err_rtnl_unlock: +if (rtnl) +rtnl_unlock (); +return err; }
@@ -1571,7 +1589,7 @@ void idpf_init_task(struct work_struct *work) np =netdev_priv (vport->netdev); np->state = __IDPF_VPORT_DOWN;if (test_and_clear_bit (IDPF_VPORT_UP_REQUESTED , vport_config->flags)) -idpf_vport_open (vport); +idpf_vport_open (vport, true);/* Spawn and return 'idpf_init_task' work queue until all the * default vports are created
@@ -1961,7 +1979,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,idpf_send_delete_queues_msg (vport); }else {set_bit (IDPF_VPORT_DEL_QUEUES , vport->flags); -idpf_vport_stop (vport); +idpf_vport_stop (vport, false); }idpf_deinit_rss (vport);
@@ -1991,7 +2009,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport, goto err_open;if (current_state == __IDPF_VPORT_UP) - err =idpf_vport_open (vport); + err =idpf_vport_open (vport, false); goto free_vport;
@@ -2001,7 +2019,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport, err_open:if (current_state == __IDPF_VPORT_UP) -idpf_vport_open (vport); +idpf_vport_open (vport, false); free_vport:kfree (new_vport);
@@ -2239,7 +2257,7 @@ static int idpf_open(struct net_device *netdev)if (err) goto unlock; - err =idpf_vport_open (vport); + err =idpf_vport_open (vport, false); unlock:idpf_vport_ctrl_unlock (netdev);
drivers/net/ethernet/intel/idpf/idpf_txrx.c +17 -0
@@ -3508,6 +3508,20 @@ void idpf_vport_intr_rel(struct idpf_vport *vport) vport->q_vectors =NULL ; } +static void idpf_q_vector_set_napi (struct idpf_q_vector *q_vector,bool link) +{ +struct napi_struct *napi = link ? &q_vector->napi :NULL ; +struct net_device *dev = q_vector->vport->netdev; + +for (u32 i =0 ; i < q_vector->num_rxq; i++) +netif_queue_set_napi (dev, q_vector->rx[i]->idx, +NETDEV_QUEUE_TYPE_RX , napi); + +for (u32 i =0 ; i < q_vector->num_txq; i++) +netif_queue_set_napi (dev, q_vector->tx[i]->idx, +NETDEV_QUEUE_TYPE_TX , napi); +} +/** * idpf_vport_intr_rel_irq - Free the IRQ association with the OS * @vport: main vport structure
@@ -3528,6 +3542,7 @@ static void idpf_vport_intr_rel_irq(struct idpf_vport *vport) vidx = vport->q_vector_idxs[vector]; irq_num = adapter->msix_entries[vidx].vector; +idpf_q_vector_set_napi (q_vector, false);kfree (free_irq (irq_num, q_vector)); } }
@@ -3715,6 +3730,8 @@ static int idpf_vport_intr_req_irq(struct idpf_vport *vport) "Request_irq failed, error: %d\n", err); goto free_q_irqs; } + +idpf_q_vector_set_napi (q_vector, true); }return 0 ;
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 10/18 idpf: add 4-byte completion descriptor definition
In reply to Alexander LobakinFrom: Michal Kubiak <[email protected]>
In the queue-based scheduling mode, Tx completion descriptor is 4 bytes comparing to 8 bytes in flow-based.
Add definition for it and allocate the corresponding amount of memory for the descriptors during the completion queue creation. This does not include handling 4-byte completions during Tx polling, as for now, the only user of QB will be XDP, which has its own routines.
--- .../net/ethernet/intel/idpf/idpf_lan_txrx.h | 6 +++- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 11 ++++-- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 34 +++++++++++-------- 3 files changed, 33 insertions(+), 18 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_lan_txrx.h +5 -1
@@ -186,13 +186,17 @@ struct idpf_base_tx_desc {__le64 qw1;/* type_cmd_offset_bsz_l2tag1 */ };/* read used with buffer queues */ -struct idpf_splitq_tx_compl_desc { +struct idpf_splitq_4b_tx_compl_desc {/* qid=[10:0] comptype=[13:11] rsvd=[14] gen=[15] */ __le16 qid_comptype_gen;union {__le16 q_head;/* Queue head */ __le16 compl_tag;/* Completion tag */ } q_head_compl_tag; +};/* writeback used with completion queues */ + +struct idpf_splitq_tx_compl_desc { +struct idpf_splitq_4b_tx_compl_desc common;u8 ts[3 ];u8 rsvd;/* Reserved */ };/* writeback used with completion queues */
drivers/net/ethernet/intel/idpf/idpf_txrx.h +9 -2
@@ -728,7 +728,9 @@ libeth_cacheline_set_assert(struct idpf_buf_queue, 64, 24, 32);/** * struct idpf_compl_queue - software structure representing a completion queue -* @comp: completion descriptor array +* @comp: 8-byte completion descriptor array +* @comp_4b: 4-byte completion descriptor array +* @desc_ring: virtual descriptor ring address * @txq_grp: See struct idpf_txq_group * @flags: See enum idpf_queue_flags_t * @desc_count: Number of descriptors
@@ -748,7 +750,12 @@ libeth_cacheline_set_assert(struct idpf_buf_queue, 64, 24, 32);*/ struct idpf_compl_queue {__cacheline_group_begin_aligned (read_mostly); -struct idpf_splitq_tx_compl_desc *comp; +union { +struct idpf_splitq_tx_compl_desc *comp; +struct idpf_splitq_4b_tx_compl_desc *comp_4b; + +void *desc_ring; + };struct idpf_txq_group *txq_grp; DECLARE_BITMAP(flags, __IDPF_Q_FLAGS_NBITS);
drivers/net/ethernet/intel/idpf/idpf_txrx.c +19 -15
@@ -95,8 +95,8 @@ static void idpf_compl_desc_rel(struct idpf_compl_queue *complq)return ;dma_free_coherent (complq->netdev->dev.parent, complq->size, - complq->comp, complq->dma); - complq->comp =NULL ; + complq->desc_ring, complq->dma); + complq->desc_ring =NULL ; complq->next_to_use =0 ; complq->next_to_clean =0 ; }
@@ -225,12 +225,16 @@ static int idpf_tx_desc_alloc(const struct idpf_vport *vport,static int idpf_compl_desc_alloc (const struct idpf_vport *vport,struct idpf_compl_queue *complq) { - complq->size =array_size (complq->desc_count,sizeof (*complq->comp)); +u32 desc_size; - complq->comp =dma_alloc_coherent (complq->netdev->dev.parent, - complq->size, &complq->dma, -GFP_KERNEL ); -if (!complq->comp) + desc_size =idpf_queue_has (FLOW_SCH_EN , complq) ? +sizeof (*complq->comp) :sizeof (*complq->comp_4b); + complq->size =array_size (complq->desc_count, desc_size); + + complq->desc_ring =dma_alloc_coherent (complq->netdev->dev.parent, + complq->size, &complq->dma, +GFP_KERNEL ); +if (!complq->desc_ring)return -ENOMEM ; complq->next_to_use =0 ;
@@ -1738,7 +1742,7 @@ static void idpf_tx_handle_rs_completion(struct idpf_tx_queue *txq,/* RS completion contains queue head for queue based scheduling or * completion tag for flow based scheduling. */ -u16 rs_compl_val =le16_to_cpu (desc->q_head_compl_tag.q_head); +u16 rs_compl_val =le16_to_cpu (desc->common.q_head_compl_tag.q_head);if (!idpf_queue_has (FLOW_SCH_EN , txq)) {idpf_tx_splitq_clean (txq, rs_compl_val, budget, cleaned, false);
@@ -1773,19 +1777,19 @@ static bool idpf_tx_clean_complq(struct idpf_compl_queue *complq, int budget, do { struct libeth_sq_napi_stats cleaned_stats = { }; struct idpf_tx_queue *tx_q; + __le16 hw_head; int rel_tx_qid; - u16 hw_head; u8 ctype; /* completion type */ u16 gen; /* if the descriptor isn't done, no work yet to do */ - gen = le16_get_bits(tx_desc->qid_comptype_gen, + gen = le16_get_bits(tx_desc->common.qid_comptype_gen, IDPF_TXD_COMPLQ_GEN_M); if (idpf_queue_has(GEN_CHK, complq) != gen) break; /* Find necessary info of TX queue to clean buffers */ - rel_tx_qid = le16_get_bits(tx_desc->qid_comptype_gen, + rel_tx_qid = le16_get_bits(tx_desc->common.qid_comptype_gen, IDPF_TXD_COMPLQ_QID_M); if (rel_tx_qid >= complq->txq_grp->num_txq || !complq->txq_grp->txqs[rel_tx_qid]) {
@@ -1795,14 +1799,14 @@ static bool idpf_tx_clean_complq(struct idpf_compl_queue *complq, int budget, tx_q = complq->txq_grp->txqs[rel_tx_qid];/* Determine completion type */ - ctype =le16_get_bits (tx_desc->qid_comptype_gen, + ctype =le16_get_bits (tx_desc->common.qid_comptype_gen,IDPF_TXD_COMPLQ_COMPL_TYPE_M );switch (ctype) {case IDPF_TXD_COMPLT_RE : - hw_head =le16_to_cpu (tx_desc->q_head_compl_tag.q_head); + hw_head = tx_desc->common.q_head_compl_tag.q_head; -idpf_tx_splitq_clean (tx_q, hw_head, budget, - &cleaned_stats, true); +idpf_tx_splitq_clean (tx_q,le16_to_cpu (hw_head), + budget, &cleaned_stats, true);break ;case IDPF_TXD_COMPLT_RS : idpf_tx_handle_rs_completion(tx_q, tx_desc,
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 11/18 idpf: remove SW marker handling from NAPI
In reply to Alexander LobakinFrom: Michal Kubiak <[email protected]>
SW marker descriptors on completion queues are used only when a queue is about to be destroyed. It's far from hotpath and handling it in the hotpath NAPI poll makes no sense.
Instead, run a simple poller after a virtchnl message for destroying the queue is sent and wait for the replies. If replies for all of the queues are received, this means the synchronization is done correctly and we can go forth with stopping the link.
--- drivers/net/ethernet/intel/idpf/idpf.h | 7 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 4 +- drivers/net/ethernet/intel/idpf/idpf_lib.c | 2 - drivers/net/ethernet/intel/idpf/idpf_txrx.c | 97 ++++++++++++------- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 34 ++----- 5 files changed, 72 insertions(+), 72 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +1 -6
@@ -40,6 +40,7 @@ struct idpf_vport_max_q;#define IDPF_NUM_CHUNKS_PER_MSG (struct_sz, chunk_sz) \ ((IDPF_CTLQ_MAX_BUF_LEN - (struct_sz)) / (chunk_sz)) +#define IDPF_WAIT_FOR_MARKER_TIMEO 500#define IDPF_MAX_WAIT 500/* available message levels */
@@ -246,13 +247,10 @@ enum idpf_vport_reset_cause {/** * enum idpf_vport_flags - Vport flags * @IDPF_VPORT_DEL_QUEUES: To send delete queues message -* @IDPF_VPORT_SW_MARKER: Indicate TX pipe drain software marker packets -* processing is done * @IDPF_VPORT_FLAGS_NBITS: Must be last */ enum idpf_vport_flags {IDPF_VPORT_DEL_QUEUES , -IDPF_VPORT_SW_MARKER ,IDPF_VPORT_FLAGS_NBITS , };
@@ -318,7 +316,6 @@ struct idpf_fsteer_fltr {* @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation * @port_stats: per port csum, header split, and other offload stats * @link_up: True if link is up -* @sw_marker_wq: workqueue for marker packets * @tx_tstamp_caps: Capabilities negotiated for Tx timestamping * @tstamp_config: The Tx tstamp config * @tstamp_task: Tx timestamping task
@@ -367,8 +364,6 @@ struct idpf_vport {bool link_up; -wait_queue_head_t sw_marker_wq; -struct idpf_ptp_vport_tx_tstamp_caps *tx_tstamp_caps;struct kernel_hwtstamp_config tstamp_config;struct work_struct tstamp_task;
drivers/net/ethernet/intel/idpf/idpf_txrx.h +2 -2
@@ -275,7 +275,6 @@ struct idpf_ptype_state {* bit and Q_RFL_GEN is the SW bit. * @__IDPF_Q_FLOW_SCH_EN: Enable flow scheduling * @__IDPF_Q_SW_MARKER: Used to indicate TX queue marker completions -* @__IDPF_Q_POLL_MODE: Enable poll mode * @__IDPF_Q_CRC_EN: enable CRC offload in singleq mode * @__IDPF_Q_HSPLIT_EN: enable header split on Rx (splitq) * @__IDPF_Q_PTP: indicates whether the Rx timestamping is enabled for the
@@ -287,7 +286,6 @@ enum idpf_queue_flags_t { __IDPF_Q_RFL_GEN_CHK, __IDPF_Q_FLOW_SCH_EN, __IDPF_Q_SW_MARKER, - __IDPF_Q_POLL_MODE, __IDPF_Q_CRC_EN, __IDPF_Q_HSPLIT_EN, __IDPF_Q_PTP,
@@ -1036,4 +1034,6 @@ bool idpf_rx_singleq_buf_hw_alloc_all(struct idpf_rx_queue *rxq, u16 cleaned_count);int idpf_tso (struct sk_buff *skb,struct idpf_tx_offload_params *off); +void idpf_wait_for_sw_marker_completion (const struct idpf_tx_queue *txq); +#endif /* !_IDPF_TXRX_H_ */
drivers/net/ethernet/intel/idpf/idpf_lib.c +0 -2
@@ -1565,8 +1565,6 @@ void idpf_init_task(struct work_struct *work) index = vport->idx; vport_config = adapter->vport_config[index]; -init_waitqueue_head (&vport->sw_marker_wq); -spin_lock_init (&vport_config->mac_filter_list_lock);INIT_LIST_HEAD (&vport_config->user_config.mac_filter_list);
drivers/net/ethernet/intel/idpf/idpf_txrx.c +60 -37
121 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +9 -25
@@ -724,21 +724,17 @@ int idpf_recv_mb_msg(struct idpf_adapter *adapter)**/ static int idpf_wait_for_marker_event (struct idpf_vport *vport) { -int event; -int i; - -for (i =0 ; i < vport->num_txq; i++) -idpf_queue_set (SW_MARKER , vport->txqs[i]); +bool markers_rcvd = true; - event =wait_event_timeout (vport->sw_marker_wq, -test_and_clear_bit (IDPF_VPORT_SW_MARKER , - vport->flags), -msecs_to_jiffies (500 )); +for (u32 i =0 ; i < vport->num_txq; i++) { +struct idpf_tx_queue *txq = vport->txqs[i]; -for (i =0 ; i < vport->num_txq; i++) -idpf_queue_clear (POLL_MODE , vport->txqs[i]); +idpf_queue_set (SW_MARKER , txq); +idpf_wait_for_sw_marker_completion (txq); + markers_rcvd &= !idpf_queue_has (SW_MARKER , txq); + } -if (event) +if (markers_rcvd)return 0 ;dev_warn (&vport->adapter->pdev->dev,"Failed to receive marker packets\n" );
@@ -2137,24 +2133,12 @@ int idpf_send_enable_queues_msg(struct idpf_vport *vport)*/ int idpf_send_disable_queues_msg (struct idpf_vport *vport) { -int err, i; +int err; err =idpf_send_ena_dis_queues_msg (vport, false);if (err)return err; -/* switch to poll mode as interrupts will be disabled after disable -* queues virtchnl message is sent -*/ -for (i =0 ; i < vport->num_txq; i++) -idpf_queue_set (POLL_MODE , vport->txqs[i]); - -/* schedule the napi to receive all the marker packets */ -local_bh_disable (); -for (i =0 ; i < vport->num_q_vectors; i++) -napi_schedule (&vport->q_vectors[i].napi); -local_bh_enable (); -return idpf_wait_for_marker_event (vport); }
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 12/18 idpf: add support for nointerrupt queues
In reply to Alexander LobakinCurrently, queues are associated 1:1 with interrupt vectors as it's assumed queues are always interrupt-driven. For XDP, we want to use Tx queues without interrupts and only do "lazy" cleaning when the number of free elements is <= threshold (closest pow-2 to 1/4 of the ring). In order to use a queue without an interrupt, idpf still needs to have a vector assigned to it to flush descriptors. This vector can be global and only one for the whole vport to handle all its noirq queues. Always request one excessive vector and configure it in non-interrupt mode right away when creating vport, so that it can be used later by queues when needed (not only XDP ones).
--- drivers/net/ethernet/intel/idpf/idpf.h | 8 +++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 4 ++ drivers/net/ethernet/intel/idpf/idpf_dev.c | 11 +++- drivers/net/ethernet/intel/idpf/idpf_lib.c | 2 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 8 +++ drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 11 +++- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 54 ++++++++++++++----- 7 files changed, 81 insertions(+), 17 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +8 -0
@@ -310,6 +310,9 @@ struct idpf_fsteer_fltr {* @num_q_vectors: Number of IRQ vectors allocated * @q_vectors: Array of queue vectors * @q_vector_idxs: Starting index of queue vectors +* @noirq_dyn_ctl: register to enable/disable the vector for NOIRQ queues +* @noirq_dyn_ctl_ena: value to write to the above to enable it +* @noirq_v_idx: ID of the NOIRQ vector * @max_mtu: device given max possible MTU * @default_mac_addr: device will give a default MAC to use * @rx_itr_profile: RX profiles for Dynamic Interrupt Moderation
@@ -356,6 +359,11 @@ struct idpf_vport {u16 num_q_vectors;struct idpf_q_vector *q_vectors;u16 *q_vector_idxs; + +void __iomem *noirq_dyn_ctl; +u32 noirq_dyn_ctl_ena; +u16 noirq_v_idx; +u16 max_mtu;u8 default_mac_addr[ETH_ALEN ];u16 rx_itr_profile[IDPF_DIM_PROFILE_SLOTS ];
drivers/net/ethernet/intel/idpf/idpf_txrx.h +4 -0
@@ -58,6 +58,8 @@#define IDPF_MBX_Q_VEC 1#define IDPF_MIN_Q_VEC 1#define IDPF_MIN_RDMA_VEC 2 +/* Data vector for NOIRQ queues */ +#define IDPF_RESERVED_VECS 1#define IDPF_DFLT_TX_Q_DESC_COUNT 512#define IDPF_DFLT_TX_COMPLQ_DESC_COUNT 512
@@ -279,6 +281,7 @@ struct idpf_ptype_state {* @__IDPF_Q_HSPLIT_EN: enable header split on Rx (splitq) * @__IDPF_Q_PTP: indicates whether the Rx timestamping is enabled for the * queue +* @__IDPF_Q_NOIRQ: queue is polling-driven and has no interrupt * @__IDPF_Q_FLAGS_NBITS: Must be last */ enum idpf_queue_flags_t {
@@ -289,6 +292,7 @@ enum idpf_queue_flags_t { __IDPF_Q_CRC_EN, __IDPF_Q_HSPLIT_EN, __IDPF_Q_PTP, + __IDPF_Q_NOIRQ, __IDPF_Q_FLAGS_NBITS, };
drivers/net/ethernet/intel/idpf/idpf_dev.c +10 -1
@@ -77,7 +77,7 @@ static int idpf_intr_reg_init(struct idpf_vport *vport)int num_vecs = vport->num_q_vectors;struct idpf_vec_regs *reg_vals;int num_regs, i, err =0 ; -u32 rx_itr, tx_itr; +u32 rx_itr, tx_itr, val;u16 total_vecs; total_vecs =idpf_get_reserved_vecs (vport->adapter);
@@ -121,6 +121,15 @@ static int idpf_intr_reg_init(struct idpf_vport *vport) intr->tx_itr =idpf_get_reg_addr (adapter, tx_itr); } +/* Data vector for NOIRQ queues */ + + val = reg_vals[vport->q_vector_idxs[i] -IDPF_MBX_Q_VEC ].dyn_ctl_reg; + vport->noirq_dyn_ctl =idpf_get_reg_addr (adapter, val); + + val =PF_GLINT_DYN_CTL_WB_ON_ITR_M |PF_GLINT_DYN_CTL_INTENA_MSK_M | +FIELD_PREP (PF_GLINT_DYN_CTL_ITR_INDX_M ,IDPF_NO_ITR_UPDATE_IDX ); + vport->noirq_dyn_ctl_ena = val; + free_reg_vals:kfree (reg_vals);
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -1
@@ -1141,7 +1141,7 @@ static struct idpf_vport *idpf_vport_alloc(struct idpf_adapter *adapter,if (!vport)return vport; - num_max_q =max (max_q->max_txq, max_q->max_rxq); + num_max_q =max (max_q->max_txq, max_q->max_rxq) +IDPF_RESERVED_VECS ;if (!adapter->vport_config[idx]) {struct idpf_vport_config *vport_config;struct idpf_q_coalesce *q_coal;
drivers/net/ethernet/intel/idpf/idpf_txrx.c +8 -0
@@ -3591,6 +3591,8 @@ static void idpf_vport_intr_dis_irq_all(struct idpf_vport *vport)struct idpf_q_vector *q_vector = vport->q_vectors;int q_idx; +writel (0 , vport->noirq_dyn_ctl); +for (q_idx =0 ; q_idx < vport->num_q_vectors; q_idx++)writel (0 , q_vector[q_idx].intr_reg.dyn_ctl); }
@@ -3834,6 +3836,8 @@ static void idpf_vport_intr_ena_irq_all(struct idpf_vport *vport)if (qv->num_txq || qv->num_rxq)idpf_vport_intr_update_itr_ena_irq (qv); } + +writel (vport->noirq_dyn_ctl_ena, vport->noirq_dyn_ctl); }/**
@@ -4145,6 +4149,8 @@ static int idpf_vport_intr_init_vec_idx(struct idpf_vport *vport)for (i =0 ; i < vport->num_q_vectors; i++) vport->q_vectors[i].v_idx = vport->q_vector_idxs[i]; + vport->noirq_v_idx = vport->q_vector_idxs[i]; +return 0 ; }
@@ -4158,6 +4164,8 @@ static int idpf_vport_intr_init_vec_idx(struct idpf_vport *vport)for (i =0 ; i < vport->num_q_vectors; i++) vport->q_vectors[i].v_idx = vecids[vport->q_vector_idxs[i]]; + vport->noirq_v_idx = vecids[vport->q_vector_idxs[i]]; +kfree (vecids);return 0 ;
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c +10 -1
@@ -76,7 +76,7 @@ static int idpf_vf_intr_reg_init(struct idpf_vport *vport)int num_vecs = vport->num_q_vectors;struct idpf_vec_regs *reg_vals;int num_regs, i, err =0 ; -u32 rx_itr, tx_itr; +u32 rx_itr, tx_itr, val;u16 total_vecs; total_vecs =idpf_get_reserved_vecs (vport->adapter);
@@ -120,6 +120,15 @@ static int idpf_vf_intr_reg_init(struct idpf_vport *vport) intr->tx_itr =idpf_get_reg_addr (adapter, tx_itr); } +/* Data vector for NOIRQ queues */ + + val = reg_vals[vport->q_vector_idxs[i] -IDPF_MBX_Q_VEC ].dyn_ctl_reg; + vport->noirq_dyn_ctl =idpf_get_reg_addr (adapter, val); + + val =VF_INT_DYN_CTLN_WB_ON_ITR_M |VF_INT_DYN_CTLN_INTENA_MSK_M | +FIELD_PREP (VF_INT_DYN_CTLN_ITR_INDX_M ,IDPF_NO_ITR_UPDATE_IDX ); + vport->noirq_dyn_ctl_ena = val; + free_reg_vals:kfree (reg_vals);
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +40 -14
91 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 13/18 idpf: prepare structures to support XDP
In reply to Alexander LobakinFrom: Michal Kubiak <[email protected]>
Extend basic structures of the driver (e.g. 'idpf_vport', 'idpf_*_queue', 'idpf_vport_user_config_data') by adding members necessary to support XDP. Add extra XDP Tx queues needed to support XDP_TX and XDP_REDIRECT actions without interfering with regular Tx traffic.
Also add functions dedicated to support XDP initialization for Rx and Tx queues and call those functions from the existing algorithms of queues configuration.
Note that "other count" in Ethtool will now also include XDP Tx queues.
--- drivers/net/ethernet/intel/idpf/Kconfig | 2 +- drivers/net/ethernet/intel/idpf/Makefile | 2 + drivers/net/ethernet/intel/idpf/idpf.h | 16 ++ drivers/net/ethernet/intel/idpf/idpf_txrx.h | 100 +++++++---- drivers/net/ethernet/intel/idpf/xdp.h | 17 ++ .../net/ethernet/intel/idpf/idpf_ethtool.c | 6 +- drivers/net/ethernet/intel/idpf/idpf_lib.c | 21 ++- drivers/net/ethernet/intel/idpf/idpf_main.c | 1 + .../ethernet/intel/idpf/idpf_singleq_txrx.c | 8 +- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 104 ++++++++--- .../net/ethernet/intel/idpf/idpf_virtchnl.c | 25 +-- drivers/net/ethernet/intel/idpf/xdp.c | 165 ++++++++++++++++++ 12 files changed, 381 insertions(+), 86 deletions(-) create mode 100644 drivers/net/ethernet/intel/idpf/xdp.h create mode 100644 drivers/net/ethernet/intel/idpf/xdp.c
drivers/net/ethernet/intel/idpf/Kconfig +1 -1
@@ -6,7 +6,7 @@ config IDPF depends on PCI_MSI depends on PTP_1588_CLOCK_OPTIONAL select DIMLIB - select LIBETH + select LIBETH_XDP help This driver supports Intel(R) Infrastructure Data Path Function devices.
drivers/net/ethernet/intel/idpf/Makefile +2 -0
@@ -21,3 +21,5 @@ idpf-$(CONFIG_IDPF_SINGLEQ) += idpf_singleq_txrx.o idpf-$(CONFIG_PTP_1588_CLOCK) += idpf_ptp.o idpf-$(CONFIG_PTP_1588_CLOCK) += idpf_virtchnl_ptp.o + +idpf-y += xdp.o
drivers/net/ethernet/intel/idpf/idpf.h +16 -0
@@ -285,6 +285,10 @@ struct idpf_fsteer_fltr {* @txq_model: Split queue or single queue queuing model * @txqs: Used only in hotpath to get to the right queue very fast * @crc_enable: Enable CRC insertion offload +* @xdpsq_share: whether XDPSQ sharing is enabled +* @num_xdp_txq: number of XDPSQs +* @xdp_txq_offset: index of the first XDPSQ (== number of regular SQs) +* @xdp_prog: installed XDP program * @num_rxq: Number of allocated RX queues * @num_bufq: Number of allocated buffer queues * @rxq_desc_count: RX queue descriptor count. *MUST* have enough descriptors
@@ -335,6 +339,11 @@ struct idpf_vport {struct idpf_tx_queue **txqs;bool crc_enable; +bool xdpsq_share; +u16 num_xdp_txq; +u16 xdp_txq_offset; +struct bpf_prog *xdp_prog; +u16 num_rxq;u16 num_bufq;u32 rxq_desc_count;
@@ -436,6 +445,7 @@ struct idpf_q_coalesce {* ethtool * @num_req_rxq_desc: Number of user requested RX queue descriptors through * ethtool +* @xdp_prog: requested XDP program to install * @user_flags: User toggled config flags * @mac_filter_list: List of MAC filters * @num_fsteer_fltrs: number of flow steering filters
@@ -450,6 +460,7 @@ struct idpf_vport_user_config_data {u16 num_req_rx_qs;u32 num_req_txq_desc;u32 num_req_rxq_desc; +struct bpf_prog *xdp_prog;DECLARE_BITMAP (user_flags, __IDPF_USER_FLAGS_NBITS);struct list_head mac_filter_list;u32 num_fsteer_fltrs;
@@ -679,6 +690,11 @@ static inline int idpf_is_queue_model_split(u16 q_model) q_model ==VIRTCHNL2_QUEUE_MODEL_SPLIT ; } +static inline bool idpf_xdp_enabled (const struct idpf_vport *vport) +{ +return vport->adapter && vport->xdp_prog; +} +#define idpf_is_cap_ena (adapter, field, flag) \ idpf_is_capability_ena(adapter, false, field, flag)#define idpf_is_cap_ena_all (adapter, field, flag) \
drivers/net/ethernet/intel/idpf/idpf_txrx.h +62 -38
206 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/xdp.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2025 Intel Corporation */ + +#ifndef _IDPF_XDP_H_ +#define _IDPF_XDP_H_ + +#include <linux/types.h> + +struct idpf_vport ; + +int idpf_xdp_rxq_info_init_all (const struct idpf_vport *vport); +void idpf_xdp_rxq_info_deinit_all (const struct idpf_vport *vport); + +int idpf_xdpsqs_get (const struct idpf_vport *vport); +void idpf_xdpsqs_put (const struct idpf_vport *vport); + +#endif /* _IDPF_XDP_H_ */
drivers/net/ethernet/intel/idpf/idpf_ethtool.c +4 -2
@@ -474,9 +474,11 @@ static void idpf_get_channels(struct net_device *netdev, {struct idpf_netdev_priv *np =netdev_priv (netdev);struct idpf_vport_config *vport_config; +const struct idpf_vport *vport;u16 num_txq, num_rxq;u16 combined; + vport =idpf_netdev_to_vport (netdev); vport_config = np->adapter->vport_config[np->vport_idx]; num_txq = vport_config->user_config.num_req_tx_qs;
@@ -490,8 +492,8 @@ static void idpf_get_channels(struct net_device *netdev, ch->max_rx = vport_config->max_q.max_rxq; ch->max_tx = vport_config->max_q.max_txq; - ch->max_other =IDPF_MAX_MBXQ ; - ch->other_count =IDPF_MAX_MBXQ ; + ch->max_other =IDPF_MAX_MBXQ + vport->num_xdp_txq; + ch->other_count =IDPF_MAX_MBXQ + vport->num_xdp_txq; ch->combined_count = combined; ch->rx_count = num_rxq - combined;
drivers/net/ethernet/intel/idpf/idpf_lib.c +17 -4
@@ -4,6 +4,7 @@#include "idpf.h" #include "idpf_virtchnl.h" #include "idpf_ptp.h" +#include "xdp.h" static const struct net_device_ops idpf_netdev_ops;
@@ -913,6 +914,7 @@ static void idpf_vport_stop(struct idpf_vport *vport, bool rtnl) vport->link_up = false;idpf_vport_intr_deinit (vport); +idpf_xdp_rxq_info_deinit_all (vport);idpf_vport_queues_rel (vport);idpf_vport_intr_rel (vport); np->state = __IDPF_VPORT_DOWN;
@@ -1315,13 +1317,13 @@ static void idpf_restore_features(struct idpf_vport *vport)*/ static int idpf_set_real_num_queues (struct idpf_vport *vport) { -int err; +int err, txq = vport->num_txq - vport->num_xdp_txq; err =netif_set_real_num_rx_queues (vport->netdev, vport->num_rxq);if (err)return err; -return netif_set_real_num_tx_queues (vport->netdev, vport->num_txq); +return netif_set_real_num_tx_queues (vport->netdev, txq); }/**
@@ -1434,20 +1436,29 @@ static int idpf_vport_open(struct idpf_vport *vport, bool rtnl) }idpf_rx_init_buf_tail (vport); + + err =idpf_xdp_rxq_info_init_all (vport); +if (err) { +netdev_err (vport->netdev, +"Failed to initialize XDP RxQ info for vport %u: %pe\n" , + vport->vport_id,ERR_PTR (err)); + goto intr_deinit; + } +idpf_vport_intr_ena (vport); err =idpf_send_config_queues_msg (vport);if (err) {dev_err (&adapter->pdev->dev,"Failed to configure queues for vport %u, %d\n" , vport->vport_id, err); - goto intr_deinit; + goto rxq_deinit; } err =idpf_send_map_unmap_queue_vector_msg (vport, true);if (err) {dev_err (&adapter->pdev->dev,"Failed to map queue vectors for vport %u: %d\n" , vport->vport_id, err); - goto intr_deinit; + goto rxq_deinit; } err =idpf_send_enable_queues_msg (vport);
@@ -1498,6 +1509,8 @@ static int idpf_vport_open(struct idpf_vport *vport, bool rtnl)idpf_send_disable_queues_msg (vport); unmap_queue_vectors:idpf_send_map_unmap_queue_vector_msg (vport, false); +rxq_deinit: +idpf_xdp_rxq_info_deinit_all (vport); intr_deinit:idpf_vport_intr_deinit (vport); queues_rel:
drivers/net/ethernet/intel/idpf/idpf_main.c +1 -0
@@ -9,6 +9,7 @@MODULE_DESCRIPTION (DRV_SUMMARY );MODULE_IMPORT_NS ("LIBETH" ); +MODULE_IMPORT_NS ("LIBETH_XDP" );MODULE_LICENSE ("GPL" );/**
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c +4 -4
@@ -655,7 +655,7 @@ static void idpf_rx_singleq_csum(struct idpf_rx_queue *rxq,bool ipv4, ipv6;/* check if Rx checksum is enabled */ -if (!libeth_rx_pt_has_checksum (rxq->netdev, decoded)) +if (!libeth_rx_pt_has_checksum (rxq->xdp_rxq.dev, decoded))return ;/* check if HW has decoded the packet and checksum */
@@ -794,7 +794,7 @@ static void idpf_rx_singleq_base_hash(struct idpf_rx_queue *rx_q, {u64 mask, qw1; -if (!libeth_rx_pt_has_hash (rx_q->netdev, decoded)) +if (!libeth_rx_pt_has_hash (rx_q->xdp_rxq.dev, decoded))return ; mask =VIRTCHNL2_RX_BASE_DESC_FLTSTAT_RSS_HASH_M ;
@@ -822,7 +822,7 @@ static void idpf_rx_singleq_flex_hash(struct idpf_rx_queue *rx_q, const union virtchnl2_rx_desc *rx_desc, struct libeth_rx_pt decoded) { - if (!libeth_rx_pt_has_hash(rx_q->netdev, decoded)) + if (!libeth_rx_pt_has_hash(rx_q->xdp_rxq.dev, decoded)) return; if (FIELD_GET(VIRTCHNL2_RX_FLEX_DESC_STATUS0_RSS_VALID_M,
@@ -855,7 +855,7 @@ idpf_rx_singleq_process_skb_fields(struct idpf_rx_queue *rx_q,struct libeth_rx_csum csum_bits;/* modifies the skb - consumes the enet header */ - skb->protocol =eth_type_trans (skb, rx_q->netdev); + skb->protocol =eth_type_trans (skb, rx_q->xdp_rxq.dev);/* Check if we're using base mode descriptor IDs */ if (rx_q->rxdids ==VIRTCHNL2_RXDID_1_32B_BASE_M ) {
drivers/net/ethernet/intel/idpf/idpf_txrx.c +79 -25
244 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c +13 -12
@@ -1748,9 +1748,12 @@ static int idpf_send_config_rx_queues_msg(struct idpf_vport *vport)for (j =0 ; j < num_rxq; j++, k++) {const struct idpf_bufq_set *sets;struct idpf_rx_queue *rxq; +u32 rxdids;if (!idpf_is_queue_model_split (vport->rxq_model)) { rxq = rx_qgrp->singleq.rxqs[j]; + rxdids = rxq->rxdids; + goto common_qi_fields; }
@@ -1783,6 +1786,8 @@ static int idpf_send_config_rx_queues_msg(struct idpf_vport *vport)cpu_to_le16 (rxq->rx_hbuf_size); } + rxdids =VIRTCHNL2_RXDID_2_FLEX_SPLITQ_M ; + common_qi_fields: qi[k].queue_id =cpu_to_le32 (rxq->q_id); qi[k].model =cpu_to_le16 (vport->rxq_model);
@@ -1793,7 +1798,7 @@ static int idpf_send_config_rx_queues_msg(struct idpf_vport *vport) qi[k].data_buffer_size =cpu_to_le32 (rxq->rx_buf_size); qi[k].qflags |=cpu_to_le16 (VIRTCHNL2_RX_DESC_SIZE_32BYTE ); - qi[k].desc_ids =cpu_to_le64 (rxq->rxdids); + qi[k].desc_ids =cpu_to_le64 (rxdids); } }
@@ -2028,6 +2033,8 @@ int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map)if (idpf_queue_has (NOIRQ , txq)) vec =NULL ; +else if (idpf_queue_has (XDP , txq)) + vec = txq->complq->q_vector;else if (idpf_is_queue_model_split (vport->txq_model)) vec = txq->txq_grp->complq->q_vector;else
@@ -2046,9 +2053,6 @@ int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map) } } -if (vport->num_txq != k) -return -EINVAL ; -for (i =0 ; i < vport->num_rxq_grp; i++) {struct idpf_rxq_group *rx_qgrp = &vport->rxq_grps[i];u16 num_rxq;
@@ -2084,13 +2088,8 @@ int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map) } } -if (idpf_is_queue_model_split (vport->txq_model)) { -if (vport->num_rxq != k - vport->num_complq) -return -EINVAL ; - }else { -if (vport->num_rxq != k - vport->num_txq) -return -EINVAL ; - } +if (k != num_q) +return -EINVAL ;/* Chunk up the vector info into multiple messages */ config_sz =sizeof (struct virtchnl2_queue_vector_maps );
@@ -3307,7 +3306,9 @@ int idpf_vport_alloc_vec_indexes(struct idpf_vport *vport)if (vec_info.num_curr_vecs) vec_info.num_curr_vecs +=IDPF_RESERVED_VECS ; - req =max (vport->num_txq, vport->num_rxq) +IDPF_RESERVED_VECS ; +/* XDPSQs are all bound to the NOIRQ vector from IDPF_RESERVED_VECS */ + req =max (vport->num_txq - vport->num_xdp_txq, vport->num_rxq) + +IDPF_RESERVED_VECS ; vec_info.num_req_vecs = req; vec_info.default_vport = vport->default_vport;
drivers/net/ethernet/intel/idpf/xdp.c new file +165 -0
165 lines not on this page · raw message
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerRe: [PATCH iwl-next v3 13/18] idpf: prepare structures to support XDP
Quoted 1 line · On Wed, 30 Jul 2025 18:07:12 +0200 Alexander Lobakin wrote:
Note that "other count" in Ethtool will now also include XDP Tx queues.
Erm, what? You mean other channels? Channels are interrupts, not queues.
Alexander Lobakin
maintainerRe: [PATCH iwl-next v3 13/18] idpf: prepare structures to support XDP
From: Jakub Kicinski <[email protected]>
Date: Fri, 1 Aug 2025 15:30:23 -0700
Quoted 5 lines · On Wed, 30 Jul 2025 18:07:12 +0200 Alexander Lobakin wrote:
Quoted 1 line
Note that "other count" in Ethtool will now also include XDP Tx queues.
Erm, what? You mean other channels? Channels are interrupts, not queues.
Ooops. I had a strong impression that "channels" mean "queues"... I think I really need to sit and re-read the Ethtool documentation carefully.
Apologies, I'll drop this in the next rev. XDPSQs in idpf don't use interrupts, so they shouldn't be counted here.
Thanks,
Olek
Alexander Lobakin
maintainerPATCH v3 14/18 idpf: implement XDP_SETUP_PROG in ndo_bpf for splitq
In reply to Alexander LobakinFrom: Michal Kubiak <[email protected]>
Implement loading/removing XDP program using .ndo_bpf callback in the split queue mode. Reconfigure and restart the queues if needed (!!old_prog != !!new_prog), otherwise, just update the pointers.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 4 +- drivers/net/ethernet/intel/idpf/xdp.h | 7 ++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 4 + drivers/net/ethernet/intel/idpf/xdp.c | 98 +++++++++++++++++++++ 5 files changed, 113 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +3 -1
@@ -467,6 +467,7 @@ struct idpf_tx_queue_stats {* @desc_ring: virtual descriptor ring address * @bufq_sets: Pointer to the array of buffer queues in splitq mode * @napi: NAPI instance corresponding to this queue (splitq) +* @xdp_prog: attached XDP program * @rx_buf: See struct &libeth_fqe * @pp: Page pool pointer in singleq mode * @tail: Tail offset. Used for both queue models single and split.
@@ -508,13 +509,14 @@ struct idpf_rx_queue {struct {struct idpf_bufq_set *bufq_sets;struct napi_struct *napi; +struct bpf_prog __rcu *xdp_prog; };struct {struct libeth_fqe *rx_buf;struct page_pool *pp; +void __iomem *tail; }; }; -void __iomem *tail;DECLARE_BITMAP (flags, __IDPF_Q_FLAGS_NBITS);u16 idx;
drivers/net/ethernet/intel/idpf/xdp.h +7 -0
@@ -6,12 +6,19 @@#include <linux/types.h> +struct bpf_prog ;struct idpf_vport ; +struct net_device ; +struct netdev_bpf ;int idpf_xdp_rxq_info_init_all (const struct idpf_vport *vport);void idpf_xdp_rxq_info_deinit_all (const struct idpf_vport *vport); +void idpf_xdp_copy_prog_to_rqs (const struct idpf_vport *vport, +struct bpf_prog *xdp_prog);int idpf_xdpsqs_get (const struct idpf_vport *vport);void idpf_xdpsqs_put (const struct idpf_vport *vport); +int idpf_xdp (struct net_device *dev,struct netdev_bpf *xdp); +#endif /* _IDPF_XDP_H_ */
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
@@ -2521,4 +2521,5 @@ static const struct net_device_ops idpf_netdev_ops = { .ndo_tx_timeout = idpf_tx_timeout, .ndo_hwtstamp_get = idpf_hwtstamp_get, .ndo_hwtstamp_set = idpf_hwtstamp_set, + .ndo_bpf = idpf_xdp, };
drivers/net/ethernet/intel/idpf/idpf_txrx.c +4 -0
@@ -741,6 +741,8 @@ int idpf_rx_bufs_init_all(struct idpf_vport *vport)bool split =idpf_is_queue_model_split (vport->rxq_model);int i, j, err; +idpf_xdp_copy_prog_to_rqs (vport, vport->xdp_prog); +for (i =0 ; i < vport->num_rxq_grp; i++) {struct idpf_rxq_group *rx_qgrp = &vport->rxq_grps[i];u32 truesize =0 ;
@@ -1019,6 +1021,8 @@ static void idpf_vport_queue_grp_rel_all(struct idpf_vport *vport)*/ void idpf_vport_queues_rel (struct idpf_vport *vport) { +idpf_xdp_copy_prog_to_rqs (vport,NULL ); +idpf_tx_desc_rel_all (vport);idpf_rx_desc_rel_all (vport);
drivers/net/ethernet/intel/idpf/xdp.c +98 -0
113 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 15/18 idpf: use generic functions to build xdp_buff and skb
In reply to Alexander LobakinIn preparation of XDP support, move from having skb as the main frame container during the Rx polling to &xdp_buff.
This allows to use generic and libeth helpers for building an XDP buffer and changes the logics: now we try to allocate an skb only when we processed all the descriptors related to the frame. Store &libeth_xdp_stash instead of the skb pointer on the Rx queue. It's only 8 bytes wider, but contains everything we may need.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 17 +- .../ethernet/intel/idpf/idpf_singleq_txrx.c | 104 ++++++------- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 145 +++++------------- 3 files changed, 90 insertions(+), 176 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +7 -10
@@ -484,7 +484,7 @@ struct idpf_tx_queue_stats {* @next_to_use: Next descriptor to use * @next_to_clean: Next descriptor to clean * @next_to_alloc: RX buffer to allocate at -* @skb: Pointer to the skb +* @xdp: XDP buffer with the current frame * @cached_phc_time: Cached PHC time for the Rx queue * @stats_sync: See struct u64_stats_sync * @q_stats: See union idpf_rx_queue_stats
@@ -536,11 +536,11 @@ struct idpf_rx_queue {__cacheline_group_end_aligned (read_mostly);__cacheline_group_begin_aligned (read_write); -u16 next_to_use; -u16 next_to_clean; -u16 next_to_alloc; +u32 next_to_use; +u32 next_to_clean; +u32 next_to_alloc; -struct sk_buff *skb; +struct libeth_xdp_buff_stash xdp;u64 cached_phc_time;struct u64_stats_sync stats_sync;
@@ -563,8 +563,8 @@ struct idpf_rx_queue { libeth_cacheline_set_assert(struct idpf_rx_queue,ALIGN (64 , __alignof(struct xdp_rxq_info )) +sizeof (struct xdp_rxq_info ), -72 + offsetof(struct idpf_rx_queue , q_stats) - - offsetofend(struct idpf_rx_queue, skb), +96 + offsetof(struct idpf_rx_queue , q_stats) - + offsetofend(struct idpf_rx_queue, cached_phc_time), 32);/**
@@ -1047,9 +1047,6 @@ int idpf_config_rss(struct idpf_vport *vport);int idpf_init_rss (struct idpf_vport *vport);void idpf_deinit_rss (struct idpf_vport *vport);int idpf_rx_bufs_init_all (struct idpf_vport *vport); -void idpf_rx_add_frag (struct idpf_rx_buf *rx_buf,struct sk_buff *skb, -unsigned int size); -struct sk_buff *idpf_rx_build_skb (const struct libeth_fqe *buf,u32 size);void idpf_tx_buf_hw_update (struct idpf_tx_queue *tx_q,u32 val,bool xmit_more);unsigned int idpf_size_to_txd_count (unsigned int size);
drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c +47 -57
179 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_txrx.c +36 -109
224 lines not on this page · raw message
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 16/18 idpf: add support for XDP on Rx
In reply to Alexander LobakinUse libeth XDP infra to support running XDP program on Rx polling. This includes all of the possible verdicts/actions.
XDP Tx queues are cleaned only in "lazy" mode when there are less than 1/4 free descriptors left on the ring. libeth helper macros to define driver-specific XDP functions make sure the compiler could uninline them when needed.
Use __LIBETH_WORD_ACCESS to parse descriptors more efficiently when applicable. It really gives some good boosts and code size reduction on x86_64.
--- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 4 +- drivers/net/ethernet/intel/idpf/xdp.h | 92 +++++++++++- drivers/net/ethernet/intel/idpf/idpf_lib.c | 2 + drivers/net/ethernet/intel/idpf/idpf_txrx.c | 23 +-- drivers/net/ethernet/intel/idpf/xdp.c | 147 +++++++++++++++++++- 5 files changed, 248 insertions(+), 20 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.h +2 -2
@@ -646,8 +646,8 @@ struct idpf_tx_queue {__cacheline_group_end_aligned (read_mostly);__cacheline_group_begin_aligned (read_write); -u16 next_to_use; -u16 next_to_clean; +u32 next_to_use; +u32 next_to_clean; union { struct {
drivers/net/ethernet/intel/idpf/xdp.h +87 -5
105 lines not on this page · raw message
drivers/net/ethernet/intel/idpf/idpf_lib.c +2 -0
@@ -835,6 +835,8 @@ static int idpf_cfg_netdev(struct idpf_vport *vport) netdev->hw_features |= netdev->features | other_offloads; netdev->vlan_features |= netdev->features | other_offloads; netdev->hw_enc_features |= dflt_features | other_offloads; +idpf_xdp_set_features (vport); +idpf_set_ethtool_ops (netdev);netif_set_affinity_auto (netdev);SET_NETDEV_DEV (netdev, &adapter->pdev->dev);
drivers/net/ethernet/intel/idpf/idpf_txrx.c +12 -11
@@ -1,8 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright (C) 2023 Intel Corporation */ -#include <net/libeth/xdp.h> -#include "idpf.h" #include "idpf_ptp.h" #include "idpf_virtchnl.h"
@@ -3127,14 +3125,12 @@ static bool idpf_rx_process_skb_fields(struct sk_buff *skb,return !__idpf_rx_process_skb_fields (rxq, skb, xdp->desc); } -static void -idpf_xdp_run_pass (struct libeth_xdp_buff *xdp,struct napi_struct *napi, -struct libeth_rq_napi_stats *ss, -const struct virtchnl2_rx_flex_desc_adv_nic_3 *desc) -{ -libeth_xdp_run_pass (xdp,NULL , napi, ss, desc,NULL , - idpf_rx_process_skb_fields); -} +LIBETH_XDP_DEFINE_START (); +LIBETH_XDP_DEFINE_RUN(static idpf_xdp_run_pass, idpf_xdp_run_prog, + idpf_xdp_tx_flush_bulk, idpf_rx_process_skb_fields); +LIBETH_XDP_DEFINE_FINALIZE(static idpf_xdp_finalize_rx, idpf_xdp_tx_flush_bulk, + idpf_xdp_tx_finalize); +LIBETH_XDP_DEFINE_END ();/** * idpf_rx_hsplit_wa - handle header buffer overflows and split errors
@@ -3222,7 +3218,10 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)struct libeth_rq_napi_stats rs = { };u16 ntc = rxq->next_to_clean;LIBETH_XDP_ONSTACK_BUFF (xdp); +LIBETH_XDP_ONSTACK_BULK (bq); +libeth_xdp_tx_init_bulk (&bq, rxq->xdp_prog, rxq->xdp_rxq.dev, + rxq->xdpsqs, rxq->num_xdp_txq);libeth_xdp_init_buff (xdp, &rxq->xdp, &rxq->xdp_rxq);/* Process Rx packets bounded by budget */
@@ -3318,11 +3317,13 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)if (!idpf_rx_splitq_is_eop (rx_desc) ||unlikely (!xdp->data))continue ; -idpf_xdp_run_pass (xdp, rxq->napi, &rs, rx_desc); +idpf_xdp_run_pass (xdp, &bq, rxq->napi, &rs, rx_desc); } rxq->next_to_clean = ntc; +libeth_xdp_save_buff (&rxq->xdp, xdp); +idpf_xdp_finalize_rx (&bq);u64_stats_update_begin (&rxq->stats_sync);u64_stats_add (&rxq->q_stats.packets, rs.packets);
drivers/net/ethernet/intel/idpf/xdp.c +145 -2
177 lines not on this page · raw message
Signature · 1 line
2.50.1
Simon Horman
reviewerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
+ Kees, linux-hardening
Quoted 10 lines · Alexander Lobakin
Use libeth XDP infra to support running XDP program on Rx polling. This includes all of the possible verdicts/actions.
XDP Tx queues are cleaned only in "lazy" mode when there are less than 1/4 free descriptors left on the ring. libeth helper macros to define driver-specific XDP functions make sure the compiler could uninline them when needed.
Use__LIBETH_WORD_ACCESSto parse descriptors more efficiently when applicable. It really gives some good boosts and code size reduction onx86_64.
Quoted 3 lines
Co-developed-by Michal Kubiak <[email protected]>Signed-off-by Michal Kubiak <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>
Hi Alexander, all,
Sorry for providing review of __LIBETH_WORD_ACCESS[1] after the fact. I had missed it earlier.
While I appreciate the desire for improved performance and nicer code generation. I think the idea of writing 64 bits of data to the address of a 32 bit member of a structure goes against the direction of hardening work by Kees and others.
Indeed, it seems to me this is the kind of thing that struct_group() aims to avoid.
In this case struct group() doesn't seem like the best option, because it would provide a 64-bit buffer that we can memcpy into. But it seems altogether better to simply assign u64 value to a u64 member.
So I'm wondering if an approach along the following lines is appropriate (Very lightly compile tested only!).
And yes, there is room for improvement of the wording of the comment I included below.
include/net/libeth/xdp.h +1 -5
@@ -1283,11 +1283,7 @@ static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,const struct page *page =__netmem_to_page (fqe->netmem);#ifdef __LIBETH_WORD_ACCESS -static_assert (offsetofend (typeof (xdp->base), flags) - - offsetof(typeof(xdp->base), frame_sz) == -sizeof (u64)); - - *(u64 *)&xdp->base.frame_sz = fqe->truesize; + xdp->base.frame_sz_le_qword = fqe->truesize;#else xdp_init_buff (&xdp->base, fqe->truesize, xdp->base.rxq);#endif
include/net/xdp.h +13 -2
@@ -85,8 +85,19 @@ struct xdp_buff {void *data_hard_start;struct xdp_rxq_info *rxq;struct xdp_txq_info *txq; -u32 frame_sz;/* frame size to deduce data_hard_end/reserved tailroom*/ -u32 flags;/* supported values defined in xdp_buff_flags */ +union { +/* Allow setting frame_sz and flags as a single u64 on +* little endian systems. This may may give optimal +* performance. */ +u64 frame_sz_le_qword; +struct { +/* Frame size to deduce data_hard_end/reserved +* tailroom. */ +u32 frame_sz; +/* Supported values defined in xdp_buff_flags. */ +u32 flags; + }; + }; }; static __always_inline bool xdp_buff_has_frags(const struct xdp_buff *xdp)
[1] https://git.kernel.org/torvalds/c/80bae9df2108
...
Re: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
Quoted 4 lines · Simon Horman
While I appreciate the desire for improved performance and nicer code generation. I think the idea of writing 64 bits of data to the address of a 32 bit member of a structure goes against the direction of hardening work by Kees and others.
Agreed: it's better to avoid obscuring these details from the compiler so it can have an "actual" view of the object sizes involved.
Quoted 6 lines
Indeed, it seems to me this is the kind of thing that
struct_group()aims to avoid.In this case struct
group()doesn't seem like the best option, because it would provide a 64-bit buffer that we can memcpy into. But it seems altogether better to simply assign u64 value to a u64 member.
Agreed: with struct_group you get a sized pointer, and while you can provide a struct tag to make it an assignable object, it doesn't make too much sense here.
Quoted 37 lines
So I'm wondering if an approach along the following lines is appropriate (Very lightly compile tested only!).
And yes, there is room for improvement of the wording of the comment I included below.
include/net/libeth/xdp.h +1
-5@@ -1283,11 +1283,7 @@ static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,const struct page *page =__netmem_to_page (fqe->netmem);#ifdef __LIBETH_WORD_ACCESS -static_assert (offsetofend (typeof (xdp->base), flags) - - offsetof(typeof(xdp->base), frame_sz) == -sizeof (u64)); - - *(u64 *)&xdp->base.frame_sz = fqe->truesize; + xdp->base.frame_sz_le_qword = fqe->truesize;#else xdp_init_buff (&xdp->base, fqe->truesize, xdp->base.rxq);#endif include/net/xdp.h +4
-2@@ -85,8 +85,19 @@ struct xdp_buff {void *data_hard_start;struct xdp_rxq_info *rxq;struct xdp_txq_info *txq; -u32 frame_sz;/* frame size to deduce data_hard_end/reserved tailroom*/ -u32 flags;/* supported values defined in xdp_buff_flags */ +union { +/* Allow setting frame_sz and flags as a single u64 on +* little endian systems. This may may give optimal +* performance. */
include/net/xdp.h struct xdp_buff { · line 101
Quoted 10 lines
include/net/xdp.h +9
-0+u64 frame_sz_le_qword; +struct { +/* Frame size to deduce data_hard_end/reserved +* tailroom. */ +u32 frame_sz; +/* Supported values defined in xdp_buff_flags. */ +u32 flags; + }; + }; };
Yeah, this looks like a nice way to express this, and is way more descriptive than "(u64 *)&xdp->base.frame_sz" :)
Signature · 1 line
Kees Cook
Alexander Lobakin
maintainerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
From: Kees Cook <[email protected]>
Date: Thu, 31 Jul 2025 10:05:47 -0700
Quoted 62 lines · Simon Horman
Quoted 4 lines
While I appreciate the desire for improved performance and nicer code generation. I think the idea of writing 64 bits of data to the address of a 32 bit member of a structure goes against the direction of hardening work by Kees and others.
Agreed: it's better to avoid obscuring these details from the compiler so it can have an "actual" view of the object sizes involved.
Quoted 6 lines
Indeed, it seems to me this is the kind of thing that
struct_group()aims to avoid.In this case struct
group()doesn't seem like the best option, because it would provide a 64-bit buffer that we can memcpy into. But it seems altogether better to simply assign u64 value to a u64 member.Agreed: with
struct_groupyou get a sized pointer, and while you can provide a struct tag to make it an assignable object, it doesn't make too much sense here.Quoted 42 lines
So I'm wondering if an approach along the following lines is appropriate (Very lightly compile tested only!).
And yes, there is room for improvement of the wording of the comment I included below.
include/net/libeth/xdp.h +1
-5@@ -1283,11 +1283,7 @@ static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,const struct page *page =__netmem_to_page (fqe->netmem);#ifdef __LIBETH_WORD_ACCESS -static_assert (offsetofend (typeof (xdp->base), flags) - - offsetof(typeof(xdp->base), frame_sz) == -sizeof (u64)); - - *(u64 *)&xdp->base.frame_sz = fqe->truesize; + xdp->base.frame_sz_le_qword = fqe->truesize;#else xdp_init_buff (&xdp->base, fqe->truesize, xdp->base.rxq);#endif include/net/xdp.h +9
-2@@ -85,8 +85,19 @@ struct xdp_buff {void *data_hard_start;struct xdp_rxq_info *rxq;struct xdp_txq_info *txq; -u32 frame_sz;/* frame size to deduce data_hard_end/reserved tailroom*/ -u32 flags;/* supported values defined in xdp_buff_flags */ +union { +/* Allow setting frame_sz and flags as a single u64 on +* little endian systems. This may may give optimal +* performance. */ +u64 frame_sz_le_qword; +struct { +/* Frame size to deduce data_hard_end/reserved +* tailroom. */ +u32 frame_sz;
Quoted 8 lines
include/net/xdp.h struct xdp_buff { · line 101
Quoted 5 lines
include/net/xdp.h +4
-0+/* Supported values defined in xdp_buff_flags. */ +u32 flags; + }; + }; };Yeah, this looks like a nice way to express this, and is way more descriptive than "(u64 *)&xdp->base.frame_sz" :)
Sounds good to me!
Let me send v4 where I'll fix this.
Thanks,
Olek
Alexander Lobakin
maintainerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
From: Alexander Lobakin <[email protected]>
Date: Fri, 1 Aug 2025 15:12:43 +0200
Quoted 74 lines
From: Kees Cook <[email protected]>
Date: Thu, 31 Jul 2025 10:05:47 -0700Quoted 62 lines · Simon Horman
Quoted 4 lines
While I appreciate the desire for improved performance and nicer code generation. I think the idea of writing 64 bits of data to the address of a 32 bit member of a structure goes against the direction of hardening work by Kees and others.
Agreed: it's better to avoid obscuring these details from the compiler so it can have an "actual" view of the object sizes involved.
Quoted 6 lines
Indeed, it seems to me this is the kind of thing that
struct_group()aims to avoid.In this case struct
group()doesn't seem like the best option, because it would provide a 64-bit buffer that we can memcpy into. But it seems altogether better to simply assign u64 value to a u64 member.Agreed: with
struct_groupyou get a sized pointer, and while you can provide a struct tag to make it an assignable object, it doesn't make too much sense here.Quoted 42 lines
So I'm wondering if an approach along the following lines is appropriate (Very lightly compile tested only!).
And yes, there is room for improvement of the wording of the comment I included below.
include/net/libeth/xdp.h +1
-5@@ -1283,11 +1283,7 @@ static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,const struct page *page =__netmem_to_page (fqe->netmem);#ifdef __LIBETH_WORD_ACCESS -static_assert (offsetofend (typeof (xdp->base), flags) - - offsetof(typeof(xdp->base), frame_sz) == -sizeof (u64)); - - *(u64 *)&xdp->base.frame_sz = fqe->truesize; + xdp->base.frame_sz_le_qword = fqe->truesize;#else xdp_init_buff (&xdp->base, fqe->truesize, xdp->base.rxq);#endif include/net/xdp.h +9
-2@@ -85,8 +85,19 @@ struct xdp_buff {void *data_hard_start;struct xdp_rxq_info *rxq;struct xdp_txq_info *txq; -u32 frame_sz;/* frame size to deduce data_hard_end/reserved tailroom*/ -u32 flags;/* supported values defined in xdp_buff_flags */ +union { +/* Allow setting frame_sz and flags as a single u64 on +* little endian systems. This may may give optimal +* performance. */ +u64 frame_sz_le_qword; +struct { +/* Frame size to deduce data_hard_end/reserved +* tailroom. */ +u32 frame_sz;Quoted 8 lines
include/net/xdp.h struct xdp_buff { · line 101
Quoted 5 lines
include/net/xdp.h +4
-0+/* Supported values defined in xdp_buff_flags. */ +u32 flags; + }; + }; };Yeah, this looks like a nice way to express this, and is way more descriptive than "(u64 *)&xdp->base.frame_sz" :)
Quoted 3 lines
Sounds good to me!
Let me send v4 where I'll fix this.
Note: would it be okay if I send v4 with this fix when the window opens, while our validation will retest v3 from Tony's tree in meantine? It's a cosmetic change anyway and does not involve any functional changes.
Thanks,
Olek
Re: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
Quoted 77 lines · Alexander Lobakin
From: Alexander Lobakin <[email protected]>
Date: Fri, 1 Aug 2025 15:12:43 +0200Quoted 74 lines
From: Kees Cook <[email protected]>
Date: Thu, 31 Jul 2025 10:05:47 -0700Quoted 70 lines · Simon Horman
Quoted 4 lines
While I appreciate the desire for improved performance and nicer code generation. I think the idea of writing 64 bits of data to the address of a 32 bit member of a structure goes against the direction of hardening work by Kees and others.
Agreed: it's better to avoid obscuring these details from the compiler so it can have an "actual" view of the object sizes involved.
Quoted 6 lines
Indeed, it seems to me this is the kind of thing that
struct_group()aims to avoid.In this case struct
group()doesn't seem like the best option, because it would provide a 64-bit buffer that we can memcpy into. But it seems altogether better to simply assign u64 value to a u64 member.Agreed: with
struct_groupyou get a sized pointer, and while you can provide a struct tag to make it an assignable object, it doesn't make too much sense here.Quoted 37 lines
So I'm wondering if an approach along the following lines is appropriate (Very lightly compile tested only!).
And yes, there is room for improvement of the wording of the comment I included below.
include/net/libeth/xdp.h +1
-5@@ -1283,11 +1283,7 @@ static inline void libeth_xdp_prepare_buff(struct libeth_xdp_buff *xdp,const struct page *page =__netmem_to_page (fqe->netmem);#ifdef __LIBETH_WORD_ACCESS -static_assert (offsetofend (typeof (xdp->base), flags) - - offsetof(typeof(xdp->base), frame_sz) == -sizeof (u64)); - - *(u64 *)&xdp->base.frame_sz = fqe->truesize; + xdp->base.frame_sz_le_qword = fqe->truesize;#else xdp_init_buff (&xdp->base, fqe->truesize, xdp->base.rxq);#endif include/net/xdp.h +4
-2@@ -85,8 +85,19 @@ struct xdp_buff {void *data_hard_start;struct xdp_rxq_info *rxq;struct xdp_txq_info *txq; -u32 frame_sz;/* frame size to deduce data_hard_end/reserved tailroom*/ -u32 flags;/* supported values defined in xdp_buff_flags */ +union { +/* Allow setting frame_sz and flags as a single u64 on +* little endian systems. This may may give optimal +* performance. */ include/net/xdp.h struct xdp_buff { · line 101
Quoted 10 lines
include/net/xdp.h +9
-0+u64 frame_sz_le_qword; +struct { +/* Frame size to deduce data_hard_end/reserved +* tailroom. */ +u32 frame_sz; +/* Supported values defined in xdp_buff_flags. */ +u32 flags; + }; + }; };Yeah, this looks like a nice way to express this, and is way more descriptive than "(u64 *)&xdp->base.frame_sz" :)
Quoted 7 lines
Quoted 3 lines
Sounds good to me!
Let me send v4 where I'll fix this.
Note: would it be okay if I send v4 with this fix when the window opens, while our validation will retest v3 from Tony's tree in meantine? It's a cosmetic change anyway and does not involve any functional changes.
If this is directed at me, yeah, I don't see any high urgency here.
Signature · 1 line
Kees Cook
Simon Horman
reviewerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
Quoted 8 lines · Kees Cook
Quoted 7 lines · Alexander Lobakin
From: Alexander Lobakin <[email protected]>
Date: Fri, 1 Aug 2025 15:12:43 +0200Quoted 4 lines
From: Kees Cook <[email protected]>
Date: Thu, 31 Jul 2025 10:05:47 -0700Quoted 1 line · Simon Horman
...
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Yeah, this looks like a nice way to express this, and is way more descriptive than "(u64 *)&xdp->base.frame_sz" :)
Sounds good to me!
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Let me send v4 where I'll fix this.
Note: would it be okay if I send v4 with this fix when the window opens, while our validation will retest v3 from Tony's tree in meantine? It's a cosmetic change anyway and does not involve any functional changes.
If this is directed at me, yeah, I don't see any high urgency here.
Likewise, I see no urgency.
Simon Horman
reviewerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
In reply to Alexander LobakinQuoted 13 lines · Alexander Lobakin
Use libeth XDP infra to support running XDP program on Rx polling. This includes all of the possible verdicts/actions.
XDP Tx queues are cleaned only in "lazy" mode when there are less than 1/4 free descriptors left on the ring. libeth helper macros to define driver-specific XDP functions make sure the compiler could uninline them when needed.
Use__LIBETH_WORD_ACCESSto parse descriptors more efficiently when applicable. It really gives some good boosts and code size reduction onx86_64.Co-developed-by Michal Kubiak <[email protected]>Signed-off-by Michal Kubiak <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>
...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0
-0
...
Quoted 34 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +9
-8@@ -3127,14 +3125,12 @@ static bool idpf_rx_process_skb_fields(struct sk_buff *skb,return !__idpf_rx_process_skb_fields (rxq, skb, xdp->desc); } -static void -idpf_xdp_run_pass (struct libeth_xdp_buff *xdp,struct napi_struct *napi, -struct libeth_rq_napi_stats *ss, -const struct virtchnl2_rx_flex_desc_adv_nic_3 *desc) -{ -libeth_xdp_run_pass (xdp,NULL , napi, ss, desc,NULL , - idpf_rx_process_skb_fields); -} +LIBETH_XDP_DEFINE_START (); +LIBETH_XDP_DEFINE_RUN(static idpf_xdp_run_pass, idpf_xdp_run_prog, + idpf_xdp_tx_flush_bulk, idpf_rx_process_skb_fields); +LIBETH_XDP_DEFINE_FINALIZE(static idpf_xdp_finalize_rx, idpf_xdp_tx_flush_bulk, + idpf_xdp_tx_finalize); +LIBETH_XDP_DEFINE_END ();/** * idpf_rx_hsplit_wa - handle header buffer overflows and split errors @@ -3222,7 +3218,10 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)struct libeth_rq_napi_stats rs = { };u16 ntc = rxq->next_to_clean;LIBETH_XDP_ONSTACK_BUFF (xdp); +LIBETH_XDP_ONSTACK_BULK (bq); +libeth_xdp_tx_init_bulk (&bq, rxq->xdp_prog, rxq->xdp_rxq.dev, + rxq->xdpsqs, rxq->num_xdp_txq);libeth_xdp_init_buff (xdp, &rxq->xdp, &rxq->xdp_rxq);/* Process Rx packets bounded by budget */ @@ -3318,11 +3317,13 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)if (!idpf_rx_splitq_is_eop (rx_desc) ||unlikely (!xdp->data))
drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3326
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +3
-1continue ; -idpf_xdp_run_pass (xdp, rxq->napi, &rs, rx_desc); +idpf_xdp_run_pass (xdp, &bq, rxq->napi, &rs, rx_desc); } rxq->next_to_clean = ntc; +libeth_xdp_save_buff (&rxq->xdp, xdp); +idpf_xdp_finalize_rx (&bq);
This will call __libeth_xdp_finalize_rx(), which calls rcu_read_unlock(). But there doesn't seem to be a corresponding call to rcu_read_lock()
Flagged by Sparse.
Quoted 3 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0
-0u64_stats_update_begin (&rxq->stats_sync);u64_stats_add (&rxq->q_stats.packets, rs.packets);
...
Alexander Lobakin
maintainerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
From: Simon Horman <[email protected]>
Date: Thu, 31 Jul 2025 14:35:57 +0100
Quoted 69 lines · Alexander Lobakin
Quoted 13 lines
Use libeth XDP infra to support running XDP program on Rx polling. This includes all of the possible verdicts/actions.
XDP Tx queues are cleaned only in "lazy" mode when there are less than 1/4 free descriptors left on the ring. libeth helper macros to define driver-specific XDP functions make sure the compiler could uninline them when needed.
Use__LIBETH_WORD_ACCESSto parse descriptors more efficiently when applicable. It really gives some good boosts and code size reduction onx86_64.Co-developed-by Michal Kubiak <[email protected]>Signed-off-by Michal Kubiak <[email protected]>Signed-off-by Alexander Lobakin <[email protected]>...
Quoted 1 line
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0
-0...
Quoted 34 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +9
-8@@ -3127,14 +3125,12 @@ static bool idpf_rx_process_skb_fields(struct sk_buff *skb,return !__idpf_rx_process_skb_fields (rxq, skb, xdp->desc); } -static void -idpf_xdp_run_pass (struct libeth_xdp_buff *xdp,struct napi_struct *napi, -struct libeth_rq_napi_stats *ss, -const struct virtchnl2_rx_flex_desc_adv_nic_3 *desc) -{ -libeth_xdp_run_pass (xdp,NULL , napi, ss, desc,NULL , - idpf_rx_process_skb_fields); -} +LIBETH_XDP_DEFINE_START (); +LIBETH_XDP_DEFINE_RUN(static idpf_xdp_run_pass, idpf_xdp_run_prog, + idpf_xdp_tx_flush_bulk, idpf_rx_process_skb_fields); +LIBETH_XDP_DEFINE_FINALIZE(static idpf_xdp_finalize_rx, idpf_xdp_tx_flush_bulk, + idpf_xdp_tx_finalize); +LIBETH_XDP_DEFINE_END ();/** * idpf_rx_hsplit_wa - handle header buffer overflows and split errors @@ -3222,7 +3218,10 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)struct libeth_rq_napi_stats rs = { };u16 ntc = rxq->next_to_clean;LIBETH_XDP_ONSTACK_BUFF (xdp); +LIBETH_XDP_ONSTACK_BULK (bq); +libeth_xdp_tx_init_bulk (&bq, rxq->xdp_prog, rxq->xdp_rxq.dev, + rxq->xdpsqs, rxq->num_xdp_txq);libeth_xdp_init_buff (xdp, &rxq->xdp, &rxq->xdp_rxq);/* Process Rx packets bounded by budget */ @@ -3318,11 +3317,13 @@ static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget)if (!idpf_rx_splitq_is_eop (rx_desc) ||unlikely (!xdp->data))drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3326
Quoted 10 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +3
-1continue ; -idpf_xdp_run_pass (xdp, rxq->napi, &rs, rx_desc); +idpf_xdp_run_pass (xdp, &bq, rxq->napi, &rs, rx_desc); } rxq->next_to_clean = ntc; +libeth_xdp_save_buff (&rxq->xdp, xdp); +idpf_xdp_finalize_rx (&bq);This will call
__libeth_xdp_finalize_rx(), which callsrcu_read_unlock(). But there doesn't seem to be a corresponding call torcu_read_lock()
Quoted 1 line
Flagged by Sparse.
It's false-positive, rcu_read_lock() is called in tx_init_bulk().
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c static int idpf_rx_splitq_clean(struct idpf_rx_queue *rxq, int budget) · line 3329
Quoted 4 lines
drivers/net/ethernet/intel/idpf/idpf_txrx.c +0
-0u64_stats_update_begin (&rxq->stats_sync);u64_stats_add (&rxq->q_stats.packets, rs.packets);
Thanks,
Olek
Jakub Kicinski
maintainerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
In reply to Alexander LobakinQuoted 3 lines · On Wed, 30 Jul 2025 18:07:15 +0200 Alexander Lobakin wrote:
Use
__LIBETH_WORD_ACCESSto parse descriptors more efficiently when applicable. It really gives some good boosts and code size reduction onx86_64.
Could you perhaps quantify the goodness of the boost with a number? :)
Alexander Lobakin
maintainerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
From: Jakub Kicinski <[email protected]>
Date: Fri, 1 Aug 2025 15:33:43 -0700
Quoted 6 lines · On Wed, 30 Jul 2025 18:07:15 +0200 Alexander Lobakin wrote:
Quoted 3 lines
Use
__LIBETH_WORD_ACCESSto parse descriptors more efficiently when applicable. It really gives some good boosts and code size reduction onx86_64.Could you perhaps quantify the goodness of the boost with a number? :)
Sure, only a matter of switching this definition and running the tests (and bloat-o-meter).
Intel doesn't allow us to publish raw numbers (Gbps/Mpps), I hope the diff in percents (+ bloat-o-meter output) would be enough?
Thanks,
Olek
Jakub Kicinski
maintainerRe: [PATCH iwl-next v3 16/18] idpf: add support for XDP on Rx
Quoted 8 lines · On Tue, 5 Aug 2025 18:09:40 +0200 Alexander Lobakin wrote:
From: Jakub Kicinski <[email protected]>
Date: Fri, 1 Aug 2025 15:33:43 -0700Quoted 5 lines · On Wed, 30 Jul 2025 18:07:15 +0200 Alexander Lobakin wrote:
Quoted 3 lines
Use
__LIBETH_WORD_ACCESSto parse descriptors more efficiently when applicable. It really gives some good boosts and code size reduction onx86_64.
Quoted 6 lines
Quoted 1 line
Could you perhaps quantify the goodness of the boost with a number? :)
Sure, only a matter of switching this definition and running the tests (and bloat-o-meter).
Intel doesn't allow us to publish raw numbers (Gbps/Mpps), I hope the diff in percents (+ bloat-o-meter output) would be enough?
Yes, delta is perfect. Absolute numbers aren't very meaningful if you don't specify all HW components and FW versions, and direction of wind on the day, anyway :$
Alexander Lobakin
maintainerPATCH v3 17/18 idpf: add support for .ndo_xdp_xmit()
In reply to Alexander LobakinUse libeth XDP infra to implement .ndo_xdp_xmit() in idpf. The Tx callbacks are reused from XDP_TX code. XDP redirect target feature is set/cleared depending on the XDP prog presence, as for now we still don't allocate XDP Tx queues when there's no program.
--- drivers/net/ethernet/intel/idpf/xdp.h | 2 ++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 1 + drivers/net/ethernet/intel/idpf/xdp.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+)
drivers/net/ethernet/intel/idpf/xdp.h +2 -0
@@ -102,5 +102,7 @@ static inline void idpf_xdp_tx_finalize(void *_xdpsq, bool sent, bool flush)void idpf_xdp_set_features (const struct idpf_vport *vport);int idpf_xdp (struct net_device *dev,struct netdev_bpf *xdp); +int idpf_xdp_xmit (struct net_device *dev,int n,struct xdp_frame **frames, +u32 flags);#endif /* _IDPF_XDP_H_ */
drivers/net/ethernet/intel/idpf/idpf_lib.c +1 -0
@@ -2524,4 +2524,5 @@ static const struct net_device_ops idpf_netdev_ops = { .ndo_hwtstamp_get = idpf_hwtstamp_get, .ndo_hwtstamp_set = idpf_hwtstamp_set, .ndo_bpf = idpf_xdp, + .ndo_xdp_xmit = idpf_xdp_xmit, };
drivers/net/ethernet/intel/idpf/xdp.c +20 -0
@@ -320,8 +320,26 @@ LIBETH_XDP_DEFINE_START(); LIBETH_XDP_DEFINE_TIMER(static idpf_xdp_tx_timer, idpf_xdpsq_complete);LIBETH_XDP_DEFINE_FLUSH_TX (idpf_xdp_tx_flush_bulk, idpf_xdp_tx_prep, idpf_xdp_tx_xmit); +LIBETH_XDP_DEFINE_FLUSH_XMIT(static idpf_xdp_xmit_flush_bulk, idpf_xdp_tx_prep, + idpf_xdp_tx_xmit);LIBETH_XDP_DEFINE_END (); +int idpf_xdp_xmit (struct net_device *dev,int n,struct xdp_frame **frames, +u32 flags) +{ +const struct idpf_netdev_priv *np =netdev_priv (dev); +const struct idpf_vport *vport = np->vport; + +if (unlikely (!netif_carrier_ok (dev) || !vport->link_up)) +return -ENETDOWN ; + +return libeth_xdp_xmit_do_bulk (dev, n, frames, flags, + &vport->txqs[vport->xdp_txq_offset], + vport->num_xdp_txq, + idpf_xdp_xmit_flush_bulk, + idpf_xdp_tx_finalize); +} +void idpf_xdp_set_features (const struct idpf_vport *vport) {if (!idpf_is_queue_model_split (vport->rxq_model))
@@ -376,6 +394,8 @@ static int idpf_xdp_setup_prog(struct idpf_vport *vport,if (old)bpf_prog_put (old); +libeth_xdp_set_redirect (vport->netdev, vport->xdp_prog); +return ret; }
Signature · 1 line
2.50.1
Alexander Lobakin
maintainerPATCH v3 18/18 idpf: add XDP RSS hash hint
In reply to Alexander LobakinAdd &xdp_metadata_ops with a callback to get RSS hash hint from the descriptor. Declare the splitq 32-byte descriptor as 4 u64s to parse them more efficiently when possible.
--- drivers/net/ethernet/intel/idpf/xdp.h | 64 +++++++++++++++++++++++++++ drivers/net/ethernet/intel/idpf/xdp.c | 28 +++++++++++- 2 files changed, 91 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/idpf/xdp.h +64 -0
@@ -99,6 +99,70 @@ static inline void idpf_xdp_tx_finalize(void *_xdpsq, bool sent, bool flush)libeth_xdpsq_unlock (&xdpsq->xdp_lock); } +struct idpf_xdp_rx_desc { +aligned_u64 qw0; +#define IDPF_XDP_RX_BUFQ BIT_ULL(47) +#define IDPF_XDP_RX_GEN BIT_ULL(46) +#define IDPF_XDP_RX_LEN GENMASK_ULL(45, 32) +#define IDPF_XDP_RX_PT GENMASK_ULL(25, 16) + +aligned_u64 qw1; +#define IDPF_XDP_RX_BUF GENMASK_ULL(47, 32) +#define IDPF_XDP_RX_EOP BIT_ULL(1) + +aligned_u64 qw2; +#define IDPF_XDP_RX_HASH GENMASK_ULL(31, 0) + +aligned_u64 qw3; +}__aligned(4 * sizeof(u64)) ; +static_assert (sizeof (struct idpf_xdp_rx_desc ) == +sizeof (struct virtchnl2_rx_flex_desc_adv_nic_3 )); + +#define idpf_xdp_rx_bufq (desc) !!((desc)->qw0 & IDPF_XDP_RX_BUFQ) +#define idpf_xdp_rx_gen (desc) !!((desc)->qw0 & IDPF_XDP_RX_GEN) +#define idpf_xdp_rx_len (desc) FIELD_GET(IDPF_XDP_RX_LEN, (desc)->qw0) +#define idpf_xdp_rx_pt (desc) FIELD_GET(IDPF_XDP_RX_PT, (desc)->qw0) +#define idpf_xdp_rx_buf (desc) FIELD_GET(IDPF_XDP_RX_BUF, (desc)->qw1) +#define idpf_xdp_rx_eop (desc) !!((desc)->qw1 & IDPF_XDP_RX_EOP) +#define idpf_xdp_rx_hash (desc) FIELD_GET(IDPF_XDP_RX_HASH, (desc)->qw2) + +static inline void +idpf_xdp_get_qw0 (struct idpf_xdp_rx_desc *desc, +const struct virtchnl2_rx_flex_desc_adv_nic_3 *rxd) +{ +#ifdef __LIBETH_WORD_ACCESS + desc->qw0 = ((const typeof (desc ))rxd)->qw0; +#else + desc->qw0 = ((u64 )le16_to_cpu (rxd->pktlen_gen_bufq_id) <<32 ) | + ((u64 )le16_to_cpu (rxd->ptype_err_fflags0) <<16 ); +#endif +} + +static inline void +idpf_xdp_get_qw1 (struct idpf_xdp_rx_desc *desc, +const struct virtchnl2_rx_flex_desc_adv_nic_3 *rxd) +{ +#ifdef __LIBETH_WORD_ACCESS + desc->qw1 = ((const typeof (desc ))rxd)->qw1; +#else + desc->qw1 = ((u64 )le16_to_cpu (rxd->buf_id) <<32 ) | + rxd->status_err0_qw1; +#endif +} + +static inline void +idpf_xdp_get_qw2 (struct idpf_xdp_rx_desc *desc, +const struct virtchnl2_rx_flex_desc_adv_nic_3 *rxd) +{ +#ifdef __LIBETH_WORD_ACCESS + desc->qw2 = ((const typeof (desc ))rxd)->qw2; +#else + desc->qw2 = ((u64 )rxd->hash3 <<24 ) | + ((u64 )rxd->ff2_mirrid_hash2.hash2 <<16 ) | +le16_to_cpu (rxd->hash1); +#endif +} +void idpf_xdp_set_features (const struct idpf_vport *vport);int idpf_xdp (struct net_device *dev,struct netdev_bpf *xdp);
drivers/net/ethernet/intel/idpf/xdp.c +27 -1
@@ -340,12 +340,38 @@ int idpf_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, idpf_xdp_tx_finalize); } +static int idpf_xdpmo_rx_hash (const struct xdp_md *ctx,u32 *hash, +enum xdp_rss_hash_type *rss_type) +{ +const struct libeth_xdp_buff *xdp = (typeof (xdp ))ctx; + struct idpf_xdp_rx_desc desc __uninitialized; +const struct idpf_rx_queue *rxq; +struct libeth_rx_pt pt; + + rxq =libeth_xdp_buff_to_rq (xdp,typeof (*rxq), xdp_rxq); + +idpf_xdp_get_qw0 (&desc, xdp->desc); + + pt = rxq->rx_ptype_lkup[idpf_xdp_rx_pt (&desc)]; +if (!libeth_rx_pt_has_hash (rxq->xdp_rxq.dev, pt)) +return -ENODATA ; + +idpf_xdp_get_qw2 (&desc, xdp->desc); + +return libeth_xdpmo_rx_hash (hash, rss_type,idpf_xdp_rx_hash (&desc), + pt); +} + +static const struct xdp_metadata_ops idpf_xdpmo = { + .xmo_rx_hash = idpf_xdpmo_rx_hash, +}; +void idpf_xdp_set_features (const struct idpf_vport *vport) {if (!idpf_is_queue_model_split (vport->rxq_model))return ; -libeth_xdp_set_features_noredir (vport->netdev); +libeth_xdp_set_features_noredir (vport->netdev, &idpf_xdpmo); } static int idpf_xdp_setup_prog(struct idpf_vport *vport,
Signature · 1 line
2.50.1