net/bnxt: add code to determine the Tx COS queue
[dpdk.git] / drivers / net / bnxt / bnxt_hwrm.c
index 0100f74..3a326d4 100644 (file)
@@ -27,6 +27,7 @@
 #include <rte_io.h>
 
 #define HWRM_CMD_TIMEOUT               10000
+#define HWRM_VERSION_1_9_1             0x10901
 
 struct bnxt_plcmodes_cfg {
        uint32_t        flags;
@@ -665,6 +666,7 @@ int bnxt_hwrm_ver_get(struct bnxt *bp)
        fw_version = resp->hwrm_intf_maj << 16;
        fw_version |= resp->hwrm_intf_min << 8;
        fw_version |= resp->hwrm_intf_upd;
+       bp->hwrm_spec_code = fw_version;
 
        if (resp->hwrm_intf_maj != HWRM_VERSION_MAJOR) {
                PMD_DRV_LOG(ERR, "Unsupported firmware API version\n");
@@ -891,9 +893,15 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
        int rc = 0;
        struct hwrm_queue_qportcfg_input req = {.req_type = 0 };
        struct hwrm_queue_qportcfg_output *resp = bp->hwrm_cmd_resp_addr;
+       int i;
 
        HWRM_PREP(req, QUEUE_QPORTCFG);
 
+       req.flags = HWRM_QUEUE_QPORTCFG_INPUT_FLAGS_PATH_TX;
+       /* HWRM Version >= 1.9.1 */
+       if (bp->hwrm_spec_code >= HWRM_VERSION_1_9_1)
+               req.drv_qmap_cap =
+                       HWRM_QUEUE_QPORTCFG_INPUT_DRV_QMAP_CAP_ENABLED;
        rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
 
        HWRM_CHECK_RESULT();
@@ -913,6 +921,20 @@ int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
 
        HWRM_UNLOCK();
 
+       if (bp->hwrm_spec_code < HWRM_VERSION_1_9_1) {
+               bp->tx_cosq_id = bp->cos_queue[0].id;
+       } else {
+               /* iterate and find the COSq profile to use for Tx */
+               for (i = 0; i < BNXT_COS_QUEUE_COUNT; i++) {
+                       if (bp->cos_queue[i].profile ==
+                               HWRM_QUEUE_SERVICE_PROFILE_LOSSY) {
+                               bp->tx_cosq_id = bp->cos_queue[i].id;
+                               break;
+                       }
+               }
+       }
+       PMD_DRV_LOG(DEBUG, "Tx Cos Queue to use: %d\n", bp->tx_cosq_id);
+
        return rc;
 }
 
@@ -936,7 +958,7 @@ int bnxt_hwrm_ring_alloc(struct bnxt *bp,
 
        switch (ring_type) {
        case HWRM_RING_ALLOC_INPUT_RING_TYPE_TX:
-               req.queue_id = bp->cos_queue[0].id;
+               req.queue_id = rte_cpu_to_le_16(bp->tx_cosq_id);
                /* FALLTHROUGH */
        case HWRM_RING_ALLOC_INPUT_RING_TYPE_RX:
                req.ring_type = ring_type;