Skip to content

Commit 14f662b

Browse files
alobakinanguy11
authored andcommitted
idpf: merge singleq and splitq &net_device_ops
It makes no sense to have a second &net_device_ops struct (800 bytes of rodata) with only one difference in .ndo_start_xmit, which can easily be just one `if`. This `if` is a drop in the ocean and you won't see any difference. Define unified idpf_xmit_start(). The preparation for sending is the same, just call either idpf_tx_splitq_frame() or idpf_tx_singleq_frame() depending on the active model to actually map and send the skb. Reviewed-by: Przemek Kitszel <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Signed-off-by: Alexander Lobakin <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 5a816aa commit 14f662b

File tree

4 files changed

+20
-63
lines changed

4 files changed

+20
-63
lines changed

drivers/net/ethernet/intel/idpf/idpf_lib.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include "idpf.h"
55
#include "idpf_virtchnl.h"
66

7-
static const struct net_device_ops idpf_netdev_ops_splitq;
8-
static const struct net_device_ops idpf_netdev_ops_singleq;
7+
static const struct net_device_ops idpf_netdev_ops;
98

109
/**
1110
* idpf_init_vector_stack - Fill the MSIX vector stack with vector index
@@ -764,10 +763,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport)
764763
}
765764

766765
/* assign netdev_ops */
767-
if (idpf_is_queue_model_split(vport->txq_model))
768-
netdev->netdev_ops = &idpf_netdev_ops_splitq;
769-
else
770-
netdev->netdev_ops = &idpf_netdev_ops_singleq;
766+
netdev->netdev_ops = &idpf_netdev_ops;
771767

772768
/* setup watchdog timeout value to be 5 second */
773769
netdev->watchdog_timeo = 5 * HZ;
@@ -2352,24 +2348,10 @@ void idpf_free_dma_mem(struct idpf_hw *hw, struct idpf_dma_mem *mem)
23522348
mem->pa = 0;
23532349
}
23542350

2355-
static const struct net_device_ops idpf_netdev_ops_splitq = {
2356-
.ndo_open = idpf_open,
2357-
.ndo_stop = idpf_stop,
2358-
.ndo_start_xmit = idpf_tx_splitq_start,
2359-
.ndo_features_check = idpf_features_check,
2360-
.ndo_set_rx_mode = idpf_set_rx_mode,
2361-
.ndo_validate_addr = eth_validate_addr,
2362-
.ndo_set_mac_address = idpf_set_mac,
2363-
.ndo_change_mtu = idpf_change_mtu,
2364-
.ndo_get_stats64 = idpf_get_stats64,
2365-
.ndo_set_features = idpf_set_features,
2366-
.ndo_tx_timeout = idpf_tx_timeout,
2367-
};
2368-
2369-
static const struct net_device_ops idpf_netdev_ops_singleq = {
2351+
static const struct net_device_ops idpf_netdev_ops = {
23702352
.ndo_open = idpf_open,
23712353
.ndo_stop = idpf_stop,
2372-
.ndo_start_xmit = idpf_tx_singleq_start,
2354+
.ndo_start_xmit = idpf_tx_start,
23732355
.ndo_features_check = idpf_features_check,
23742356
.ndo_set_rx_mode = idpf_set_rx_mode,
23752357
.ndo_validate_addr = eth_validate_addr,

drivers/net/ethernet/intel/idpf/idpf_singleq_txrx.c

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ static void idpf_tx_singleq_build_ctx_desc(struct idpf_tx_queue *txq,
351351
*
352352
* Returns NETDEV_TX_OK if sent, else an error code
353353
*/
354-
static netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb,
355-
struct idpf_tx_queue *tx_q)
354+
netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb,
355+
struct idpf_tx_queue *tx_q)
356356
{
357357
struct idpf_tx_offload_params offload = { };
358358
struct idpf_tx_buf *first;
@@ -408,33 +408,6 @@ static netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb,
408408
return idpf_tx_drop_skb(tx_q, skb);
409409
}
410410

411-
/**
412-
* idpf_tx_singleq_start - Selects the right Tx queue to send buffer
413-
* @skb: send buffer
414-
* @netdev: network interface device structure
415-
*
416-
* Returns NETDEV_TX_OK if sent, else an error code
417-
*/
418-
netdev_tx_t idpf_tx_singleq_start(struct sk_buff *skb,
419-
struct net_device *netdev)
420-
{
421-
struct idpf_vport *vport = idpf_netdev_to_vport(netdev);
422-
struct idpf_tx_queue *tx_q;
423-
424-
tx_q = vport->txqs[skb_get_queue_mapping(skb)];
425-
426-
/* hardware can't handle really short frames, hardware padding works
427-
* beyond this point
428-
*/
429-
if (skb_put_padto(skb, IDPF_TX_MIN_PKT_LEN)) {
430-
idpf_tx_buf_hw_update(tx_q, tx_q->next_to_use, false);
431-
432-
return NETDEV_TX_OK;
433-
}
434-
435-
return idpf_tx_singleq_frame(skb, tx_q);
436-
}
437-
438411
/**
439412
* idpf_tx_singleq_clean - Reclaim resources from queue
440413
* @tx_q: Tx queue to clean

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#include "idpf.h"
55
#include "idpf_virtchnl.h"
66

7+
static bool idpf_chk_linearize(struct sk_buff *skb, unsigned int max_bufs,
8+
unsigned int count);
9+
710
/**
811
* idpf_buf_lifo_push - push a buffer pointer onto stack
912
* @stack: pointer to stack struct
@@ -2702,8 +2705,8 @@ static bool __idpf_chk_linearize(struct sk_buff *skb, unsigned int max_bufs)
27022705
* E.g.: a packet with 7 fragments can require 9 DMA transactions; 1 for TSO
27032706
* header, 1 for segment payload, and then 7 for the fragments.
27042707
*/
2705-
bool idpf_chk_linearize(struct sk_buff *skb, unsigned int max_bufs,
2706-
unsigned int count)
2708+
static bool idpf_chk_linearize(struct sk_buff *skb, unsigned int max_bufs,
2709+
unsigned int count)
27072710
{
27082711
if (likely(count < max_bufs))
27092712
return false;
@@ -2849,14 +2852,13 @@ static netdev_tx_t idpf_tx_splitq_frame(struct sk_buff *skb,
28492852
}
28502853

28512854
/**
2852-
* idpf_tx_splitq_start - Selects the right Tx queue to send buffer
2855+
* idpf_tx_start - Selects the right Tx queue to send buffer
28532856
* @skb: send buffer
28542857
* @netdev: network interface device structure
28552858
*
28562859
* Returns NETDEV_TX_OK if sent, else an error code
28572860
*/
2858-
netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb,
2859-
struct net_device *netdev)
2861+
netdev_tx_t idpf_tx_start(struct sk_buff *skb, struct net_device *netdev)
28602862
{
28612863
struct idpf_vport *vport = idpf_netdev_to_vport(netdev);
28622864
struct idpf_tx_queue *tx_q;
@@ -2878,7 +2880,10 @@ netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb,
28782880
return NETDEV_TX_OK;
28792881
}
28802882

2881-
return idpf_tx_splitq_frame(skb, tx_q);
2883+
if (idpf_is_queue_model_split(vport->txq_model))
2884+
return idpf_tx_splitq_frame(skb, tx_q);
2885+
else
2886+
return idpf_tx_singleq_frame(skb, tx_q);
28822887
}
28832888

28842889
/**

drivers/net/ethernet/intel/idpf/idpf_txrx.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,14 +1198,11 @@ void idpf_tx_dma_map_error(struct idpf_tx_queue *txq, struct sk_buff *skb,
11981198
struct idpf_tx_buf *first, u16 ring_idx);
11991199
unsigned int idpf_tx_desc_count_required(struct idpf_tx_queue *txq,
12001200
struct sk_buff *skb);
1201-
bool idpf_chk_linearize(struct sk_buff *skb, unsigned int max_bufs,
1202-
unsigned int count);
12031201
int idpf_tx_maybe_stop_common(struct idpf_tx_queue *tx_q, unsigned int size);
12041202
void idpf_tx_timeout(struct net_device *netdev, unsigned int txqueue);
1205-
netdev_tx_t idpf_tx_splitq_start(struct sk_buff *skb,
1206-
struct net_device *netdev);
1207-
netdev_tx_t idpf_tx_singleq_start(struct sk_buff *skb,
1208-
struct net_device *netdev);
1203+
netdev_tx_t idpf_tx_singleq_frame(struct sk_buff *skb,
1204+
struct idpf_tx_queue *tx_q);
1205+
netdev_tx_t idpf_tx_start(struct sk_buff *skb, struct net_device *netdev);
12091206
bool idpf_rx_singleq_buf_hw_alloc_all(struct idpf_rx_queue *rxq,
12101207
u16 cleaned_count);
12111208
int idpf_tso(struct sk_buff *skb, struct idpf_tx_offload_params *off);

0 commit comments

Comments
 (0)