Support for dynamic queue size changes
Subsystems (3)
v3 cover Support for dynamic queue size changes
From: Sameeh Jubran <[email protected]>
This patchset introduces the following:
* add new admin command for supporting different queue size for Tx/Rx
* add support for Tx/Rx queues size modification through ethtool
* allow queues allocation backoff when low on memory
* update driver version
Difference from v2:
* Dropped superfluous range checks which are already done in ethtool. [patch 5/7]
* Dropped inline keyword from function. [patch 4/7]
* Added a new patch which drops inline keyword all *.c files. [patch 6/7]
Difference from v1:
* Changed ena_update_queue_sizes() signature to use u32 instead of int type for the size arguments. [patch 5/7]
Arthur Kiyanovski (1):
net: ena: add MAX_QUEUES_EXT get feature admin command
Sameeh Jubran (6):
net: ena: enable negotiating larger Rx ring size
net: ena: make ethtool show correct current and max queue sizes
net: ena: allow queue allocation backoff when low on memory
net: ena: add ethtool function for changing io queue sizes
net: ena: remove inline keyword from functions in *.c
net: ena: update driver version from 2.0.3 to 2.1.0
.../net/ethernet/amazon/ena/ena_admin_defs.h | 56 ++- drivers/net/ethernet/amazon/ena/ena_com.c | 82 +++-- drivers/net/ethernet/amazon/ena/ena_com.h | 3 + drivers/net/ethernet/amazon/ena/ena_eth_com.c | 26 +- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 32 +- drivers/net/ethernet/amazon/ena/ena_netdev.c | 319 +++++++++++++----- drivers/net/ethernet/amazon/ena/ena_netdev.h | 28 +- 7 files changed, 403 insertions(+), 143 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/7 net: ena: add MAX_QUEUES_EXT get feature admin command
From: Arthur Kiyanovski <[email protected]>
Add a new admin command to support different queue size for Tx/Rx queues (the change also support different SQ/CQ sizes)
--- .../net/ethernet/amazon/ena/ena_admin_defs.h | 56 +++++++++++++- drivers/net/ethernet/amazon/ena/ena_com.c | 76 ++++++++++++------- drivers/net/ethernet/amazon/ena/ena_com.h | 3 + 3 files changed, 105 insertions(+), 30 deletions(-)
drivers/net/ethernet/amazon/ena/ena_admin_defs.h +54 -2
@@ -64,6 +64,7 @@ enum ena_admin_aq_feature_id {ENA_ADMIN_LLQ =4 ,ENA_ADMIN_EXTRA_PROPERTIES_STRINGS =5 ,ENA_ADMIN_EXTRA_PROPERTIES_FLAGS =6 , +ENA_ADMIN_MAX_QUEUES_EXT =7 ,ENA_ADMIN_RSS_HASH_FUNCTION =10 ,ENA_ADMIN_STATELESS_OFFLOAD_CONFIG =11 , ENA_ADMIN_RSS_REDIRECTION_TABLE_CONFIG = 12,
@@ -425,7 +426,13 @@ struct ena_admin_get_set_feature_common_desc {/* as appears in ena_admin_aq_feature_id */ u8 feature_id; -u16 reserved16; +/* The driver specifies the max feature version it supports and the +* device responds with the currently supported feature version. The +* field is zero based +*/ +u8 feature_version; + +u8 reserved8; };struct ena_admin_device_attr_feature_desc {
@@ -535,6 +542,34 @@ struct ena_admin_feature_llq_desc {u32 max_tx_burst_size; }; +struct ena_admin_queue_ext_feature_fields { +u32 max_tx_sq_num; + +u32 max_tx_cq_num; + +u32 max_rx_sq_num; + +u32 max_rx_cq_num; + +u32 max_tx_sq_depth; + +u32 max_tx_cq_depth; + +u32 max_rx_sq_depth; + +u32 max_rx_cq_depth; + +u32 max_tx_header_size; + +/* Maximum Descriptors number, including meta descriptor, allowed for +* a single Tx packet +*/ +u16 max_per_packet_tx_descs; + +/* Maximum Descriptors number allowed for a single Rx packet */ +u16 max_per_packet_rx_descs; +}; +struct ena_admin_queue_feature_desc {u32 max_sq_num;
@@ -849,6 +884,19 @@ struct ena_admin_get_feat_cmd {u32 raw[11 ]; }; +struct ena_admin_queue_ext_feature_desc { +/* version */ +u8 version; + +u8 reserved1[3 ]; + +union { +struct ena_admin_queue_ext_feature_fields max_queue_ext; + +u32 raw[10 ]; + }; +}; +struct ena_admin_get_feat_resp {struct ena_admin_acq_common_desc acq_common_desc;
@@ -861,6 +909,8 @@ struct ena_admin_get_feat_resp {struct ena_admin_queue_feature_desc max_queue; +struct ena_admin_queue_ext_feature_desc max_queue_ext; +struct ena_admin_feature_aenq_desc aenq;struct ena_admin_get_feature_link_desc link;
@@ -929,7 +979,9 @@ struct ena_admin_aenq_common_desc {u16 syndrom; -/* 0 : phase */ +/* 0 : phase +* 7:1 : reserved - MBZ +*/ u8 flags;u8 reserved1[3 ];
drivers/net/ethernet/amazon/ena/ena_com.c +48 -28
204 lines not on this page · raw message
drivers/net/ethernet/amazon/ena/ena_com.h +3 -0
@@ -101,6 +101,8 @@#define ENA_HW_HINTS_NO_TIMEOUT 0xFFFF +#define ENA_FEATURE_MAX_QUEUE_EXT_VER 1 +enum ena_intr_moder_level {ENA_INTR_MODER_LOWEST =0 ,ENA_INTR_MODER_LOW ,
@@ -389,6 +391,7 @@ struct ena_com_dev {struct ena_com_dev_get_features_ctx {struct ena_admin_queue_feature_desc max_queues; +struct ena_admin_queue_ext_feature_desc max_queue_ext;struct ena_admin_device_attr_feature_desc dev_attr;struct ena_admin_feature_aenq_desc aenq;struct ena_admin_feature_offload_desc offload;
Signature · 1 line
2.17.1
PATCH v3 2/7 net: ena: enable negotiating larger Rx ring size
In reply to [email protected]From: Sameeh Jubran <[email protected]>
Use MAX_QUEUES_EXT get feature capability to query the device.
--- drivers/net/ethernet/amazon/ena/ena_netdev.c | 144 ++++++++++++------- drivers/net/ethernet/amazon/ena/ena_netdev.h | 15 ++ 2 files changed, 110 insertions(+), 49 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.c +95 -49
@@ -2465,13 +2465,6 @@ static int ena_device_validate_params(struct ena_adapter *adapter,return -EINVAL ; } -if ((get_feat_ctx->max_queues.max_cq_num < adapter->num_queues) || - (get_feat_ctx->max_queues.max_sq_num < adapter->num_queues)) { -netif_err (adapter, drv, netdev, -"Error, device doesn't support enough queues\n" ); -return -EINVAL ; - } -if (get_feat_ctx->dev_attr.max_mtu < netdev->mtu) {netif_err (adapter, drv, netdev,"Error, device max mtu is smaller than netdev MTU\n" );
@@ -3045,18 +3038,32 @@ static int ena_calc_io_queue_num(struct pci_dev *pdev,struct ena_com_dev *ena_dev, struct ena_com_dev_get_features_ctx *get_feat_ctx) { - int io_sq_num, io_queue_num; + int io_tx_sq_num, io_tx_cq_num, io_rx_num, io_queue_num; + +if (ena_dev->supported_features &BIT (ENA_ADMIN_MAX_QUEUES_EXT )) { +struct ena_admin_queue_ext_feature_fields *max_queue_ext = + &get_feat_ctx->max_queue_ext.max_queue_ext; + io_rx_num =min_t (int, max_queue_ext->max_rx_sq_num, + max_queue_ext->max_rx_cq_num); -/* In case of LLQ use the llq number in the get feature cmd */ + io_tx_sq_num = max_queue_ext->max_tx_sq_num; + io_tx_cq_num = max_queue_ext->max_tx_cq_num; + }else { +struct ena_admin_queue_feature_desc *max_queues = + &get_feat_ctx->max_queues; + io_tx_sq_num = max_queues->max_sq_num; + io_tx_cq_num = max_queues->max_cq_num; + io_rx_num =min_t (int, io_tx_sq_num, io_tx_cq_num); + } + +/* In case of LLQ use the llq fields for the tx SQ/CQ */ if (ena_dev->tx_mem_queue_type ==ENA_ADMIN_PLACEMENT_POLICY_DEV ) - io_sq_num = get_feat_ctx->llq.max_llq_num; -else - io_sq_num = get_feat_ctx->max_queues.max_sq_num; + io_tx_sq_num = get_feat_ctx->llq.max_llq_num; io_queue_num =min_t (int,num_online_cpus (),ENA_MAX_NUM_IO_QUEUES ); - io_queue_num =min_t (int, io_queue_num, io_sq_num); - io_queue_num =min_t (int, io_queue_num, - get_feat_ctx->max_queues.max_cq_num); + io_queue_num =min_t (int, io_queue_num, io_rx_num); + io_queue_num =min_t (int, io_queue_num, io_tx_sq_num); + io_queue_num =min_t (int, io_queue_num, io_tx_cq_num);/* 1 IRQ for for mgmnt and 1 IRQs for each IO direction */ io_queue_num =min_t (int, io_queue_num,pci_msix_vec_count (pdev) -1 );if (unlikely (!io_queue_num)) {
@@ -3239,36 +3246,73 @@ static inline void set_default_llq_configurations(struct ena_llq_configurations llq_config->llq_ring_entry_size_value =128 ; } -static int ena_calc_queue_size (struct pci_dev *pdev, -struct ena_com_dev *ena_dev, -u16 *max_tx_sgl_size, -u16 *max_rx_sgl_size, -struct ena_com_dev_get_features_ctx *get_feat_ctx) +static int ena_calc_queue_size (struct ena_calc_queue_size_ctx *ctx) { -u32 queue_size =ENA_DEFAULT_RING_SIZE ; +struct ena_admin_feature_llq_desc *llq = &ctx->get_feat_ctx->llq; +struct ena_com_dev *ena_dev = ctx->ena_dev; +u32 tx_queue_size =ENA_DEFAULT_RING_SIZE ; +u32 rx_queue_size =ENA_DEFAULT_RING_SIZE ; +u32 max_tx_queue_size; +u32 max_rx_queue_size; - queue_size =min_t (u32, queue_size, - get_feat_ctx->max_queues.max_cq_depth); - queue_size =min_t (u32, queue_size, - get_feat_ctx->max_queues.max_sq_depth); +if (ctx->ena_dev->supported_features &BIT (ENA_ADMIN_MAX_QUEUES_EXT )) { +struct ena_admin_queue_ext_feature_fields *max_queue_ext = + &ctx->get_feat_ctx->max_queue_ext.max_queue_ext; + max_rx_queue_size =min_t (u32, max_queue_ext->max_rx_cq_depth, + max_queue_ext->max_rx_sq_depth); + max_tx_queue_size = max_queue_ext->max_tx_cq_depth; -if (ena_dev->tx_mem_queue_type ==ENA_ADMIN_PLACEMENT_POLICY_DEV ) - queue_size =min_t (u32, queue_size, - get_feat_ctx->llq.max_llq_depth); +if (ena_dev->tx_mem_queue_type ==ENA_ADMIN_PLACEMENT_POLICY_DEV ) + max_tx_queue_size =min_t (u32, max_tx_queue_size, + llq->max_llq_depth); +else + max_tx_queue_size =min_t (u32, max_tx_queue_size, + max_queue_ext->max_tx_sq_depth); - queue_size =rounddown_pow_of_two (queue_size); + ctx->max_tx_sgl_size =min_t (u16,ENA_PKT_MAX_BUFS , + max_queue_ext->max_per_packet_tx_descs); + ctx->max_rx_sgl_size =min_t (u16,ENA_PKT_MAX_BUFS , + max_queue_ext->max_per_packet_rx_descs); + }else { +struct ena_admin_queue_feature_desc *max_queues = + &ctx->get_feat_ctx->max_queues; + max_rx_queue_size =min_t (u32, max_queues->max_cq_depth, + max_queues->max_sq_depth); + max_tx_queue_size = max_queues->max_cq_depth; + +if (ena_dev->tx_mem_queue_type ==ENA_ADMIN_PLACEMENT_POLICY_DEV ) + max_tx_queue_size =min_t (u32, max_tx_queue_size, + llq->max_llq_depth); +else + max_tx_queue_size =min_t (u32, max_tx_queue_size, + max_queues->max_sq_depth); + + ctx->max_tx_sgl_size =min_t (u16,ENA_PKT_MAX_BUFS , + max_queues->max_packet_tx_descs); + ctx->max_rx_sgl_size =min_t (u16,ENA_PKT_MAX_BUFS , + max_queues->max_packet_rx_descs); + } + + max_tx_queue_size =rounddown_pow_of_two (max_tx_queue_size); + max_rx_queue_size =rounddown_pow_of_two (max_rx_queue_size); -if (unlikely (!queue_size)) { -dev_err (&pdev->dev,"Invalid queue size\n" ); + tx_queue_size =min_t (u32, tx_queue_size, max_tx_queue_size); + rx_queue_size =min_t (u32, rx_queue_size, max_rx_queue_size); + + tx_queue_size =rounddown_pow_of_two (tx_queue_size); + rx_queue_size =rounddown_pow_of_two (rx_queue_size); + +if (unlikely (!rx_queue_size || !tx_queue_size)) { +dev_err (&ctx->pdev->dev,"Invalid queue size\n" );return -EFAULT ; } - *max_tx_sgl_size =min_t (u16,ENA_PKT_MAX_BUFS , - get_feat_ctx->max_queues.max_packet_tx_descs); - *max_rx_sgl_size =min_t (u16,ENA_PKT_MAX_BUFS , - get_feat_ctx->max_queues.max_packet_rx_descs); + ctx->max_tx_queue_size = max_tx_queue_size; + ctx->max_rx_queue_size = max_rx_queue_size; + ctx->tx_queue_size = tx_queue_size; + ctx->rx_queue_size = rx_queue_size; -return queue_size; +return 0 ; }/* ena_probe - Device Initialization Routine
@@ -3284,6 +3328,7 @@ static int ena_calc_queue_size(struct pci_dev *pdev,static int ena_probe (struct pci_dev *pdev,const struct pci_device_id *ent) {struct ena_com_dev_get_features_ctx get_feat_ctx; +struct ena_calc_queue_size_ctx calc_queue_ctx = {0 };struct ena_llq_configurations llq_config;struct ena_com_dev *ena_dev =NULL ;struct ena_adapter *adapter;
@@ -3291,9 +3336,6 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)struct net_device *netdev;static int adapters_found;char *queue_type_str; -u16 tx_sgl_size =0 ; -u16 rx_sgl_size =0 ; -int queue_size;bool wd_state;dev_dbg (&pdev->dev,"%s\n" , __func__);
@@ -3350,20 +3392,25 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_device_destroy; } + calc_queue_ctx.ena_dev = ena_dev; + calc_queue_ctx.get_feat_ctx = &get_feat_ctx; + calc_queue_ctx.pdev = pdev; +/* initial Tx interrupt delay, Assumes 1 usec granularity. * Updated during device initialization with the real granularity */ ena_dev->intr_moder_tx_interval =ENA_INTR_INITIAL_TX_INTERVAL_USECS ; io_queue_num =ena_calc_io_queue_num (pdev, ena_dev, &get_feat_ctx); - queue_size =ena_calc_queue_size (pdev, ena_dev, &tx_sgl_size, - &rx_sgl_size, &get_feat_ctx); -if ((queue_size <=0 ) || (io_queue_num <=0 )) { + rc =ena_calc_queue_size (&calc_queue_ctx); +if (rc || io_queue_num <=0 ) { rc = -EFAULT ; goto err_device_destroy; } -dev_info (&pdev->dev,"creating %d io queues. queue size: %d. LLQ is %s\n" , - io_queue_num, queue_size, +dev_info (&pdev->dev,"creating %d io queues. rx queue size: %d tx queue size. %d LLQ is %s\n" , + io_queue_num, + calc_queue_ctx.rx_queue_size, + calc_queue_ctx.tx_queue_size, (ena_dev->tx_mem_queue_type ==ENA_ADMIN_PLACEMENT_POLICY_DEV ) ?"ENABLED" :"DISABLED" );
@@ -3389,11 +3436,10 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) adapter->msg_enable =netif_msg_init (debug,DEFAULT_MSG_ENABLE ); adapter->reset_reason =ENA_REGS_RESET_NORMAL ; - adapter->tx_ring_size = queue_size; - adapter->rx_ring_size = queue_size; - - adapter->max_tx_sgl_size = tx_sgl_size; - adapter->max_rx_sgl_size = rx_sgl_size; + adapter->tx_ring_size = calc_queue_ctx.tx_queue_size; + adapter->rx_ring_size = calc_queue_ctx.rx_queue_size; + adapter->max_tx_sgl_size = calc_queue_ctx.max_tx_sgl_size; + adapter->max_rx_sgl_size = calc_queue_ctx.max_rx_sgl_size; adapter->num_queues = io_queue_num; adapter->last_monitored_tx_qid =0 ;
drivers/net/ethernet/amazon/ena/ena_netdev.h +15 -0
@@ -154,6 +154,18 @@ struct ena_napi {u32 qid; }; +struct ena_calc_queue_size_ctx { +struct ena_com_dev_get_features_ctx *get_feat_ctx; +struct ena_com_dev *ena_dev; +struct pci_dev *pdev; +u16 tx_queue_size; +u16 rx_queue_size; +u16 max_tx_queue_size; +u16 max_rx_queue_size; +u16 max_tx_sgl_size; +u16 max_rx_sgl_size; +}; +struct ena_tx_buffer {struct sk_buff *skb;/* num of ena desc for this specific skb
@@ -322,6 +334,9 @@ struct ena_adapter {u32 tx_ring_size;u32 rx_ring_size; +u32 max_tx_ring_size; +u32 max_rx_ring_size; +u32 msg_enable;u16 max_tx_sgl_size;
Signature · 1 line
2.17.1
PATCH v3 3/7 net: ena: make ethtool show correct current and max queue sizes
In reply to [email protected]From: Sameeh Jubran <[email protected]>
Currently ethtool -g shows the same size for current and max queue sizes.
--- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 10 ++++------ drivers/net/ethernet/amazon/ena/ena_netdev.c | 2 ++ 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/amazon/ena/ena_ethtool.c +4 -6
@@ -486,13 +486,11 @@ static void ena_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring) {struct ena_adapter *adapter =netdev_priv (netdev); -struct ena_ring *tx_ring = &adapter->tx_ring[0 ]; -struct ena_ring *rx_ring = &adapter->rx_ring[0 ]; - ring->rx_max_pending = rx_ring->ring_size; - ring->tx_max_pending = tx_ring->ring_size; - ring->rx_pending = rx_ring->ring_size; - ring->tx_pending = tx_ring->ring_size; + ring->tx_max_pending = adapter->max_tx_ring_size; + ring->rx_max_pending = adapter->max_rx_ring_size; + ring->tx_pending = adapter->tx_ring_size; + ring->rx_pending = adapter->rx_ring_size; }static u32 ena_flow_hash_to_flow_type (u16 hash_fields)
drivers/net/ethernet/amazon/ena/ena_netdev.c +2 -0
@@ -3438,6 +3438,8 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent) adapter->tx_ring_size = calc_queue_ctx.tx_queue_size; adapter->rx_ring_size = calc_queue_ctx.rx_queue_size; + adapter->max_tx_ring_size = calc_queue_ctx.max_tx_queue_size; + adapter->max_rx_ring_size = calc_queue_ctx.max_rx_queue_size; adapter->max_tx_sgl_size = calc_queue_ctx.max_tx_sgl_size; adapter->max_rx_sgl_size = calc_queue_ctx.max_rx_sgl_size;
Signature · 1 line
2.17.1
PATCH v3 4/7 net: ena: allow queue allocation backoff when low on memory
In reply to [email protected]From: Sameeh Jubran <[email protected]>
If there is not enough memory to allocate io queues the driver will try to allocate smaller queues.
The backoff algorithm is as follows:
1. Try to allocate TX and RX and if successful.
1.1. return success
2. Divide by 2 the size of the larger of RX and TX queues (or both if their size is the same).
3. If TX or RX is smaller than 256
3.1. return failure.
4. else
4.1. go back to 1.
Also change the tx_queue_size, rx_queue_size field names in struct adapter to requested_tx_queue_size and requested_rx_queue_size, and use RX and TX queue 0 for actual queue sizes.
Explanation:
The original fields were useless as they were simply used to assign values once from them to each of the queues in the adapter in ena_probe(). They could simply be deleted. However now that we have a backoff feature, we have use for them. In case of backoff there is a difference between the requested queue sizes and the actual sizes. Therefore there is a need to save the requested queue size for future retries of queue allocation (for example if allocation failed and then ifdown + ifup was called we want to start the allocation from the original requested size of the queues).
--- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 4 +- drivers/net/ethernet/amazon/ena/ena_netdev.c | 159 +++++++++++++----- drivers/net/ethernet/amazon/ena/ena_netdev.h | 6 +- 3 files changed, 127 insertions(+), 42 deletions(-)
drivers/net/ethernet/amazon/ena/ena_ethtool.c +2 -2
@@ -489,8 +489,8 @@ static void ena_get_ringparam(struct net_device *netdev, ring->tx_max_pending = adapter->max_tx_ring_size; ring->rx_max_pending = adapter->max_rx_ring_size; - ring->tx_pending = adapter->tx_ring_size; - ring->rx_pending = adapter->rx_ring_size; + ring->tx_pending = adapter->tx_ring[0 ].ring_size; + ring->rx_pending = adapter->rx_ring[0 ].ring_size; }static u32 ena_flow_hash_to_flow_type (u16 hash_fields)
drivers/net/ethernet/amazon/ena/ena_netdev.c +121 -38
226 lines not on this page · raw message
drivers/net/ethernet/amazon/ena/ena_netdev.h +4 -2
@@ -79,6 +79,8 @@#define ENA_BAR_MASK (BIT(ENA_REG_BAR) | BIT(ENA_MEM_BAR))#define ENA_DEFAULT_RING_SIZE (1024) +#define ENA_MIN_RING_SIZE (256) +#define ENA_TX_WAKEUP_THRESH (MAX_SKB_FRAGS + 2)#define ENA_DEFAULT_RX_COPYBREAK (256 - NET_IP_ALIGN)
@@ -331,8 +333,8 @@ struct ena_adapter {u32 tx_usecs, rx_usecs;/* interrupt moderation */ u32 tx_frames, rx_frames;/* interrupt moderation */ -u32 tx_ring_size; -u32 rx_ring_size; +u32 requested_tx_ring_size; +u32 requested_rx_ring_size;u32 max_tx_ring_size;u32 max_rx_ring_size;
Signature · 1 line
2.17.1
PATCH v3 5/7 net: ena: add ethtool function for changing io queue sizes
In reply to [email protected]From: Sameeh Jubran <[email protected]>
Implement the set_ringparam() function of the ethtool interface to enable the changing of io queue sizes.
--- drivers/net/ethernet/amazon/ena/ena_ethtool.c | 22 +++++++++++++++++++ drivers/net/ethernet/amazon/ena/ena_netdev.c | 14 ++++++++++++ drivers/net/ethernet/amazon/ena/ena_netdev.h | 5 ++++- 3 files changed, 40 insertions(+), 1 deletion(-)
drivers/net/ethernet/amazon/ena/ena_ethtool.c +22 -0
@@ -493,6 +493,27 @@ static void ena_get_ringparam(struct net_device *netdev, ring->rx_pending = adapter->rx_ring[0 ].ring_size; } +static int ena_set_ringparam (struct net_device *netdev, +struct ethtool_ringparam *ring) +{ +struct ena_adapter *adapter =netdev_priv (netdev); +u32 new_tx_size, new_rx_size; + + new_tx_size = ring->tx_pending <ENA_MIN_RING_SIZE ? +ENA_MIN_RING_SIZE : ring->tx_pending; + new_tx_size =rounddown_pow_of_two (new_tx_size); + + new_rx_size = ring->rx_pending <ENA_MIN_RING_SIZE ? +ENA_MIN_RING_SIZE : ring->rx_pending; + new_rx_size =rounddown_pow_of_two (new_rx_size); + +if (new_tx_size == adapter->requested_tx_ring_size && + new_rx_size == adapter->requested_rx_ring_size) +return 0 ; + +return ena_update_queue_sizes (adapter, new_tx_size, new_rx_size); +} +static u32 ena_flow_hash_to_flow_type (u16 hash_fields) {u32 data =0 ;
@@ -858,6 +879,7 @@ static const struct ethtool_ops ena_ethtool_ops = { .get_coalesce = ena_get_coalesce, .set_coalesce = ena_set_coalesce, .get_ringparam = ena_get_ringparam, + .set_ringparam = ena_set_ringparam, .get_sset_count = ena_get_sset_count, .get_strings = ena_get_strings, .get_ethtool_stats = ena_get_ethtool_stats,
drivers/net/ethernet/amazon/ena/ena_netdev.c +14 -0
@@ -2031,6 +2031,20 @@ static int ena_close(struct net_device *netdev)return 0 ; } +int ena_update_queue_sizes (struct ena_adapter *adapter, +u32 new_tx_size, +u32 new_rx_size) +{ +bool dev_up; + + dev_up =test_bit (ENA_FLAG_DEV_UP , &adapter->flags); +ena_close (adapter->netdev); + adapter->requested_tx_ring_size = new_tx_size; + adapter->requested_rx_ring_size = new_rx_size; +ena_init_io_rings (adapter); +return dev_up ?ena_up (adapter) :0 ; +} +static void ena_tx_csum (struct ena_com_tx_ctx *ena_tx_ctx,struct sk_buff *skb) {u32 mss =skb_shinfo (skb)->gso_size;
drivers/net/ethernet/amazon/ena/ena_netdev.h +4 -1
@@ -81,7 +81,6 @@#define ENA_DEFAULT_RING_SIZE (1024)#define ENA_MIN_RING_SIZE (256) -#define ENA_TX_WAKEUP_THRESH (MAX_SKB_FRAGS + 2)#define ENA_DEFAULT_RX_COPYBREAK (256 - NET_IP_ALIGN)
@@ -389,6 +388,10 @@ void ena_dump_stats_to_dmesg(struct ena_adapter *adapter);void ena_dump_stats_to_buf (struct ena_adapter *adapter,u8 *buf); +int ena_update_queue_sizes (struct ena_adapter *adapter, +u32 new_tx_size, +u32 new_rx_size); +int ena_get_sset_count (struct net_device *netdev,int sset);#endif /* !(ENA_H) */
Signature · 1 line
2.17.1
PATCH v3 6/7 net: ena: remove inline keyword from functions in *.c
In reply to [email protected]From: Sameeh Jubran <[email protected]>
Let the compiler decide if the function should be inline in *.c files
--- drivers/net/ethernet/amazon/ena/ena_com.c | 6 ++--- drivers/net/ethernet/amazon/ena/ena_eth_com.c | 26 +++++++++---------- drivers/net/ethernet/amazon/ena/ena_netdev.c | 16 ++++++------ 3 files changed, 24 insertions(+), 24 deletions(-)
drivers/net/ethernet/amazon/ena/ena_com.c +3 -3
@@ -91,7 +91,7 @@ struct ena_com_stats_ctx {struct ena_admin_acq_get_stats_resp get_resp; }; -static inline int ena_com_mem_addr_set (struct ena_com_dev *ena_dev, +static int ena_com_mem_addr_set (struct ena_com_dev *ena_dev,struct ena_common_mem_addr *ena_addr,dma_addr_t addr) {
@@ -190,7 +190,7 @@ static int ena_com_admin_init_aenq(struct ena_com_dev *dev,return 0 ; } -static inline void comp_ctxt_release (struct ena_com_admin_queue *queue, +static void comp_ctxt_release (struct ena_com_admin_queue *queue,struct ena_comp_ctx *comp_ctx) { comp_ctx->occupied = false;
@@ -277,7 +277,7 @@ static struct ena_comp_ctx *__ena_com_submit_admin_cmd(struct ena_com_admin_queureturn comp_ctx; } -static inline int ena_com_init_comp_ctxt (struct ena_com_admin_queue *queue) +static int ena_com_init_comp_ctxt (struct ena_com_admin_queue *queue) {size_t size = queue->q_depth *sizeof (struct ena_comp_ctx );struct ena_comp_ctx *comp_ctx;
drivers/net/ethernet/amazon/ena/ena_eth_com.c +13 -13
@@ -32,7 +32,7 @@#include "ena_eth_com.h" -static inline struct ena_eth_io_rx_cdesc_base *ena_com_get_next_rx_cdesc ( +static struct ena_eth_io_rx_cdesc_base *ena_com_get_next_rx_cdesc (struct ena_com_io_cq *io_cq) {struct ena_eth_io_rx_cdesc_base *cdesc;
@@ -59,7 +59,7 @@ static inline struct ena_eth_io_rx_cdesc_base *ena_com_get_next_rx_cdesc(return cdesc; } -static inline void *get_sq_desc_regular_queue (struct ena_com_io_sq *io_sq) +static void *get_sq_desc_regular_queue (struct ena_com_io_sq *io_sq) {u16 tail_masked;u32 offset;
@@ -71,7 +71,7 @@ static inline void *get_sq_desc_regular_queue(struct ena_com_io_sq *io_sq)return (void *)((uintptr_t )io_sq->desc_addr.virt_addr + offset); } -static inline int ena_com_write_bounce_buffer_to_dev (struct ena_com_io_sq *io_sq, +static int ena_com_write_bounce_buffer_to_dev (struct ena_com_io_sq *io_sq,u8 *bounce_buffer) {struct ena_com_llq_info *llq_info = &io_sq->llq_info;
@@ -111,7 +111,7 @@ static inline int ena_com_write_bounce_buffer_to_dev(struct ena_com_io_sq *io_sqreturn 0 ; } -static inline int ena_com_write_header_to_bounce (struct ena_com_io_sq *io_sq, +static int ena_com_write_header_to_bounce (struct ena_com_io_sq *io_sq,u8 *header_src,u16 header_len) {
@@ -142,7 +142,7 @@ static inline int ena_com_write_header_to_bounce(struct ena_com_io_sq *io_sq,return 0 ; } -static inline void *get_sq_desc_llq (struct ena_com_io_sq *io_sq) +static void *get_sq_desc_llq (struct ena_com_io_sq *io_sq) {struct ena_com_llq_pkt_ctrl *pkt_ctrl = &io_sq->llq_buf_ctrl;u8 *bounce_buffer;
@@ -162,7 +162,7 @@ static inline void *get_sq_desc_llq(struct ena_com_io_sq *io_sq)return sq_desc; } -static inline int ena_com_close_bounce_buffer (struct ena_com_io_sq *io_sq) +static int ena_com_close_bounce_buffer (struct ena_com_io_sq *io_sq) {struct ena_com_llq_pkt_ctrl *pkt_ctrl = &io_sq->llq_buf_ctrl;struct ena_com_llq_info *llq_info = &io_sq->llq_info;
@@ -189,7 +189,7 @@ static inline int ena_com_close_bounce_buffer(struct ena_com_io_sq *io_sq)return 0 ; } -static inline void *get_sq_desc (struct ena_com_io_sq *io_sq) +static void *get_sq_desc (struct ena_com_io_sq *io_sq) {if (io_sq->mem_queue_type ==ENA_ADMIN_PLACEMENT_POLICY_DEV )return get_sq_desc_llq (io_sq);
@@ -197,7 +197,7 @@ static inline void *get_sq_desc(struct ena_com_io_sq *io_sq)return get_sq_desc_regular_queue (io_sq); } -static inline int ena_com_sq_update_llq_tail (struct ena_com_io_sq *io_sq) +static int ena_com_sq_update_llq_tail (struct ena_com_io_sq *io_sq) {struct ena_com_llq_pkt_ctrl *pkt_ctrl = &io_sq->llq_buf_ctrl;struct ena_com_llq_info *llq_info = &io_sq->llq_info;
@@ -225,7 +225,7 @@ static inline int ena_com_sq_update_llq_tail(struct ena_com_io_sq *io_sq)return 0 ; } -static inline int ena_com_sq_update_tail (struct ena_com_io_sq *io_sq) +static int ena_com_sq_update_tail (struct ena_com_io_sq *io_sq) {if (io_sq->mem_queue_type ==ENA_ADMIN_PLACEMENT_POLICY_DEV )return ena_com_sq_update_llq_tail (io_sq);
@@ -239,7 +239,7 @@ static inline int ena_com_sq_update_tail(struct ena_com_io_sq *io_sq)return 0 ; } -static inline struct ena_eth_io_rx_cdesc_base * +static struct ena_eth_io_rx_cdesc_base *ena_com_rx_cdesc_idx_to_ptr (struct ena_com_io_cq *io_cq,u16 idx) { idx &= (io_cq->q_depth -1 );
@@ -248,7 +248,7 @@ static inline struct ena_eth_io_rx_cdesc_base * idx * io_cq->cdesc_entry_size_in_bytes); } -static inline u16 ena_com_cdesc_rx_pkt_get (struct ena_com_io_cq *io_cq, +static u16 ena_com_cdesc_rx_pkt_get (struct ena_com_io_cq *io_cq,u16 *first_cdesc_idx) {struct ena_eth_io_rx_cdesc_base *cdesc;
@@ -285,7 +285,7 @@ static inline u16 ena_com_cdesc_rx_pkt_get(struct ena_com_io_cq *io_cq,return count; } -static inline int ena_com_create_and_store_tx_meta_desc (struct ena_com_io_sq *io_sq, +static int ena_com_create_and_store_tx_meta_desc (struct ena_com_io_sq *io_sq,struct ena_com_tx_ctx *ena_tx_ctx) {struct ena_eth_io_tx_meta_desc *meta_desc =NULL ;
@@ -334,7 +334,7 @@ static inline int ena_com_create_and_store_tx_meta_desc(struct ena_com_io_sq *ioreturn ena_com_sq_update_tail (io_sq); } -static inline void ena_com_rx_set_flags (struct ena_com_rx_ctx *ena_rx_ctx, +static void ena_com_rx_set_flags (struct ena_com_rx_ctx *ena_rx_ctx,struct ena_eth_io_rx_cdesc_base *cdesc) { ena_rx_ctx->l3_proto = cdesc->status &
drivers/net/ethernet/amazon/ena/ena_netdev.c +8 -8
@@ -326,7 +326,7 @@ static void ena_free_all_io_tx_resources(struct ena_adapter *adapter)ena_free_tx_resources (adapter, i); } -static inline int validate_rx_req_id (struct ena_ring *rx_ring,u16 req_id) +static int validate_rx_req_id (struct ena_ring *rx_ring,u16 req_id) {if (likely (req_id < rx_ring->ring_size))return 0 ;
@@ -460,7 +460,7 @@ static void ena_free_all_io_rx_resources(struct ena_adapter *adapter)ena_free_rx_resources (adapter, i); } -static inline int ena_alloc_rx_page (struct ena_ring *rx_ring, +static int ena_alloc_rx_page (struct ena_ring *rx_ring,struct ena_rx_buffer *rx_info,gfp_t gfp) {struct ena_com_buf *ena_buf;
@@ -620,7 +620,7 @@ static void ena_free_all_rx_bufs(struct ena_adapter *adapter)ena_free_rx_bufs (adapter, i); } -static inline void ena_unmap_tx_skb (struct ena_ring *tx_ring, +static void ena_unmap_tx_skb (struct ena_ring *tx_ring,struct ena_tx_buffer *tx_info) {struct ena_com_buf *ena_buf;
@@ -955,7 +955,7 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,* @ena_rx_ctx: received packet context/metadata * @skb: skb currently being received and modified */ -static inline void ena_rx_checksum (struct ena_ring *rx_ring, +static void ena_rx_checksum (struct ena_ring *rx_ring,struct ena_com_rx_ctx *ena_rx_ctx,struct sk_buff *skb) {
@@ -1155,7 +1155,7 @@ error:return 0 ; } -inline void ena_adjust_intr_moderation (struct ena_ring *rx_ring, +void ena_adjust_intr_moderation (struct ena_ring *rx_ring,struct ena_ring *tx_ring) {/* We apply adaptive moderation on Rx path only.
@@ -1174,7 +1174,7 @@ inline void ena_adjust_intr_moderation(struct ena_ring *rx_ring, rx_ring->per_napi_bytes =0 ; } -static inline void ena_unmask_interrupt (struct ena_ring *tx_ring, +static void ena_unmask_interrupt (struct ena_ring *tx_ring,struct ena_ring *rx_ring) {struct ena_eth_io_intr_reg intr_reg;
@@ -1194,7 +1194,7 @@ static inline void ena_unmask_interrupt(struct ena_ring *tx_ring,ena_com_unmask_intr (rx_ring->ena_com_io_cq, &intr_reg); } -static inline void ena_update_ring_numa_node (struct ena_ring *tx_ring, +static void ena_update_ring_numa_node (struct ena_ring *tx_ring,struct ena_ring *rx_ring) {int cpu =get_cpu ();
@@ -3337,7 +3337,7 @@ static void ena_release_bars(struct ena_com_dev *ena_dev, struct pci_dev *pdev)pci_release_selected_regions (pdev, release_bars); } -static inline void set_default_llq_configurations (struct ena_llq_configurations *llq_config) +static void set_default_llq_configurations (struct ena_llq_configurations *llq_config) { llq_config->llq_header_location =ENA_ADMIN_INLINE_HEADER ; llq_config->llq_ring_entry_size =ENA_ADMIN_LIST_ENTRY_SIZE_128B ;
Signature · 1 line
2.17.1
PATCH v3 7/7 net: ena: update driver version from 2.0.3 to 2.1.0
In reply to [email protected]From: Sameeh Jubran <[email protected]>
Update driver version to match device specification.
--- drivers/net/ethernet/amazon/ena/ena_netdev.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/amazon/ena/ena_netdev.h +2 -2
@@ -44,8 +44,8 @@#include "ena_eth_com.h" #define DRV_MODULE_VER_MAJOR 2 -#define DRV_MODULE_VER_MINOR 0 -#define DRV_MODULE_VER_SUBMINOR 3 +#define DRV_MODULE_VER_MINOR 1 +#define DRV_MODULE_VER_SUBMINOR 0#define DRV_MODULE_NAME "ena"#ifndef DRV_MODULE_VERSION
Signature · 1 line
2.17.1
David Miller
maintainerFrom: <[email protected]>
Date: Tue, 11 Jun 2019 14:58:04 +0300
Quoted 8 lines
From: Sameeh Jubran <[email protected]>
This patchset introduces the following:
* add new admin command for supporting different queue size for Tx/Rx
* add support for Tx/Rx queues size modification through ethtool
* allow queues allocation backoff when low on memory
* update driver version
Quoted 8 lines
Difference from v2:
* Dropped superfluous range checks which are already done in ethtool. [patch 5/7]
* Dropped inline keyword from function. [patch 4/7]
* Added a new patch which drops inline keyword all *.c files. [patch 6/7]Difference from v1:
* Changedena_update_queue_sizes()signature to use u32 instead of int type for the size arguments. [patch 5/7]
Series applied, thanks.