Commit 6145fefc authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'cn10k-ipswec-outbound-inline-support'

Bharat Bhushan says:

====================
cn10k-ipsec: Add outbound inline ipsec support

This patch series adds outbound inline ipsec support on Marvell
cn10k series of platform. One crypto hardware logical function
(cpt-lf) per netdev is required for inline ipsec outbound
functionality. Software prepare and submit crypto hardware
(CPT) instruction for outbound inline ipsec crypto mode offload.
The CPT instruction have details for encryption and authentication
Crypto hardware encrypt, authenticate and provide the ESP packet
to network hardware logic to transmit ipsec packet.

First patch makes dma memory writable for in-place encryption,
Second patch moves code to common file, Third patch disable
backpressure on crypto (CPT) and network (NIX) hardware.
Patch four onwards enables inline outbound ipsec.

v9->v10:
 - Removed unlikely() in data-patch and used static_branch when at least
   a SA is configured.
 - Added missing READ_ONCE() as per comment on previous patch
 - Removed "\n" from end of extack messages
 - Poll for context write status check reduced to 100ms from 10s

v8->v9:
 - Removed mutex lock to use hardware, now using hardware state
 - Previous versions were supporting only 64 SAs and a bitmap was
   used for same. That limitation is removed from this version.
 - Replaced netdev_err with NL_SET_ERR_MSG_MOD in state add flow
   as per comment in previous version

v7->v8:
 - spell correction in patch 1/8 (s/sdk/skb)

v6->v7:
 - skb data was mapped as device writeable but it was not ensured
   that skb is writeable. This version calls skb_unshare() to make
   skb data writeable (Thanks Jakub Kicinski for pointing out).

v4->v5:
 - Fixed un-initialized warning and pointer check
   (comment from Kalesh Anakkur Purayil)

v3->v4:
 - Few error messages in data-path removed and some moved
   under netif_msg_tx_err().
 - Added check for crypto offload (XFRM_DEV_OFFLOAD_CRYPTO)
   Thanks "Leon Romanovsky" for pointing out
 - Fixed codespell error as per comment from Simon Horman
 - Added some other cleanup comment from Kalesh Anakkur Purayil

v2->v3:
 - Fix smatch and sparse errors (Comment from Simon Horman)
 - Fix build error with W=1 (Comment from Simon Horman)
   https://patchwork.kernel.org/project/netdevbpf/patch/20240513105446.297451-6-bbhushan2@marvell.com/
 - Some other minor cleanup as per comment
   https://www.spinics.net/lists/netdev/msg997197.html



v1->v2:
 - Fix compilation error to build driver a module
 - Use dma_wmb() instead of architecture specific barrier
 - Fix couple of other compilation warnings
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7ea27457 b3ae3dc3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -13942,6 +13942,7 @@ M: Sunil Goutham <sgoutham@marvell.com>
M:	Geetha sowjanya <gakula@marvell.com>
M:	Subbaraya Sundeep <sbhatta@marvell.com>
M:	hariprasad <hkelam@marvell.com>
M:	Bharat Bhushan <bbhushan2@marvell.com>
L:	netdev@vger.kernel.org
S:	Supported
F:	drivers/net/ethernet/marvell/octeontx2/nic/
+4 −0
Original line number Diff line number Diff line
@@ -313,6 +313,10 @@ M(NIX_BANDPROF_FREE, 0x801e, nix_bandprof_free, nix_bandprof_free_req, \
				msg_rsp)				    \
M(NIX_BANDPROF_GET_HWINFO, 0x801f, nix_bandprof_get_hwinfo, msg_req,		\
				nix_bandprof_get_hwinfo_rsp)		    \
M(NIX_CPT_BP_ENABLE,    0x8020, nix_cpt_bp_enable, nix_bp_cfg_req,	    \
				nix_bp_cfg_rsp)				    \
M(NIX_CPT_BP_DISABLE,   0x8021, nix_cpt_bp_disable, nix_bp_cfg_req,	    \
				msg_rsp)				\
M(NIX_READ_INLINE_IPSEC_CFG, 0x8023, nix_read_inline_ipsec_cfg,		\
				msg_req, nix_inline_ipsec_cfg)		\
M(NIX_MCAST_GRP_CREATE,	0x802b, nix_mcast_grp_create, nix_mcast_grp_create_req,	\
+58 −10
Original line number Diff line number Diff line
@@ -569,9 +569,17 @@ void rvu_nix_flr_free_bpids(struct rvu *rvu, u16 pcifunc)
	mutex_unlock(&rvu->rsrc_lock);
}

int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
static u16 nix_get_channel(u16 chan, bool cpt_link)
{
	/* CPT channel for a given link channel is always
	 * assumed to be BIT(11) set in link channel.
	 */
	return cpt_link ? chan | BIT(11) : chan;
}

static int nix_bp_disable(struct rvu *rvu,
			  struct nix_bp_cfg_req *req,
				    struct msg_rsp *rsp)
			  struct msg_rsp *rsp, bool cpt_link)
{
	u16 pcifunc = req->hdr.pcifunc;
	int blkaddr, pf, type, err;
@@ -579,6 +587,7 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
	struct rvu_pfvf *pfvf;
	struct nix_hw *nix_hw;
	struct nix_bp *bp;
	u16 chan_v;
	u64 cfg;

	pf = rvu_get_pf(pcifunc);
@@ -589,6 +598,9 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
	if (is_sdp_pfvf(pcifunc))
		type = NIX_INTF_TYPE_SDP;

	if (cpt_link && !rvu->hw->cpt_links)
		return 0;

	pfvf = rvu_get_pfvf(rvu, pcifunc);
	err = nix_get_struct_ptrs(rvu, pcifunc, &nix_hw, &blkaddr);
	if (err)
@@ -597,8 +609,9 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
	bp = &nix_hw->bp;
	chan_base = pfvf->rx_chan_base + req->chan_base;
	for (chan = chan_base; chan < (chan_base + req->chan_cnt); chan++) {
		cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan));
		rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan),
		chan_v = nix_get_channel(chan, cpt_link);
		cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v));
		rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v),
			    cfg & ~BIT_ULL(16));

		if (type == NIX_INTF_TYPE_LBK) {
@@ -617,6 +630,20 @@ int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
	return 0;
}

int rvu_mbox_handler_nix_bp_disable(struct rvu *rvu,
				    struct nix_bp_cfg_req *req,
				    struct msg_rsp *rsp)
{
	return nix_bp_disable(rvu, req, rsp, false);
}

int rvu_mbox_handler_nix_cpt_bp_disable(struct rvu *rvu,
					struct nix_bp_cfg_req *req,
					struct msg_rsp *rsp)
{
	return nix_bp_disable(rvu, req, rsp, true);
}

static int rvu_nix_get_bpid(struct rvu *rvu, struct nix_bp_cfg_req *req,
			    int type, int chan_id)
{
@@ -696,15 +723,17 @@ static int rvu_nix_get_bpid(struct rvu *rvu, struct nix_bp_cfg_req *req,
	return bpid;
}

int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
static int nix_bp_enable(struct rvu *rvu,
			 struct nix_bp_cfg_req *req,
				   struct nix_bp_cfg_rsp *rsp)
			 struct nix_bp_cfg_rsp *rsp,
			 bool cpt_link)
{
	int blkaddr, pf, type, chan_id = 0;
	u16 pcifunc = req->hdr.pcifunc;
	struct rvu_pfvf *pfvf;
	u16 chan_base, chan;
	s16 bpid, bpid_base;
	u16 chan_v;
	u64 cfg;

	pf = rvu_get_pf(pcifunc);
@@ -717,6 +746,9 @@ int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
	    type != NIX_INTF_TYPE_SDP)
		return 0;

	if (cpt_link && !rvu->hw->cpt_links)
		return 0;

	pfvf = rvu_get_pfvf(rvu, pcifunc);
	blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);

@@ -730,9 +762,11 @@ int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
			return -EINVAL;
		}

		cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan));
		chan_v = nix_get_channel(chan, cpt_link);

		cfg = rvu_read64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v));
		cfg &= ~GENMASK_ULL(8, 0);
		rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan),
		rvu_write64(rvu, blkaddr, NIX_AF_RX_CHANX_CFG(chan_v),
			    cfg | (bpid & GENMASK_ULL(8, 0)) | BIT_ULL(16));
		chan_id++;
		bpid = rvu_nix_get_bpid(rvu, req, type, chan_id);
@@ -750,6 +784,20 @@ int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
	return 0;
}

int rvu_mbox_handler_nix_bp_enable(struct rvu *rvu,
				   struct nix_bp_cfg_req *req,
				   struct nix_bp_cfg_rsp *rsp)
{
	return nix_bp_enable(rvu, req, rsp, false);
}

int rvu_mbox_handler_nix_cpt_bp_enable(struct rvu *rvu,
				       struct nix_bp_cfg_req *req,
				       struct nix_bp_cfg_rsp *rsp)
{
	return nix_bp_enable(rvu, req, rsp, true);
}

static void nix_setup_lso_tso_l3(struct rvu *rvu, int blkaddr,
				 u64 format, bool v4, u64 *fidx)
{
+1 −0
Original line number Diff line number Diff line
@@ -15,5 +15,6 @@ rvu_rep-y := rep.o

rvu_nicpf-$(CONFIG_DCB) += otx2_dcbnl.o
rvu_nicpf-$(CONFIG_MACSEC) += cn10k_macsec.o
rvu_nicpf-$(CONFIG_XFRM_OFFLOAD) += cn10k_ipsec.o

ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af
+1058 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading