From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DD6FD42D2B; Fri, 23 Jun 2023 04:56:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 668C140E09; Fri, 23 Jun 2023 04:56:10 +0200 (CEST) Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by mails.dpdk.org (Postfix) with ESMTP id A4525400EF for ; Fri, 23 Jun 2023 04:56:08 +0200 (CEST) Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-6300f6ab032so1990756d6.2 for ; Thu, 22 Jun 2023 19:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687488968; x=1690080968; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AkggxoJXcwRYpp9mH0eW+bXgNKpAo4k+YWsqCAHToiI=; b=qaBcIu3mBynxfJttuxm2qVg8Cx2yt7rqAP0HWEN95Apf47X0ysca6PXETEABEpK10T AA9+9BDAMnzsXRKRAkXBrFhWzyOatKkPbBXWYqvRhiiIyYXMjT4CSJJI344vHaPD3eFA yubGPVilmAinlWKFbxwz6Z75GCH/VIlab6ytI54V8HlroKq21pfuLp3MMpoNkNVQM5mV DH2gakLJASqi+QC/2DFl8f3BhRwAAX8zhodbkSdEFdmpiBK/37g4jTObTp+b20E7wb1R 9tERYQwV78AaekI2vvNjfGNxFHBW7KiMzvM6ARfgcyUraeUPpvK2vbcOsu2fJnfzS0uN UDiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687488968; x=1690080968; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AkggxoJXcwRYpp9mH0eW+bXgNKpAo4k+YWsqCAHToiI=; b=dYeWvfyzIuj0uBeauhXLImuaauoQQEyOZ8Gj4/n/5+2Z2vCwxuaMUpibp8VllBc5U9 b2DlqHusw+4WYP/SEYFMwkx++HP3emniHbTcqs2N4V/nfckczNF0guTKogBCwZ0Zl5hw bBdgRZXE2UiU+I3z6zK6RJ6wUCSni3HF350wByX82ykwzvFI+Wvr3ysxuXPMEhnBUJY7 SE7bAP+k3vi+sjgKtAQHhfXQOobDB9Q5dsHwi9LHlj22zO3wdJbaHvkgpeZcoE9wkwjT H1Ll718rntjH/YHfidfyHoR+MPEw6+9oXjf0vy9TFeUdIFylecGdMU+geVpSXzdtLpkK NJYQ== X-Gm-Message-State: AC+VfDwrUWWoxjJvgm5E2Ly0ltAF93wm5D0FM/x6B8kKl3w0kuY7guNs Tc6Ymi9LoZRk0C9D5dEZIsavdXVw/rfBykn2Bkg= X-Google-Smtp-Source: ACHHUZ4FXYr4KO1aQZReC4D27y9Zo8v8/vpJ8C5WfuIW0gEaCnfHQjO2ig43wso53c+WxyfCjvHeS/3WIK9oQm9zDJg= X-Received: by 2002:a05:6214:27e3:b0:62f:ebed:2ba3 with SMTP id jt3-20020a05621427e300b0062febed2ba3mr23025756qvb.55.1687488967818; Thu, 22 Jun 2023 19:56:07 -0700 (PDT) MIME-Version: 1.0 References: <20230622111807.2679750-1-vattunuru@marvell.com> In-Reply-To: <20230622111807.2679750-1-vattunuru@marvell.com> From: Jerin Jacob Date: Fri, 23 Jun 2023 08:25:41 +0530 Message-ID: Subject: Re: [PATCH] net/octeon_ep: support backward compatibility To: Vamsi Attunuru Cc: dev@dpdk.org, jerinj@marvell.com, sedara@marvell.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Jun 22, 2023 at 4:48=E2=80=AFPM Vamsi Attunuru wrote: > > From: Sathesh Edara > > Add backward compatibility support between VF > and PF mailbox messages. > > Signed-off-by: Sathesh Edara > Signed-off-by: Vamsi Attunuru Applied to dpdk-next-net-mrvl/for-next-net. Thanks > --- > drivers/net/octeon_ep/otx_ep_common.h | 3 +++ > drivers/net/octeon_ep/otx_ep_ethdev.c | 6 +++++ > drivers/net/octeon_ep/otx_ep_mbox.c | 38 ++++++++++++++++++++++----- > drivers/net/octeon_ep/otx_ep_mbox.h | 11 ++++++-- > 4 files changed, 50 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/octeon_ep/otx_ep_common.h b/drivers/net/octeon_e= p/otx_ep_common.h > index 42aa065a3a..c150cbe619 100644 > --- a/drivers/net/octeon_ep/otx_ep_common.h > +++ b/drivers/net/octeon_ep/otx_ep_common.h > @@ -538,6 +538,9 @@ struct otx_ep_device { > > /* Mailbox receive message length */ > int32_t mbox_rcv_message_len; > + > + /* Negotiated Mbox version */ > + uint32_t mbox_neg_ver; > }; > > int otx_ep_setup_iqs(struct otx_ep_device *otx_ep, uint32_t iq_no, > diff --git a/drivers/net/octeon_ep/otx_ep_ethdev.c b/drivers/net/octeon_e= p/otx_ep_ethdev.c > index a9868909f8..57b965ad06 100644 > --- a/drivers/net/octeon_ep/otx_ep_ethdev.c > +++ b/drivers/net/octeon_ep/otx_ep_ethdev.c > @@ -666,6 +666,12 @@ otx_ep_eth_dev_init(struct rte_eth_dev *eth_dev) > otx_epvf->port_id =3D eth_dev->data->port_id; > eth_dev->dev_ops =3D &otx_ep_eth_dev_ops; > rte_spinlock_init(&otx_epvf->mbox_lock); > + > + /* > + * Initialize negotiated Mbox version to base version of VF Mbox > + * This will address working legacy PF with latest VF. > + */ > + otx_epvf->mbox_neg_ver =3D OTX_EP_MBOX_VERSION_V1; > eth_dev->data->mac_addrs =3D rte_zmalloc("otx_ep", RTE_ETHER_ADDR= _LEN, 0); > if (eth_dev->data->mac_addrs =3D=3D NULL) { > otx_ep_err("MAC addresses memory allocation failed\n"); > diff --git a/drivers/net/octeon_ep/otx_ep_mbox.c b/drivers/net/octeon_ep/= otx_ep_mbox.c > index 1ad36e14c8..4118645dc7 100644 > --- a/drivers/net/octeon_ep/otx_ep_mbox.c > +++ b/drivers/net/octeon_ep/otx_ep_mbox.c > @@ -12,6 +12,14 @@ > #include "cnxk_ep_vf.h" > #include "otx_ep_mbox.h" > > +/* > + * When a new command is implemented, the below table should be updated > + * with new command and it's version info. > + */ > +static uint32_t otx_ep_cmd_versions[OTX_EP_MBOX_CMD_MAX] =3D { > + [0 ... OTX_EP_MBOX_CMD_DEV_REMOVE] =3D OTX_EP_MBOX_VERSION_V1 > +}; > + > static int > __otx_ep_send_mbox_cmd(struct otx_ep_device *otx_ep, > union otx_ep_mbox_word cmd, > @@ -56,6 +64,12 @@ otx_ep_send_mbox_cmd(struct otx_ep_device *otx_ep, > int ret; > > rte_spinlock_lock(&otx_ep->mbox_lock); > + if (otx_ep_cmd_versions[cmd.s.opcode] > otx_ep->mbox_neg_ver) { > + otx_ep_dbg("CMD:%d not supported in Version:%d\n", cmd.s.= opcode, > + otx_ep->mbox_neg_ver); > + rte_spinlock_unlock(&otx_ep->mbox_lock); > + return -EOPNOTSUPP; > + } > ret =3D __otx_ep_send_mbox_cmd(otx_ep, cmd, rsp); > rte_spinlock_unlock(&otx_ep->mbox_lock); > return ret; > @@ -284,15 +298,27 @@ int otx_ep_mbox_version_check(struct rte_eth_dev *e= th_dev) > > cmd.u64 =3D 0; > cmd.s_version.opcode =3D OTX_EP_MBOX_CMD_VERSION; > - cmd.s_version.version =3D OTX_EP_MBOX_VERSION; > + cmd.s_version.version =3D OTX_EP_MBOX_VERSION_CURRENT; > ret =3D otx_ep_send_mbox_cmd(otx_ep, cmd, &rsp); > - if (!ret) > - return 0; > - if (ret =3D=3D OTX_EP_MBOX_CMD_STATUS_NACK) { > - otx_ep_err("VF Mbox version:%u is not compatible with PF\= n", > + > + /* > + * VF receives NACK or version info as zero > + * only if PF driver running old version of Mailbox > + * In this case VF mailbox version fallbacks to base > + * mailbox vesrion OTX_EP_MBOX_VERSION_V1. > + * Default VF mbox_neg_ver is set to OTX_EP_MBOX_VERSION_V1 > + * during initialization of PMD driver. > + */ > + if (ret =3D=3D OTX_EP_MBOX_CMD_STATUS_NACK || rsp.s_version.versi= on =3D=3D 0) { > + otx_ep_dbg("VF Mbox version fallback to base version from= :%u\n", > (uint32_t)cmd.s_version.version); > + return 0; > } > - return ret; > + otx_ep->mbox_neg_ver =3D (uint32_t)rsp.s_version.version; > + otx_ep_dbg("VF Mbox version:%u Negotiated VF version with PF:%u\n= ", > + (uint32_t)cmd.s_version.version, > + (uint32_t)rsp.s_version.version); > + return 0; > } > > int otx_ep_mbox_send_dev_exit(struct rte_eth_dev *eth_dev) > diff --git a/drivers/net/octeon_ep/otx_ep_mbox.h b/drivers/net/octeon_ep/= otx_ep_mbox.h > index 9df3c53edd..a3fc15cca7 100644 > --- a/drivers/net/octeon_ep/otx_ep_mbox.h > +++ b/drivers/net/octeon_ep/otx_ep_mbox.h > @@ -5,8 +5,15 @@ > #ifndef _OTX_EP_MBOX_H_ > #define _OTX_EP_MBOX_H_ > > +/* > + * When a new command is implemented, VF Mbox version should be bumped. > + */ > +enum octep_pfvf_mbox_version { > + OTX_EP_MBOX_VERSION_V0, > + OTX_EP_MBOX_VERSION_V1, > +}; > > -#define OTX_EP_MBOX_VERSION 1 > +#define OTX_EP_MBOX_VERSION_CURRENT OTX_EP_MBOX_VERSION_V1 > > enum otx_ep_mbox_opcode { > OTX_EP_MBOX_CMD_VERSION, > @@ -20,7 +27,7 @@ enum otx_ep_mbox_opcode { > OTX_EP_MBOX_CMD_GET_LINK_STATUS, > OTX_EP_MBOX_CMD_GET_MTU, > OTX_EP_MBOX_CMD_DEV_REMOVE, > - OTX_EP_MBOX_CMD_LAST, > + OTX_EP_MBOX_CMD_MAX, > }; > > enum otx_ep_mbox_word_type { > -- > 2.25.1 >