]> git.baikalelectronics.ru Git - kernel.git/commitdiff
octeontx2-af: Add mbox to retrieve bandwidth profile free count
authorSunil Goutham <sgoutham@marvell.com>
Wed, 25 Aug 2021 12:18:46 +0000 (17:48 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Aug 2021 12:39:02 +0000 (13:39 +0100)
Added mbox for PF/VF drivers to retrieve current ingress bandwidth
profile free count. Also added current policer timeunit
configuration info based on which ratelimiting decisions can be
taken by PF/VF drivers.

Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/octeontx2/af/mbox.h
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

index bc9cd1de2872ab1ae66a020cefcfd1a5b289610d..ef3c41cf34136692d67c3aed456d36fc3fbaed7b 100644 (file)
@@ -279,7 +279,9 @@ M(NIX_GET_HW_INFO,  0x801c, nix_get_hw_info, msg_req, nix_hw_info)  \
 M(NIX_BANDPROF_ALLOC,  0x801d, nix_bandprof_alloc, nix_bandprof_alloc_req, \
                                nix_bandprof_alloc_rsp)                     \
 M(NIX_BANDPROF_FREE,   0x801e, nix_bandprof_free, nix_bandprof_free_req,   \
-                               msg_rsp)
+                               msg_rsp)                                    \
+M(NIX_BANDPROF_GET_HWINFO, 0x801f, nix_bandprof_get_hwinfo, msg_req,           \
+                               nix_bandprof_get_hwinfo_rsp)
 
 /* Messages initiated by AF (range 0xC00 - 0xDFF) */
 #define MBOX_UP_CGX_MESSAGES                                           \
@@ -1101,6 +1103,12 @@ struct nix_bandprof_free_req {
        u16 prof_idx[BAND_PROF_NUM_LAYERS][MAX_BANDPROF_PER_PFFUNC];
 };
 
+struct nix_bandprof_get_hwinfo_rsp {
+       struct mbox_msghdr hdr;
+       u16 prof_count[BAND_PROF_NUM_LAYERS];
+       u32 policer_timeunit;
+};
+
 /* NPC mbox message structs */
 
 #define NPC_MCAM_ENTRY_INVALID 0xFFFF
index c2eb3b0c2f53dbc2255ed4cc1cfcd3778dac3d5c..dfa933c5fcd181d3d145823af5d8e3e0cfe6a580 100644 (file)
@@ -5173,3 +5173,36 @@ static void nix_clear_ratelimit_aggr(struct rvu *rvu, struct nix_hw *nix_hw,
                rvu_free_rsrc(&ipolicer->band_prof, mid_prof);
        }
 }
+
+int rvu_mbox_handler_nix_bandprof_get_hwinfo(struct rvu *rvu, struct msg_req *req,
+                                            struct nix_bandprof_get_hwinfo_rsp *rsp)
+{
+       struct nix_ipolicer *ipolicer;
+       int blkaddr, layer, err;
+       struct nix_hw *nix_hw;
+       u64 tu;
+
+       if (!rvu->hw->cap.ipolicer)
+               return NIX_AF_ERR_IPOLICER_NOTSUPP;
+
+       err = nix_get_struct_ptrs(rvu, req->hdr.pcifunc, &nix_hw, &blkaddr);
+       if (err)
+               return err;
+
+       /* Return number of bandwidth profiles free at each layer */
+       mutex_lock(&rvu->rsrc_lock);
+       for (layer = 0; layer < BAND_PROF_NUM_LAYERS; layer++) {
+               if (layer == BAND_PROF_INVAL_LAYER)
+                       continue;
+
+               ipolicer = &nix_hw->ipolicer[layer];
+               rsp->prof_count[layer] = rvu_rsrc_free_count(&ipolicer->band_prof);
+       }
+       mutex_unlock(&rvu->rsrc_lock);
+
+       /* Set the policer timeunit in nanosec */
+       tu = rvu_read64(rvu, blkaddr, NIX_AF_PL_TS) & GENMASK_ULL(9, 0);
+       rsp->policer_timeunit = (tu + 1) * 100;
+
+       return 0;
+}