From patchwork Sun Jul 30 07:41:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suman Ghosh X-Patchwork-Id: 128191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp1389127vqg; Sun, 30 Jul 2023 01:06:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZZYz1fHPiiIdzQLfjaqLK7dn2E+tyStI7XSDZsixAlRURbYm3lLApflkMVwfhO2y1G5Zb X-Received: by 2002:a17:90b:4a0c:b0:268:a5f6:2a97 with SMTP id kk12-20020a17090b4a0c00b00268a5f62a97mr3277126pjb.1.1690704367983; Sun, 30 Jul 2023 01:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690704367; cv=none; d=google.com; s=arc-20160816; b=xFL4PV/Hf9o2DaZgB6bzjAGeGtNJb2ggAL52n6zLkRUovNVTnnolknd9qfnf+r+whS HUY0mrMtVBWbN4luy0iUawlNDrSHPmbqQLeqdLpiFOFKBWPipatulyfyzn7q112eLpbN xxG84wrz07ZUpCa6jV3A1QSJUuGVX6A5C2T7OOt2RBR8HHGNrju5D8YhOcwUkYv5AIEh aW4PmhGy5YvkGPzAtw7t5dGzbUB09nMi5W52ZYTSo6j/SVTrsyV375v8+xUkES/VXyV5 4LezZMc8jInrzlk9W2PuUIt5e8EQGDXOApMb9BL5WGrrlB0dTOV9xv3kDlu9CcRNIBcB nTPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8peA6WwzHL0O8VTemZNDv1A+nje61jhJKdnZn2NLSVI=; fh=3ywq1KMjSb2Yjp0wxi04N5wIQTK9ttBDVyDx2nr5PZ0=; b=xjPDaHOU9+z3zwmEncKOY/5d7XhbzIaaxOIIsZDPv04QC5nOF6/Jz3ryJ9o2Txevrk OoBfvp8q5xxssUii/r1sKq9tFkIARAmVO2TM1h96omlr1BYuQri09N2aNpqXhuxoIZtv pTwQjGNZXT0b7OD7y0glA/UQ9xmgJM5MY3fgfiwv1DhUhGwWB/pGiGkMFnOFrTYxSP4b +gHUfqMSw1c3q5pcYxfDslGlUjlok5H70sbuiMoMXllwqzYbALvb7lqHit+vnzzStdoX HpR2AdTVLcKCB1PIPI+JE+3XDd/Vtyo3BBrqXlfVj+pnUiX28FvsP01lzUPPuNZ02vzc btMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b="ETLLNB/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a17090a4ec100b00263cfc9753csi1092999pjl.5.2023.07.30.01.05.54; Sun, 30 Jul 2023 01:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b="ETLLNB/N"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbjG3HmL (ORCPT + 99 others); Sun, 30 Jul 2023 03:42:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjG3HmH (ORCPT ); Sun, 30 Jul 2023 03:42:07 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4697719B7; Sun, 30 Jul 2023 00:42:06 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36U2r879032253; Sun, 30 Jul 2023 00:41:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=8peA6WwzHL0O8VTemZNDv1A+nje61jhJKdnZn2NLSVI=; b=ETLLNB/N0GT7zFfNevYtvfPtdv2vAw3iQZSj/iQvRinSAVOUCCte1wYQbBifS066f+Rw 0k8MBayu9mzOCSyGaZbvoZ+lsZh3oAI47VNJ9J3K1L8d0FJJoC8sJTfcm6sWqbpCJiQ1 YidJEhqdtia2OUYiQ0zSl+N7kRPG15d7BUI/oWSUZDQZsVeb02dEMAH2cP8ZpIw6/QG3 1fS595ogz7JfkpnYyudQPQ7dRqSclg6rA0sQ3gyI9emPlZs1zvnF1f+SmiTxgLDkeAnC AXX9zthGE68goDl/2N1y+0OjFOIJNBgI/4Ciq2A/JFsIZWYeb06Io1wfhhNKG4xJ0VL4 mA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3s504nj5wb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 30 Jul 2023 00:41:50 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 30 Jul 2023 00:41:49 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Sun, 30 Jul 2023 00:41:49 -0700 Received: from localhost.localdomain (unknown [10.28.36.166]) by maili.marvell.com (Postfix) with ESMTP id E0C463F706D; Sun, 30 Jul 2023 00:41:44 -0700 (PDT) From: Suman Ghosh To: , , , , , , , , , , , , CC: Suman Ghosh Subject: [net-next PATCH 1/2] octeontx2-af: Code restructure to handle TC outer VLAN offload Date: Sun, 30 Jul 2023 13:11:33 +0530 Message-ID: <20230730074134.2838427-2-sumang@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230730074134.2838427-1-sumang@marvell.com> References: <20230730074134.2838427-1-sumang@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 2o4XJbUfCOQMZEwoLcGqdW8h7cDDrnxr X-Proofpoint-GUID: 2o4XJbUfCOQMZEwoLcGqdW8h7cDDrnxr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-27_10,2023-07-26_01,2023-05-22_02 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772832023258804856 X-GMAIL-MSGID: 1772832023258804856 Moved the TC outer VLAN offload support to a seperate function. This change is done to handle all VLAN related changes cleanly from a dedicated function. Signed-off-by: Suman Ghosh --- .../ethernet/marvell/octeontx2/nic/otx2_tc.c | 93 +++++++++++-------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c index 0915a0121316..ba2a1e8a9b9c 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c @@ -439,6 +439,55 @@ static int otx2_tc_parse_actions(struct otx2_nic *nic, return 0; } +static int otx2_tc_process_vlan(struct otx2_nic *nic, struct flow_msg *flow_spec, + struct flow_msg *flow_mask, struct flow_rule *rule, + struct npc_install_flow_req *req, bool is_inner) +{ + struct flow_match_vlan match; + u16 vlan_tci, vlan_tci_mask; + + if (is_inner) + return -EOPNOTSUPP; + + flow_rule_match_vlan(rule, &match); + if ((ntohs(match.key->vlan_tpid) != ETH_P_8021Q)) { + netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n", + ntohs(match.key->vlan_tpid)); + return -EOPNOTSUPP; + } + + if (!match.mask->vlan_id) { + struct flow_action_entry *act; + int i; + + flow_action_for_each(i, act, &rule->action) { + if (act->id == FLOW_ACTION_DROP) { + netdev_err(nic->netdev, + "vlan tpid 0x%x with vlan_id %d is not supported for DROP rule.\n", + ntohs(match.key->vlan_tpid), match.key->vlan_id); + return -EOPNOTSUPP; + } + } + } + + if (match.mask->vlan_id || + match.mask->vlan_dei || + match.mask->vlan_priority) { + vlan_tci = match.key->vlan_id | + match.key->vlan_dei << 12 | + match.key->vlan_priority << 13; + + vlan_tci_mask = match.mask->vlan_id | + match.mask->vlan_dei << 12 | + match.mask->vlan_priority << 13; + flow_spec->vlan_tci = htons(vlan_tci); + flow_mask->vlan_tci = htons(vlan_tci_mask); + req->features |= BIT_ULL(NPC_OUTER_VID); + } + + return 0; +} + static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node, struct flow_cls_offload *f, struct npc_install_flow_req *req) @@ -564,47 +613,11 @@ static int otx2_tc_prepare_flow(struct otx2_nic *nic, struct otx2_tc_flow *node, } if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_VLAN)) { - struct flow_match_vlan match; - u16 vlan_tci, vlan_tci_mask; - - flow_rule_match_vlan(rule, &match); - - if (ntohs(match.key->vlan_tpid) != ETH_P_8021Q) { - netdev_err(nic->netdev, "vlan tpid 0x%x not supported\n", - ntohs(match.key->vlan_tpid)); - return -EOPNOTSUPP; - } - - if (!match.mask->vlan_id) { - struct flow_action_entry *act; - int i; - - flow_action_for_each(i, act, &rule->action) { - if (act->id == FLOW_ACTION_DROP) { - netdev_err(nic->netdev, - "vlan tpid 0x%x with vlan_id %d is not supported for DROP rule.\n", - ntohs(match.key->vlan_tpid), - match.key->vlan_id); - return -EOPNOTSUPP; - } - } - } + int ret; - if (match.mask->vlan_id || - match.mask->vlan_dei || - match.mask->vlan_priority) { - vlan_tci = match.key->vlan_id | - match.key->vlan_dei << 12 | - match.key->vlan_priority << 13; - - vlan_tci_mask = match.mask->vlan_id | - match.mask->vlan_dei << 12 | - match.mask->vlan_priority << 13; - - flow_spec->vlan_tci = htons(vlan_tci); - flow_mask->vlan_tci = htons(vlan_tci_mask); - req->features |= BIT_ULL(NPC_OUTER_VID); - } + ret = otx2_tc_process_vlan(nic, flow_spec, flow_mask, rule, req, false); + if (ret) + return ret; } if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {