From patchwork Fri Feb 22 11:15:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 50442 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E48912BF4; Fri, 22 Feb 2019 12:16:00 +0100 (CET) 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+ifjexLRDNf2ZLL2SOcwTulv?= =?iso-8859-1?q?gr9LTPYTeRxn353lrolKG01B2g8YU7LSHNMWGajTtONpONGmOqE?= =?iso-8859-1?q?lIHSdGKIu3047itABDL9/+yz6CNRcCFH+3M2TNaGjtKbYzGu9tH?= =?iso-8859-1?q?V3OZG+cXBHvZwnok6h1M8ZUDewWJ0IsKSbbN5XRbS7jyUayOApr?= =?iso-8859-1?q?wrmHrtr8ks89im4r2aF6a3w80Xh6xq0YQv4l5xxdCB0gKE8h5RF?= =?iso-8859-1?q?yKQnR/4q59+1BJwpdoThuXrDgmXaqxtlhQw32CsgQ0kjHKfibDG?= =?iso-8859-1?q?ScdxMxiBEl/ZjHZNE/AJiKzffGjzlEoorLMmrioFxo52M9+lo7b?= =?iso-8859-1?q?s37mbJk03vyk2SlojzRUMWGJaRul2TocnlIMlEQOFnP1N7d70Bz?= =?iso-8859-1?q?HQOu+yruusWwdceTmYthui0mL5fCkOrxtPEiwgCcBdp+BgGCaFc?= =?iso-8859-1?q?EZ7o//Y0WNkgNe3Ga1UZQdeJaL1kha0nxqS+pH28G3FMlmVgY8K?= =?iso-8859-1?q?v8EIr6LnJVeq7EclSCOBQadq7z/f9PudqL/XaIQggkwxc58Vmyl?= =?iso-8859-1?q?jmJjcfM72m3kC+TLml4iKWkbjL2H/xxzlbkiFe3DAkDoILGTZmX?= =?iso-8859-1?q?XAusKZex6eAzD6K3Q+srhdkcfmvBAKu4wHQ0ZARXba20DF6eYxJ?= =?iso-8859-1?q?FqEEyveIiOzy/D2iHBaHGfuTgmJOgZ//Vxm7qFuw3oCY5/JO24F?= =?iso-8859-1?q?Vb7NkJieWtq/KLybe2K3WE/+pAU1+SNjTn8j4RsEJpl86rYjcSt?= =?iso-8859-1?q?1tLM+wYbsjWnTZi1gdIwvAZzKEc8M2r6qq8bNESh7efjdUfDpO0?= =?iso-8859-1?q?pOx4H+q+Enrx4w2B9vRxV82dBr41lq7ZjT8pyE16vPVoKygHRRX?= =?iso-8859-1?q?+d7kBRX6FLEHUV/jgpqbgjthaThZ0YDQFklLiynxXo4i/VaaLEV?= =?iso-8859-1?q?vizK3Unb+QgSbxWdBcapddo9j3JYU5kOs2ZlqbPjd2oJbQAJeUO?= =?iso-8859-1?q?toCxyUuPciEVhrt0ZNqPcVPfRykh8jFD787pRphpniJBEPAZb9S?= =?iso-8859-1?q?s8HGHEhv+bwqFqIcIi1iGKHKVOzL6z34ez63GIJCSAPBMKvv6to?= =?iso-8859-1?q?LLNakA8YK2zD6Sas31lFOCw/dZvG1aPACTrkIvhSr267e889kPg?= =?iso-8859-1?q?WOXZ5MstJjDoH5KluLGwsMlaqEGgPETpmV1R04ST+K8IFYHSHAC?= =?iso-8859-1?q?ytJJtMceqObgKhaEr3IewTa5hzJwDiC2szMaf/lw7wGyJkV8/uD?= =?iso-8859-1?q?BCq6sOxMOCXymG/pjkAbpob+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= 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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_ethdev.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 mask) return 0; } +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 = dev->data->dev_private; + struct fsl_mc_io *dpni = priv->hw; + int ret = -ENOTSUP; + + PMD_INIT_FUNC_TRACE(); + + /* nothing to be done for standard vlan tpids */ + if (tpid == 0x8100 || tpid == 0x88A8) + return 0; + + ret = dpni_add_custom_tpid(dpni, CMD_PRI_LOW, + priv->token, tpid); + if (ret < 0) + DPAA2_PMD_INFO("Unable to set vlan tpid = %d", ret); + /* if already configured tpids, remove them first */ + if (ret == -EBUSY) { + struct dpni_custom_tpid_cfg tpid_list = {0}; + + ret = dpni_get_custom_tpid(dpni, CMD_PRI_LOW, + priv->token, &tpid_list); + if (ret < 0) + goto fail; + ret = dpni_remove_custom_tpid(dpni, CMD_PRI_LOW, + priv->token, tpid_list.tpid1); + if (ret < 0) + goto fail; + ret = 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 = { .mtu_set = dpaa2_dev_mtu_set, .vlan_filter_set = dpaa2_vlan_filter_set, .vlan_offload_set = dpaa2_vlan_offload_set, + .vlan_tpid_set = dpaa2_vlan_tpid_set, .rx_queue_setup = dpaa2_dev_rx_queue_setup, .rx_queue_release = dpaa2_dev_rx_queue_release, .tx_queue_setup = 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, 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 = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_CUSTOM_TPID, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_add_custom_tpid *)cmd.params; + cmd_params->tpid = 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() needs + * 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 = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_CUSTOM_TPID, + cmd_flags, + token); + cmd_params = (struct dpni_cmd_remove_custom_tpid *)cmd.params; + cmd_params->tpid = 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 configured + * 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 = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_CUSTOM_TPID, + cmd_flags, + token); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* read command response */ + rsp_params = (struct dpni_rsp_get_custom_tpid *)cmd.params; + tpid->tpid1 = le16_to_cpu(rsp_params->tpid1); + tpid->tpid2 = le16_to_cpu(rsp_params->tpid2); + + return err; +} diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.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); +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 custom 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) /* 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; }; +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 */