OSDN Git Service

nfp: prepare for multi-part descriptors
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 21 Mar 2022 10:42:03 +0000 (11:42 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Mar 2022 13:21:16 +0000 (13:21 +0000)
New datapaths may use multiple descriptor units to describe
a single packet.  Prepare for that by adding a descriptors
per simple frame constant into ring size calculations.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Fei Qin <fei.qin@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfd3/rings.c
drivers/net/ethernet/netronome/nfp/nfp_net.h
drivers/net/ethernet/netronome/nfp/nfp_net_dp.h
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c

index 342871d..3ebbedd 100644 (file)
@@ -244,6 +244,7 @@ nfp_nfd3_print_tx_descs(struct seq_file *file,
 
 const struct nfp_dp_ops nfp_nfd3_ops = {
        .version                = NFP_NFD_VER_NFD3,
+       .tx_min_desc_per_pkt    = 1,
        .poll                   = nfp_nfd3_poll,
        .xsk_poll               = nfp_nfd3_xsk_poll,
        .ctrl_poll              = nfp_nfd3_ctrl_poll,
index 13a9e67..d4b82c8 100644 (file)
@@ -441,8 +441,8 @@ struct nfp_stat_pair {
  * @ctrl_bar:          Pointer to mapped control BAR
  *
  * @ops:               Callbacks and parameters for this vNIC's NFD version
- * @txd_cnt:           Size of the TX ring in number of descriptors
- * @rxd_cnt:           Size of the RX ring in number of descriptors
+ * @txd_cnt:           Size of the TX ring in number of min size packets
+ * @rxd_cnt:           Size of the RX ring in number of min size packets
  * @num_r_vecs:                Number of used ring vectors
  * @num_tx_rings:      Currently configured number of TX rings
  * @num_stack_tx_rings:        Number of TX rings used by the stack (not XDP)
index 25af0e3..81be8d1 100644 (file)
@@ -106,6 +106,7 @@ enum nfp_nfd_version {
 /**
  * struct nfp_dp_ops - Hooks to wrap different implementation of different dp
  * @version:                   Indicate dp type
+ * @tx_min_desc_per_pkt:       Minimal TX descs needed for each packet
  * @poll:                      Napi poll for normal rx/tx
  * @xsk_poll:                  Napi poll when xsk is enabled
  * @ctrl_poll:                 Tasklet poll for ctrl rx/tx
@@ -121,6 +122,7 @@ enum nfp_nfd_version {
  */
 struct nfp_dp_ops {
        enum nfp_nfd_version version;
+       unsigned int tx_min_desc_per_pkt;
 
        int (*poll)(struct napi_struct *napi, int budget);
        int (*xsk_poll)(struct napi_struct *napi, int budget);
index b9abae1..7d71506 100644 (file)
@@ -26,6 +26,7 @@
 #include "nfp_app.h"
 #include "nfp_main.h"
 #include "nfp_net_ctrl.h"
+#include "nfp_net_dp.h"
 #include "nfp_net.h"
 #include "nfp_port.h"
 
@@ -390,7 +391,7 @@ static void nfp_net_get_ringparam(struct net_device *netdev,
        u32 qc_max = nn->dev_info->max_qc_size;
 
        ring->rx_max_pending = qc_max;
-       ring->tx_max_pending = qc_max;
+       ring->tx_max_pending = qc_max / nn->dp.ops->tx_min_desc_per_pkt;
        ring->rx_pending = nn->dp.rxd_cnt;
        ring->tx_pending = nn->dp.txd_cnt;
 }
@@ -414,8 +415,8 @@ static int nfp_net_set_ringparam(struct net_device *netdev,
                                 struct kernel_ethtool_ringparam *kernel_ring,
                                 struct netlink_ext_ack *extack)
 {
+       u32 tx_dpp, qc_min, qc_max, rxd_cnt, txd_cnt;
        struct nfp_net *nn = netdev_priv(netdev);
-       u32 qc_min, qc_max, rxd_cnt, txd_cnt;
 
        /* We don't have separate queues/rings for small/large frames. */
        if (ring->rx_mini_pending || ring->rx_jumbo_pending)
@@ -423,12 +424,13 @@ static int nfp_net_set_ringparam(struct net_device *netdev,
 
        qc_min = nn->dev_info->min_qc_size;
        qc_max = nn->dev_info->max_qc_size;
+       tx_dpp = nn->dp.ops->tx_min_desc_per_pkt;
        /* Round up to supported values */
        rxd_cnt = roundup_pow_of_two(ring->rx_pending);
        txd_cnt = roundup_pow_of_two(ring->tx_pending);
 
        if (rxd_cnt < qc_min || rxd_cnt > qc_max ||
-           txd_cnt < qc_min || txd_cnt > qc_max)
+           txd_cnt < qc_min / tx_dpp || txd_cnt > qc_max / tx_dpp)
                return -EINVAL;
 
        if (nn->dp.rxd_cnt == rxd_cnt && nn->dp.txd_cnt == txd_cnt)