From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50040.outbound.protection.outlook.com [40.107.5.40]) by dpdk.org (Postfix) with ESMTP id A53AF1E34 for ; Fri, 22 Feb 2019 12:15:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IIZCRlbjWQWa1r2Zo+9Z9h3dWRD+Rv4Gm3FfeId03BA=; b=whfIh/Aq4HRZ3ZU0GPYrsUMMr98pt0am1rA97kJ4HgtMGSxbyEhWBNwTEe+JkdXuBS/IVES4w5ArAN20LqsOQW7TDF7aMvuuEacWW7IFSUPPoTcylGhxodU3d3A088kcTiqhZn60lllkk0XYX4vQvIchy2zzb6zlrqyo6XnH97Q= Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com (10.168.65.19) by VI1PR0401MB2431.eurprd04.prod.outlook.com (10.169.134.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.14; Fri, 22 Feb 2019 11:15:58 +0000 Received: from VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::1cad:15be:6f7e:cb84]) by VI1PR0401MB2541.eurprd04.prod.outlook.com ([fe80::1cad:15be:6f7e:cb84%9]) with mapi id 15.20.1643.016; Fri, 22 Feb 2019 11:15:58 +0000 From: Hemant Agrawal To: "dev@dpdk.org" CC: "ferruh.yigit@intel.com" , Shreyansh Jain Thread-Topic: [PATCH 1/6] net/dpaa2: add support for VLAN tpid config Thread-Index: AQHUyp/81xWmFcOo60GlJhRracTplA== Date: Fri, 22 Feb 2019 11:15:58 +0000 Message-ID: <20190222111440.30530-1-hemant.agrawal@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [92.120.1.72] x-mailer: git-send-email 2.17.1 x-clientproxiedby: BM1PR01CA0084.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::24) To VI1PR0401MB2541.eurprd04.prod.outlook.com (2603:10a6:800:56::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c40bdb05-6ece-4352-4e51-08d698b71e89 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0401MB2431; x-ms-traffictypediagnostic: VI1PR0401MB2431: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; VI1PR0401MB2431; 23:iT6VY+dzuezg6ec4dHysjiS4FCsxhgS5bM4HN?= =?iso-8859-1?Q?a+ifjexLRDNf2ZLL2SOcwTulvgr9LTPYTeRxn353lrolKG01B2g8YU7LSH?= =?iso-8859-1?Q?NMWGajTtONpONGmOqElIHSdGKIu3047itABDL9/+yz6CNRcCFH+3M2TNaG?= =?iso-8859-1?Q?jtKbYzGu9tHV3OZG+cXBHvZwnok6h1M8ZUDewWJ0IsKSbbN5XRbS7jyUay?= =?iso-8859-1?Q?OAprwrmHrtr8ks89im4r2aF6a3w80Xh6xq0YQv4l5xxdCB0gKE8h5RFyKQ?= =?iso-8859-1?Q?nR/4q59+1BJwpdoThuXrDgmXaqxtlhQw32CsgQ0kjHKfibDGScdxMxiBEl?= =?iso-8859-1?Q?/ZjHZNE/AJiKzffGjzlEoorLMmrioFxo52M9+lo7bs37mbJk03vyk2Sloj?= =?iso-8859-1?Q?zRUMWGJaRul2TocnlIMlEQOFnP1N7d70BzHQOu+yruusWwdceTmYthui0m?= =?iso-8859-1?Q?L5fCkOrxtPEiwgCcBdp+BgGCaFcEZ7o//Y0WNkgNe3Ga1UZQdeJaL1kha0?= =?iso-8859-1?Q?nxqS+pH28G3FMlmVgY8Kv8EIr6LnJVeq7EclSCOBQadq7z/f9PudqL/XaI?= =?iso-8859-1?Q?Qggkwxc58VmyljmJjcfM72m3kC+TLml4iKWkbjL2H/xxzlbkiFe3DAkDoI?= =?iso-8859-1?Q?LGTZmXXAusKZex6eAzD6K3Q+srhdkcfmvBAKu4wHQ0ZARXba20DF6eYxJF?= =?iso-8859-1?Q?qEEyveIiOzy/D2iHBaHGfuTgmJOgZ//Vxm7qFuw3oCY5/JO24FVb7NkJie?= =?iso-8859-1?Q?Wtq/KLybe2K3WE/+pAU1+SNjTn8j4RsEJpl86rYjcSt1tLM+wYbsjWnTZi?= =?iso-8859-1?Q?1gdIwvAZzKEc8M2r6qq8bNESh7efjdUfDpO0pOx4H+q+Enrx4w2B9vRxV8?= =?iso-8859-1?Q?2dBr41lq7ZjT8pyE16vPVoKygHRRX+d7kBRX6FLEHUV/jgpqbgjthaThZ0?= =?iso-8859-1?Q?YDQFklLiynxXo4i/VaaLEVvizK3Unb+QgSbxWdBcapddo9j3JYU5kOs2Zl?= =?iso-8859-1?Q?qbPjd2oJbQAJeUOtoCxyUuPciEVhrt0ZNqPcVPfRykh8jFD787pRphpniJ?= =?iso-8859-1?Q?BEPAZb9Ss8HGHEhv+bwqFqIcIi1iGKHKVOzL6z34ez63GIJCSAPBMKvv6t?= =?iso-8859-1?Q?oLLNakA8YK2zD6Sas31lFOCw/dZvG1aPACTrkIvhSr267e889kPgWOXZ5M?= =?iso-8859-1?Q?stJjDoH5KluLGwsMlaqEGgPETpmV1R04ST+K8IFYHSHACytJJtMceqObgK?= =?iso-8859-1?Q?haEr3IewTa5hzJwDiC2szMaf/lw7wGyJkV8/uDBCq6sOxMOCXymG/pjkAb?= =?iso-8859-1?Q?pob+XjbaLPjJZ9mupR/Hh/frP?= x-microsoft-antispam-prvs: x-forefront-prvs: 09565527D6 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(376002)(396003)(136003)(366004)(189003)(199004)(2906002)(99286004)(8936002)(105586002)(26005)(54906003)(3846002)(6116002)(106356001)(71190400001)(8676002)(97736004)(316002)(6506007)(6512007)(1730700003)(5640700003)(81156014)(71200400001)(102836004)(36756003)(14444005)(256004)(386003)(6486002)(50226002)(81166006)(6436002)(6916009)(86362001)(1076003)(305945005)(478600001)(5660300002)(68736007)(44832011)(2616005)(486006)(2501003)(53936002)(2351001)(66066001)(7736002)(4326008)(186003)(14454004)(25786009)(52116002)(476003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2431; H:VI1PR0401MB2541.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: d4uGTR96uSbixOdTzdK3uQ7qgqdnyRJp2jW4lx4cWVCFCNBnj0pYNrVqiX83k3/4CmbxaWzQMijABqYYT4ouofVHfRmqt1HMEcFB36D6svg0oeL6MjX6w/R/enBU3wS3j9SHAD/2yl7G93zovKnL9dB80YaxWJYEXCseJzVBOpDADy53aP37U9M9s9/lsaQYLO3iL0SCMHcuzkuH+5QsjGvNfUDL4yVWcaMjAkyKuc9R1UR2+EaXAfFG6Soeq2oNk9HOyKMN/nz7t7Z50r9b/MOj1i8v9xIjKH+GIMCoJ8+mYMkz8EU+lR1qfaKkpnKuLFqjzk3CLDXHUb1AktELG6q7ir5AZWmpGY17kA0dgynRctATCx2CZwsGUG4ayEiaXenqfIJyx9L5/MD6GShDCwOgU2pyTx+DG/tBZgTxi2Y= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c40bdb05-6ece-4352-4e51-08d698b71e89 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Feb 2019 11:15:57.0139 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2431 Subject: [dpdk-dev] [PATCH 1/6] net/dpaa2: add support for VLAN tpid config X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2019 11:15:59 -0000 This patch add support to config custom tpid in dpni. i.e. value other than 0x8100 and 0x88A8 Signed-off-by: Hemant Agrawal --- drivers/net/dpaa2/dpaa2_ethdev.c | 39 ++++++++++++ drivers/net/dpaa2/mc/dpni.c | 98 +++++++++++++++++++++++++++++ drivers/net/dpaa2/mc/fsl_dpni.h | 20 ++++++ drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 18 ++++++ 4 files changed, 175 insertions(+) diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_eth= dev.c index 2b90f4021..bc3faa8a3 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -161,6 +161,44 @@ dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int ma= sk) return 0; } =20 +static int +dpaa2_vlan_tpid_set(struct rte_eth_dev *dev, + enum rte_vlan_type vlan_type __rte_unused, + uint16_t tpid) +{ + struct dpaa2_dev_priv *priv =3D dev->data->dev_private; + struct fsl_mc_io *dpni =3D priv->hw; + int ret =3D -ENOTSUP; + + PMD_INIT_FUNC_TRACE(); + + /* nothing to be done for standard vlan tpids */ + if (tpid =3D=3D 0x8100 || tpid =3D=3D 0x88A8) + return 0; + + ret =3D dpni_add_custom_tpid(dpni, CMD_PRI_LOW, + priv->token, tpid); + if (ret < 0) + DPAA2_PMD_INFO("Unable to set vlan tpid =3D %d", ret); + /* if already configured tpids, remove them first */ + if (ret =3D=3D -EBUSY) { + struct dpni_custom_tpid_cfg tpid_list =3D {0}; + + ret =3D dpni_get_custom_tpid(dpni, CMD_PRI_LOW, + priv->token, &tpid_list); + if (ret < 0) + goto fail; + ret =3D dpni_remove_custom_tpid(dpni, CMD_PRI_LOW, + priv->token, tpid_list.tpid1); + if (ret < 0) + goto fail; + ret =3D dpni_add_custom_tpid(dpni, CMD_PRI_LOW, + priv->token, tpid); + } +fail: + return ret; +} + static int dpaa2_fw_version_get(struct rte_eth_dev *dev, char *fw_version, @@ -1832,6 +1870,7 @@ static struct eth_dev_ops dpaa2_ethdev_ops =3D { .mtu_set =3D dpaa2_dev_mtu_set, .vlan_filter_set =3D dpaa2_vlan_filter_set, .vlan_offload_set =3D dpaa2_vlan_offload_set, + .vlan_tpid_set =3D dpaa2_vlan_tpid_set, .rx_queue_setup =3D dpaa2_dev_rx_queue_setup, .rx_queue_release =3D dpaa2_dev_rx_queue_release, .tx_queue_setup =3D dpaa2_dev_tx_queue_setup, diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c index 44b5604d3..0907a3699 100644 --- a/drivers/net/dpaa2/mc/dpni.c +++ b/drivers/net/dpaa2/mc/dpni.c @@ -2063,3 +2063,101 @@ int dpni_get_opr(struct fsl_mc_io *mc_io, =20 return 0; } + +/** + * dpni_add_custom_tpid() - Configures a distinct Ethertype value + * (or TPID value) to indicate VLAN tag in addition to the common + * TPID values 0x8100 and 0x88A8 + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @tpid: New value for TPID + * + * Only two custom values are accepted. If the function is called for the = third + * time it will return error. + * To replace an existing value use dpni_remove_custom_tpid() to remove + * a previous TPID and after that use again the function. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, + uint16_t token, uint16_t tpid) +{ + struct dpni_cmd_add_custom_tpid *cmd_params; + struct mc_command cmd =3D { 0 }; + + /* prepare command */ + cmd.header =3D mc_encode_cmd_header(DPNI_CMDID_ADD_CUSTOM_TPID, + cmd_flags, + token); + cmd_params =3D (struct dpni_cmd_add_custom_tpid *)cmd.params; + cmd_params->tpid =3D cpu_to_le16(tpid); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpni_remove_custom_tpid() - Removes a distinct Ethertype value added + * previously with dpni_add_custom_tpid() + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @tpid: New value for TPID + * + * Use this function when a TPID value added with dpni_add_custom_tpid() n= eeds + * to be replaced. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, + uint16_t token, uint16_t tpid) +{ + struct dpni_cmd_remove_custom_tpid *cmd_params; + struct mc_command cmd =3D { 0 }; + + /* prepare command */ + cmd.header =3D mc_encode_cmd_header(DPNI_CMDID_REMOVE_CUSTOM_TPID, + cmd_flags, + token); + cmd_params =3D (struct dpni_cmd_remove_custom_tpid *)cmd.params; + cmd_params->tpid =3D cpu_to_le16(tpid); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpni_get_custom_tpid() - Returns custom TPID (vlan tags) values configu= red + * to detect 802.1q frames + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPNI object + * @tpid: TPID values. Only nonzero members of the structure are valid. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, + uint16_t token, struct dpni_custom_tpid_cfg *tpid) +{ + struct dpni_rsp_get_custom_tpid *rsp_params; + struct mc_command cmd =3D { 0 }; + int err; + + /* prepare command */ + cmd.header =3D mc_encode_cmd_header(DPNI_CMDID_GET_CUSTOM_TPID, + cmd_flags, + token); + + /* send command to mc*/ + err =3D mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* read command response */ + rsp_params =3D (struct dpni_rsp_get_custom_tpid *)cmd.params; + tpid->tpid1 =3D le16_to_cpu(rsp_params->tpid1); + tpid->tpid2 =3D le16_to_cpu(rsp_params->tpid2); + + return err; +} diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpn= i.h index de1bcb5bf..0359a2bc7 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni.h +++ b/drivers/net/dpaa2/mc/fsl_dpni.h @@ -1202,4 +1202,24 @@ int dpni_get_opr(struct fsl_mc_io *mc_io, struct opr_cfg *cfg, struct opr_qry *qry); =20 +int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, + uint16_t token, uint16_t tpid); + +int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, + uint16_t token, uint16_t tpid); + +/** + * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custo= m TPID + * values used in current dpni object to detect 802.1q frames. + * @tpid1: first tag. Not used if zero. + * @tpid2: second tag. Not used if zero. + */ +struct dpni_custom_tpid_cfg { + uint16_t tpid1; + uint16_t tpid2; +}; + +int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, + uint16_t token, struct dpni_custom_tpid_cfg *tpid); + #endif /* __FSL_DPNI_H */ diff --git a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h b/drivers/net/dpaa2/mc/fsl= _dpni_cmd.h index 3df5bcf1f..81830ed85 100644 --- a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h +++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h @@ -91,6 +91,9 @@ #define DPNI_CMDID_GET_TX_CONFIRMATION_MODE DPNI_CMD(0x26D) #define DPNI_CMDID_SET_OPR DPNI_CMD(0x26e) #define DPNI_CMDID_GET_OPR DPNI_CMD(0x26f) +#define DPNI_CMDID_ADD_CUSTOM_TPID DPNI_CMD(0x275) +#define DPNI_CMDID_REMOVE_CUSTOM_TPID DPNI_CMD(0x276) +#define DPNI_CMDID_GET_CUSTOM_TPID DPNI_CMD(0x277) =20 /* Macros for accessing command fields smaller than 1byte */ #define DPNI_MASK(field) \ @@ -674,5 +677,20 @@ struct dpni_rsp_get_opr { uint16_t opr_id; }; =20 +struct dpni_cmd_add_custom_tpid { + uint16_t pad; + uint16_t tpid; +}; + +struct dpni_cmd_remove_custom_tpid { + uint16_t pad; + uint16_t tpid; +}; + +struct dpni_rsp_get_custom_tpid { + uint16_t tpid1; + uint16_t tpid2; +}; + #pragma pack(pop) #endif /* _FSL_DPNI_CMD_H */ --=20 2.17.1