[PATCH v8 08/15] octeontx2-af: Add RVU block LF provisioning support
From: Sunil Goutham Added support for a RVU PF/VF to request AF via mailbox to attach or detach NPA/NIX/SSO/SSOW/TIM/CPT block LFs. Also supports partial detachment and modifying current LF attached count of a certian block type. Signed-off-by: Sunil Goutham --- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 45 +- drivers/net/ethernet/marvell/octeontx2/af/rvu.c| 472 - drivers/net/ethernet/marvell/octeontx2/af/rvu.h| 8 +- .../net/ethernet/marvell/octeontx2/af/rvu_reg.h| 8 +- 4 files changed, 523 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h index fc593f0..7280d49 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/mbox.h +++ b/drivers/net/ethernet/marvell/octeontx2/af/mbox.h @@ -118,7 +118,17 @@ static inline struct mbox_msghdr *otx2_mbox_alloc_msg(struct otx2_mbox *mbox, #define MBOX_MSG_MAX 0x #define MBOX_MESSAGES \ -M(READY, 0x001, msg_req, ready_msg_rsp) +/* Generic mbox IDs (range 0x000 - 0x1FF) */ \ +M(READY, 0x001, msg_req, ready_msg_rsp) \ +M(ATTACH_RESOURCES,0x002, rsrc_attach, msg_rsp)\ +M(DETACH_RESOURCES,0x003, rsrc_detach, msg_rsp)\ +/* CGX mbox IDs (range 0x200 - 0x3FF) */ \ +/* NPA mbox IDs (range 0x400 - 0x5FF) */ \ +/* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */ \ +/* TIM mbox IDs (range 0x800 - 0x9FF) */ \ +/* CPT mbox IDs (range 0xA00 - 0xBFF) */ \ +/* NPC mbox IDs (range 0x6000 - 0x7FFF) */ \ +/* NIX mbox IDs (range 0x8000 - 0x) */ \ enum { #define M(_name, _id, _1, _2) MBOX_MSG_ ## _name = _id, @@ -147,4 +157,37 @@ struct ready_msg_rsp { u16sclk_feq;/* SCLK frequency */ }; +/* Structure for requesting resource provisioning. + * 'modify' flag to be used when either requesting more + * or to detach partial of a cetain resource type. + * Rest of the fields specify how many of what type to + * be attached. + */ +struct rsrc_attach { + struct mbox_msghdr hdr; + u8 modify:1; + u8 npalf:1; + u8 nixlf:1; + u16 sso; + u16 ssow; + u16 timlfs; + u16 cptlfs; +}; + +/* Structure for relinquishing resources. + * 'partial' flag to be used when relinquishing all resources + * but only of a certain type. If not set, all resources of all + * types provisioned to the RVU function will be detached. + */ +struct rsrc_detach { + struct mbox_msghdr hdr; + u8 partial:1; + u8 npalf:1; + u8 nixlf:1; + u8 sso:1; + u8 ssow:1; + u8 timlfs:1; + u8 cptlfs:1; +}; + #endif /* MBOX_H */ diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c index 53e02b0..ef3f559 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c @@ -59,6 +59,41 @@ int rvu_poll_reg(struct rvu *rvu, u64 block, u64 offset, u64 mask, bool zero) return -EBUSY; } +int rvu_alloc_rsrc(struct rsrc_bmap *rsrc) +{ + int id; + + if (!rsrc->bmap) + return -EINVAL; + + id = find_first_zero_bit(rsrc->bmap, rsrc->max); + if (id >= rsrc->max) + return -ENOSPC; + + __set_bit(id, rsrc->bmap); + + return id; +} + +void rvu_free_rsrc(struct rsrc_bmap *rsrc, int id) +{ + if (!rsrc->bmap) + return; + + __clear_bit(id, rsrc->bmap); +} + +int rvu_rsrc_free_count(struct rsrc_bmap *rsrc) +{ + int used; + + if (!rsrc->bmap) + return 0; + + used = bitmap_weight(rsrc->bmap, rsrc->max); + return (rsrc->max - used); +} + int rvu_alloc_bitmap(struct rsrc_bmap *rsrc) { rsrc->bmap = kcalloc(BITS_TO_LONGS(rsrc->max), @@ -68,6 +103,78 @@ int rvu_alloc_bitmap(struct rsrc_bmap *rsrc) return 0; } +/* Convert BLOCK_TYPE_E to a BLOCK_ADDR_E. + * Some silicon variants of OcteonTX2 supports + * multiple blocks of same type. + * + * @pcifunc has to be zero when no LF is yet attached. + */ +int rvu_get_blkaddr(struct rvu *rvu, int blktype, u16 pcifunc) +{ + int devnum, blkaddr = -ENODEV; + u64 cfg, reg; + bool is_pf; + + switch (blktype) { + case BLKTYPE_NPA: + blkaddr = BLKADDR_NPA; + goto exit; + case BLKTYPE_NIX: + /* For now assume NIX0 */ + if (!pcifunc) { + blkaddr = BLKADDR_NIX0; + goto exit; + } + break; + case BLKTYPE_SSO: + blkaddr = BLKADDR_SSO;
Re: [PATCH v8 08/15] octeontx2-af: Add RVU block LF provisioning support
On Sun, Oct 7, 2018 at 5:00 PM wrote: > > +/* Structure for requesting resource provisioning. > + * 'modify' flag to be used when either requesting more > + * or to detach partial of a cetain resource type. > + * Rest of the fields specify how many of what type to > + * be attached. > + */ > +struct rsrc_attach { > + struct mbox_msghdr hdr; > + u8 modify:1; > + u8 npalf:1; > + u8 nixlf:1; > + u16 sso; > + u16 ssow; > + u16 timlfs; > + u16 cptlfs; > +}; > + > +/* Structure for relinquishing resources. > + * 'partial' flag to be used when relinquishing all resources > + * but only of a certain type. If not set, all resources of all > + * types provisioned to the RVU function will be detached. > + */ > +struct rsrc_detach { > + struct mbox_msghdr hdr; > + u8 partial:1; > + u8 npalf:1; > + u8 nixlf:1; > + u8 sso:1; > + u8 ssow:1; > + u8 timlfs:1; > + u8 cptlfs:1; > +}; Are these bitfields part of the message that gets sent to the underlying implementation? It seems there is still an endianess issue then. Arnd
Re: [PATCH v8 08/15] octeontx2-af: Add RVU block LF provisioning support
On Mon, Oct 8, 2018 at 5:41 PM Arnd Bergmann wrote: > > On Sun, Oct 7, 2018 at 5:00 PM wrote: > > > > +/* Structure for requesting resource provisioning. > > + * 'modify' flag to be used when either requesting more > > + * or to detach partial of a cetain resource type. > > + * Rest of the fields specify how many of what type to > > + * be attached. > > + */ > > +struct rsrc_attach { > > + struct mbox_msghdr hdr; > > + u8 modify:1; > > + u8 npalf:1; > > + u8 nixlf:1; > > + u16 sso; > > + u16 ssow; > > + u16 timlfs; > > + u16 cptlfs; > > +}; > > + > > +/* Structure for relinquishing resources. > > + * 'partial' flag to be used when relinquishing all resources > > + * but only of a certain type. If not set, all resources of all > > + * types provisioned to the RVU function will be detached. > > + */ > > +struct rsrc_detach { > > + struct mbox_msghdr hdr; > > + u8 partial:1; > > + u8 npalf:1; > > + u8 nixlf:1; > > + u8 sso:1; > > + u8 ssow:1; > > + u8 timlfs:1; > > + u8 cptlfs:1; > > +}; > > Are these bitfields part of the message that gets sent to the > underlying implementation? It seems there is still an endianess > issue then. > >Arnd No these structures are not used for kernel driver to firmware communication where register reads via readq are involved. These structures are used for mailbox communication between different PCI devices and this mailbox is a shared memory. Sunil.
Re: [PATCH v8 08/15] octeontx2-af: Add RVU block LF provisioning support
On Mon, Oct 8, 2018 at 3:59 PM Sunil Kovvuri wrote: > On Mon, Oct 8, 2018 at 5:41 PM Arnd Bergmann wrote: > > On Sun, Oct 7, 2018 at 5:00 PM wrote: > > > > > > +/* Structure for requesting resource provisioning. > > > + * 'modify' flag to be used when either requesting more > > > + * or to detach partial of a cetain resource type. > > > + * Rest of the fields specify how many of what type to > > > + * be attached. > > > + */ > > > +struct rsrc_attach { > > > + struct mbox_msghdr hdr; > > > + u8 modify:1; > > > + u8 npalf:1; > > > + u8 nixlf:1; > > > + u16 sso; > > > + u16 ssow; > > > + u16 timlfs; > > > + u16 cptlfs; > > > +}; > > > + > > > +/* Structure for relinquishing resources. > > > + * 'partial' flag to be used when relinquishing all resources > > > + * but only of a certain type. If not set, all resources of all > > > + * types provisioned to the RVU function will be detached. > > > + */ > > > +struct rsrc_detach { > > > + struct mbox_msghdr hdr; > > > + u8 partial:1; > > > + u8 npalf:1; > > > + u8 nixlf:1; > > > + u8 sso:1; > > > + u8 ssow:1; > > > + u8 timlfs:1; > > > + u8 cptlfs:1; > > > +}; > > > > Are these bitfields part of the message that gets sent to the > > underlying implementation? It seems there is still an endianess > > issue then. > > No these structures are not used for kernel driver to firmware > communication where > register reads via readq are involved. These structures are used for > mailbox communication > between different PCI devices and this mailbox is a shared memory. Ok, thanks for the clarification. Arnd