net/iavf: support quanta size configuration
authorWenjun Wu <wenjun1.wu@intel.com>
Fri, 22 Apr 2022 01:43:00 +0000 (09:43 +0800)
committerQi Zhang <qi.z.zhang@intel.com>
Fri, 22 Apr 2022 12:05:29 +0000 (14:05 +0200)
This patch adds quanta size configuration support.
Quanta size should between 256 and 4096, and be a product of 64.

Signed-off-by: Wenjun Wu <wenjun1.wu@intel.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
doc/guides/nics/intel_vf.rst
doc/guides/rel_notes/release_22_07.rst
drivers/common/iavf/virtchnl.h
drivers/net/iavf/iavf.h
drivers/net/iavf/iavf_ethdev.c
drivers/net/iavf/iavf_vchnl.c

index 648af39..6498135 100644 (file)
@@ -92,6 +92,10 @@ For more detail on SR-IOV, please refer to the following documents:
     available for IAVF PMD. The same devargs with the same parameters can be applied to IAVF PMD, for detail please reference
     the section ``Protocol extraction for per queue`` of ice.rst.
 
+    Quanta size configuration is also supported when IAVF is backed by an IntelĀ® E810 device by setting ``devargs``
+    parameter ``quanta_size`` like ``-a 18:00.0,quanta_size=2048``. The default value is 1024, and quanta size should be
+    set as the product of 64 in legacy host interface mode.
+
 The PCIE host-interface of Intel Ethernet Switch FM10000 Series VF infrastructure
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
index dd2c69b..90123bb 100644 (file)
@@ -58,6 +58,7 @@ New Features
 * **Updated Intel iavf driver.**
 
   * Added Tx QoS queue rate limitation support.
+  * Added quanta size configuration support.
 
 
 Removed Items
index b948b0f..249ae6e 100644 (file)
@@ -165,6 +165,7 @@ enum virtchnl_ops {
        VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
        VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
        VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
+       VIRTCHNL_OP_CONFIG_QUANTA = 113,
        VIRTCHNL_OP_MAX,
 };
 
@@ -1996,6 +1997,12 @@ struct virtchnl_queue_vector_maps {
 
 VIRTCHNL_CHECK_STRUCT_LEN(24, virtchnl_queue_vector_maps);
 
+struct virtchnl_quanta_cfg {
+       u16 quanta_size;
+       struct virtchnl_queue_chunk queue_select;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg);
 
 /* Since VF messages are limited by u16 size, precalculate the maximum possible
  * values of nested elements in virtchnl structures that virtual channel can
@@ -2275,6 +2282,18 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
                                         sizeof(q_bw->cfg[0]);
                }
                break;
+       case VIRTCHNL_OP_CONFIG_QUANTA:
+               valid_len = sizeof(struct virtchnl_quanta_cfg);
+               if (msglen >= valid_len) {
+                       struct virtchnl_quanta_cfg *q_quanta =
+                               (struct virtchnl_quanta_cfg *)msg;
+                       if (q_quanta->quanta_size == 0 ||
+                           q_quanta->queue_select.num_queues == 0) {
+                               err_msg_format = true;
+                               break;
+                       }
+               }
+               break;
        case VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS:
                break;
        case VIRTCHNL_OP_ADD_VLAN_V2:
index 96515a3..c0a4a47 100644 (file)
@@ -292,6 +292,7 @@ enum iavf_proto_xtr_type {
 struct iavf_devargs {
        uint8_t proto_xtr_dflt;
        uint8_t proto_xtr[IAVF_MAX_QUEUE_NUM];
+       uint16_t quanta_size;
 };
 
 struct iavf_security_ctx;
@@ -467,6 +468,8 @@ int iavf_set_q_bw(struct rte_eth_dev *dev,
 int iavf_set_q_tc_map(struct rte_eth_dev *dev,
                        struct virtchnl_queue_tc_mapping *q_tc_mapping,
                        uint16_t size);
+int iavf_set_vf_quanta_size(struct iavf_adapter *adapter, u16 start_queue_id,
+                           u16 num_queues);
 void iavf_tm_conf_init(struct rte_eth_dev *dev);
 void iavf_tm_conf_uninit(struct rte_eth_dev *dev);
 int iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
index d6190ac..7d093bd 100644 (file)
 
 /* devargs */
 #define IAVF_PROTO_XTR_ARG         "proto_xtr"
+#define IAVF_QUANTA_SIZE_ARG       "quanta_size"
 
 static const char * const iavf_valid_args[] = {
        IAVF_PROTO_XTR_ARG,
+       IAVF_QUANTA_SIZE_ARG,
        NULL
 };
 
@@ -950,6 +952,9 @@ iavf_dev_start(struct rte_eth_dev *dev)
                return -1;
        }
 
+       if (iavf_set_vf_quanta_size(adapter, index, num_queue_pairs) != 0)
+               PMD_DRV_LOG(WARNING, "configure quanta size failed");
+
        /* If needed, send configure queues msg multiple times to make the
         * adminq buffer length smaller than the 4K limitation.
         */
@@ -2092,6 +2097,25 @@ iavf_handle_proto_xtr_arg(__rte_unused const char *key, const char *value,
        return 0;
 }
 
+static int
+parse_u16(__rte_unused const char *key, const char *value, void *args)
+{
+       u16 *num = (u16 *)args;
+       u16 tmp;
+
+       errno = 0;
+       tmp = strtoull(value, NULL, 10);
+       if (errno || !tmp) {
+               PMD_DRV_LOG(WARNING, "%s: \"%s\" is not a valid u16",
+                           key, value);
+               return -1;
+       }
+
+       *num = tmp;
+
+       return 0;
+}
+
 static int iavf_parse_devargs(struct rte_eth_dev *dev)
 {
        struct iavf_adapter *ad =
@@ -2118,6 +2142,20 @@ static int iavf_parse_devargs(struct rte_eth_dev *dev)
        if (ret)
                goto bail;
 
+       ret = rte_kvargs_process(kvlist, IAVF_QUANTA_SIZE_ARG,
+                                &parse_u16, &ad->devargs.quanta_size);
+       if (ret)
+               goto bail;
+
+       if (ad->devargs.quanta_size == 0)
+               ad->devargs.quanta_size = 1024;
+
+       if (ad->devargs.quanta_size < 256 || ad->devargs.quanta_size > 4096 ||
+           ad->devargs.quanta_size & 0x40) {
+               PMD_INIT_LOG(ERR, "invalid quanta size\n");
+               return -EINVAL;
+       }
+
 bail:
        rte_kvargs_free(kvlist);
        return ret;
index 537369f..f9452d1 100644 (file)
@@ -1828,3 +1828,34 @@ iavf_ipsec_crypto_request(struct iavf_adapter *adapter,
 
        return 0;
 }
+
+int
+iavf_set_vf_quanta_size(struct iavf_adapter *adapter, u16 start_queue_id, u16 num_queues)
+{
+       struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
+       struct iavf_cmd_info args;
+       struct virtchnl_quanta_cfg q_quanta;
+       int err;
+
+       if (adapter->devargs.quanta_size == 0)
+               return 0;
+
+       q_quanta.quanta_size = adapter->devargs.quanta_size;
+       q_quanta.queue_select.type = VIRTCHNL_QUEUE_TYPE_TX;
+       q_quanta.queue_select.start_queue_id = start_queue_id;
+       q_quanta.queue_select.num_queues = num_queues;
+
+       args.ops = VIRTCHNL_OP_CONFIG_QUANTA;
+       args.in_args = (uint8_t *)&q_quanta;
+       args.in_args_size = sizeof(q_quanta);
+       args.out_buffer = vf->aq_resp;
+       args.out_size = IAVF_AQ_BUF_SZ;
+
+       err = iavf_execute_vf_cmd(adapter, &args, 0);
+       if (err) {
+               PMD_DRV_LOG(ERR, "Failed to execute command VIRTCHNL_OP_CONFIG_QUANTA");
+               return err;
+       }
+
+       return 0;
+}