octeontx2-af: Fix truncation of smq in CN10K NIX AQ enqueue mbox handler
authorGeetha sowjanya <gakula@marvell.com>
Tue, 5 Sep 2023 06:48:16 +0000 (12:18 +0530)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Sep 2023 16:50:33 +0000 (17:50 +0100)
The smq value used in the CN10K NIX AQ instruction enqueue mailbox
handler was truncated to 9-bit value from 10-bit value because of
typecasting the CN10K mbox request structure to the CN9K structure.
Though this hasn't caused any problems when programming the NIX SQ
context to the HW because the context structure is the same size.
However, this causes a problem when accessing the structure parameters.
This patch reads the right smq value for each platform.

Fixes: 30077d210c83 ("octeontx2-af: cn10k: Update NIX/NPA context structure")
Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

index c2f68678e947e8019aa53a13c290080ebc488d0a..23c2f2ed2fb83294f4345cf55e9b5252d280b376 100644 (file)
@@ -846,6 +846,21 @@ static int nix_aq_enqueue_wait(struct rvu *rvu, struct rvu_block *block,
        return 0;
 }
 
+static void nix_get_aq_req_smq(struct rvu *rvu, struct nix_aq_enq_req *req,
+                              u16 *smq, u16 *smq_mask)
+{
+       struct nix_cn10k_aq_enq_req *aq_req;
+
+       if (!is_rvu_otx2(rvu)) {
+               aq_req = (struct nix_cn10k_aq_enq_req *)req;
+               *smq = aq_req->sq.smq;
+               *smq_mask = aq_req->sq_mask.smq;
+       } else {
+               *smq = req->sq.smq;
+               *smq_mask = req->sq_mask.smq;
+       }
+}
+
 static int rvu_nix_blk_aq_enq_inst(struct rvu *rvu, struct nix_hw *nix_hw,
                                   struct nix_aq_enq_req *req,
                                   struct nix_aq_enq_rsp *rsp)
@@ -857,6 +872,7 @@ static int rvu_nix_blk_aq_enq_inst(struct rvu *rvu, struct nix_hw *nix_hw,
        struct rvu_block *block;
        struct admin_queue *aq;
        struct rvu_pfvf *pfvf;
+       u16 smq, smq_mask;
        void *ctx, *mask;
        bool ena;
        u64 cfg;
@@ -928,13 +944,14 @@ static int rvu_nix_blk_aq_enq_inst(struct rvu *rvu, struct nix_hw *nix_hw,
        if (rc)
                return rc;
 
+       nix_get_aq_req_smq(rvu, req, &smq, &smq_mask);
        /* Check if SQ pointed SMQ belongs to this PF/VF or not */
        if (req->ctype == NIX_AQ_CTYPE_SQ &&
            ((req->op == NIX_AQ_INSTOP_INIT && req->sq.ena) ||
             (req->op == NIX_AQ_INSTOP_WRITE &&
-             req->sq_mask.ena && req->sq_mask.smq && req->sq.ena))) {
+             req->sq_mask.ena && req->sq.ena && smq_mask))) {
                if (!is_valid_txschq(rvu, blkaddr, NIX_TXSCH_LVL_SMQ,
-                                    pcifunc, req->sq.smq))
+                                    pcifunc, smq))
                        return NIX_AF_ERR_AQ_ENQUEUE;
        }