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 CB6B3A0032; Sat, 22 Oct 2022 10:25:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 65BD042670; Sat, 22 Oct 2022 10:24:57 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2118.outbound.protection.outlook.com [40.107.92.118]) by mails.dpdk.org (Postfix) with ESMTP id 358A040042 for ; Sat, 22 Oct 2022 10:24:54 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=djhXFM80xl3ntLZjGKwSZbH4emhn/tdkVRL4fmXK5WNzm6vIga+/rxN6CmnVXH9xg5hwqx0yZ9kQGvRSpR7IwQc2D5cXU59JNGZ0iB6ULJmDgswFhcwrfmRt2B3Nkup0O3fcsafgPUvcEv2JOGupUePKlJmCPMcsLHqbwe6GbOYp6Ve7AGIeOEUtv9R/Rv9RKWH6v9RRPr/tn1+P9IFcsCwqkB5MfRYefpVlFuRPNsSpkQizoApfhiFqFugUB1dnDP7Xo58AOgtUIeDKkN9eZ/XB/I9T3EwzqIrJV6//JcFoFeXvGiyIBc03VLMGEXOOkOSMFoqSILSt/ZijmT6O2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vNZn2FgEk5oatDEcEXneuTB+ZkcT1erk2q+Yvsv4088=; b=Hl9ingtsrgwKU27tvwGAajbDFtmWUxpIRv93vX1sqIAKgjRyp3Nw/STmM963T+5pA0CWudjoyryDXii4sKQR4SJJpUcFagFOmjSSSVWBEhFH+d+d0aa6bKMtibz1t136zsrxwkdVzPDQ22p1MxjGa/TWS3UOcnCxhom1LFqio2+G1gro6DF7uuEHCZNDnjquC6uJmCGLOK4dM0Saw8oxwe8X80A7Ak3dLg6pZD9aWX2n+a00Y2LUVAV1X+JKnGmYyrQSWTuDBV1aB2cMzQwlNI4an6zR1aPlzZy0F0a3lMjAF0bXsQKwC5Q0xW/BwwTIAurfFxuihjJ/wyx0D3TlNQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vNZn2FgEk5oatDEcEXneuTB+ZkcT1erk2q+Yvsv4088=; b=ZDIZyk86aK0IMkDZWO0i919AMYgZ+kZ/83qTGXOFcRRf32Vbet7yCvlFsdpotEZlCbulepTp89v3403qfGZxDl/VYGhVxmZuGXmUGRxqeosNeAcenm/imchr/5Gw9woOeghuZfUJsMju05INTyZGMdmFyrF3LjpaHASVUN/mojs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by CH2PR13MB3848.namprd13.prod.outlook.com (2603:10b6:610:9d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Sat, 22 Oct 2022 08:24:52 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7c26:1a0b:2825:6f4b%4]) with mapi id 15.20.5723.014; Sat, 22 Oct 2022 08:24:52 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH v2 03/25] net/nfp: prepare for IPv4 tunnel encap flow action Date: Sat, 22 Oct 2022 16:24:07 +0800 Message-Id: <1666427069-10553-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> References: <1666063359-34283-1-git-send-email-chaoyong.he@corigine.com> <1666427069-10553-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR02CA0056.apcprd02.prod.outlook.com (2603:1096:4:54::20) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CH2PR13MB3848:EE_ X-MS-Office365-Filtering-Correlation-Id: 69ad5777-75b9-471d-1b63-08dab406e46f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9aBV3EfnGvSLAqFolnM72jUhZf0kcv+Q8nF9umqE9t3tikIgmeyUcrkWPmpWh+DPgo6uEYYaRHoJrcQbnFeaxpfNkZ7nt1dlbYDqmJ9mrrbZe5LYGEpQOAJesk0SwURNHEH0f9ep+6/LKMKUPziv4sHr2J7nEu/5ZuRECKsNFtxrDB6Z4UtjDio9NU5zkEIKrzWjO7IB0X1YsYucF3D6zueZgmw2brE2Rw9/Oho9aI1u/qxFW93hDFbAqOgr6pDt6bMC0QSPfObJVWJXH2jMWsrnqWCgbbXA7Bvv8Y2WC+bkGUrHsJjo3alfn8QOkfxTIFmtlQaekQNWG25qqE/mXXnZXG1O82il9DUlRrhjThtV7rxrHepmjNhfBoJBopWleVTP1Sgiho1YoIb0IBWAfUHcOA9LoIl2DlCYO/BmVpPl084wtkPG3B3Grtay8jFggdX3UfPJcjzPVqYYacSxmQBzRvBTWQLJ6+M96ST3cix6N7d+8zobICSkif2DH5MJzSJAarLCxWXCDwD8u2wDZ7K5gN3cCJqK7RcUmupcKflJyZTLbKlRFWrcrlrZtgDqBOGoEsndzoUMg/lt3+WL0iVHqgN4lSZr+4LJHutR3fqVFNOkNpgJiAAUdJ3GwbiyDmb7namZvocANtPUFKR2n2H5HNHdfRQV6/OtxV5Ixkd+YacM2zPOY96dKPEn5FndKZYxeativiL/bEwXkIkRzw/BeH7iTZ2jISVM02ZvNCvOJrHhgRJz5kXiut2NfRhuvfUCUVLrOtX9e6X8/TYbSw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(136003)(366004)(396003)(39830400003)(346002)(376002)(451199015)(4326008)(107886003)(36756003)(38100700002)(66946007)(66556008)(316002)(6512007)(83380400001)(52116002)(66476007)(8676002)(44832011)(66574015)(6666004)(6506007)(30864003)(38350700002)(5660300002)(8936002)(6916009)(2616005)(478600001)(186003)(41300700001)(26005)(6486002)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UHFlL1c3WUNRY1AxL1R5MmV3RnQwaGhIMFBGb3RweU5Wa05oT3JXc3l4aXFj?= =?utf-8?B?eFovUzVkSjhmMFJpcVEzWmlyK0JuUGNkV3IwU0VhUG9uQzF5a0ZCV1NjQk9K?= =?utf-8?B?eFoxNWhJWDRHb1FvU0JaR3FkejR4dEtuRVIvODlua1VpangzQzdsdlZSdk44?= =?utf-8?B?cnlIeWJGTTNUbUo0dlFhbS96WTVCWFhLcWJqTDRPNkR3OStSbzV5MmZxU3dT?= =?utf-8?B?QUZZVVJjaTZlOVBPK2lONGVVdVNhd0RXQkVCak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jVaaXJzcE1FVmIzbWtBaWw0dmZneFlsZ1NEM1kraXplbFYydFZu?= =?utf-8?B?NHNQRHJLMnA1N2lKcUFTUVc0Q0F2TVBBUUFRc24xMmdwM1Ixa0Q5elM0NVo2?= =?utf-8?B?c1E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69ad5777-75b9-471d-1b63-08dab406e46f X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2022 08:24:52.2886 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tcOc55/bqL4LeEH+M3ApJ4UhIXQ9HR0NL5/80eN6uoVGBtUgWl5JQ7mOGJd36F/Fjmohuud/Crm/O+YJVRGg9ZNdYmjxqnHee75qQoLic1s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR13MB3848 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 Add the related data structure and functions, prepare for the encap action of IPv4 tunnel. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/flower/nfp_flower_cmsg.c | 29 ++++++++++ drivers/net/nfp/flower/nfp_flower_cmsg.h | 93 ++++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_flow.c | 88 ++++++++++++++++++++++++++++++ drivers/net/nfp/nfp_flow.h | 27 ++++++++++ 4 files changed, 237 insertions(+) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 15d8381..7021d1f 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -246,3 +246,32 @@ return 0; } + +int +nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_flower_cmsg_tun_neigh_v4 *payload) +{ + uint16_t cnt; + size_t msg_len; + struct rte_mbuf *mbuf; + struct nfp_flower_cmsg_tun_neigh_v4 *msg; + + mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool); + if (mbuf == NULL) { + PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v4 tun neigh"); + return -ENOMEM; + } + + msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v4); + msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH, msg_len); + memcpy(msg, payload, msg_len); + + cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf); + if (cnt == 0) { + PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed."); + rte_pktmbuf_free(mbuf); + return -EIO; + } + + return 0; +} diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h index 996ba3b..e44e311 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -129,6 +129,36 @@ struct nfp_flower_cmsg_port_mod { rte_be16_t mtu; }; +struct nfp_flower_tun_neigh { + uint8_t dst_mac[RTE_ETHER_ADDR_LEN]; + uint8_t src_mac[RTE_ETHER_ADDR_LEN]; + rte_be32_t port_id; +}; + +/* + * NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V4 + * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + * -----\ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +---------------------------------------------------------------+ + * 0 | DST_IPV4 | + * +---------------------------------------------------------------+ + * 1 | SRC_IPV4 | + * +---------------------------------------------------------------+ + * 2 | DST_MAC_B5_B4_B3_B2 | + * +-------------------------------+-------------------------------+ + * 3 | DST_MAC_B1_B0 | SRC_MAC_B5_B4 | + * +-------------------------------+-------------------------------+ + * 4 | SRC_MAC_B3_B2_B1_B0 | + * +---------------------------------------------------------------+ + * 5 | Egress Port (NFP internal) | + * +---------------------------------------------------------------+ + */ +struct nfp_flower_cmsg_tun_neigh_v4 { + rte_be32_t dst_ipv4; + rte_be32_t src_ipv4; + struct nfp_flower_tun_neigh common; +}; + /* * NFP_FLOWER_CMSG_TYPE_FLOW_STATS * Bit 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 @@ -574,6 +604,67 @@ struct nfp_fl_act_set_tport { rte_be16_t dst_port; }; +/* + * Pre-tunnel + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | - | opcode | |jump_id| - |M| - |V| + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_daddr_127_96 / ipv4_daddr | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_daddr_95_64 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_daddr_63_32 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv6_daddr_31_0 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_fl_act_pre_tun { + struct nfp_fl_act_head head; + rte_be16_t flags; + union { + rte_be32_t ipv4_dst; + uint8_t ipv6_dst[16]; + }; +}; + +/* + * Set tunnel + * 3 2 1 + * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | res | opcode | res | len_lw| reserved | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | tun_id0 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | tun_id1 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved | type |r| idx | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | ipv4_flags | ttl | tos | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved_cvs1 | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | reserved_cvs2 | reserved_cvs3 | + * | var_flags | var_np | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ +struct nfp_fl_act_set_tun { + struct nfp_fl_act_head head; + rte_be16_t reserved; + rte_be64_t tun_id; + rte_be32_t tun_type_index; + rte_be16_t tun_flags; + uint8_t ttl; + uint8_t tos; + rte_be16_t outer_vlan_tpid; + rte_be16_t outer_vlan_tci; + uint8_t tun_len; /* Only valid for NFP_FL_TUNNEL_GENEVE */ + uint8_t reserved2; + rte_be16_t tun_proto; /* Only valid for NFP_FL_TUNNEL_GENEVE */ +} __rte_packed; + int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower); int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower, struct nfp_flower_representor *repr); @@ -583,5 +674,7 @@ int nfp_flower_cmsg_flow_delete(struct nfp_app_fw_flower *app_fw_flower, struct rte_flow *flow); int nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower, struct rte_flow *flow); +int nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_flower_cmsg_tun_neigh_v4 *payload); #endif /* _NFP_CMSG_H_ */ diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index bbd9dba..f71f8b1 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -1772,6 +1772,91 @@ struct nfp_mask_id_entry { tc_hl->reserved = 0; } +__rte_unused static void +nfp_flow_pre_tun_v4_process(struct nfp_fl_act_pre_tun *pre_tun, + rte_be32_t ipv4_dst) +{ + pre_tun->head.jump_id = NFP_FL_ACTION_OPCODE_PRE_TUNNEL; + pre_tun->head.len_lw = sizeof(struct nfp_fl_act_pre_tun) >> NFP_FL_LW_SIZ; + pre_tun->ipv4_dst = ipv4_dst; +} + +__rte_unused static void +nfp_flow_set_tun_process(struct nfp_fl_act_set_tun *set_tun, + enum nfp_flower_tun_type tun_type, + uint64_t tun_id, + uint8_t ttl, + uint8_t tos) +{ + /* Currently only support one pre-tunnel, so index is always 0. */ + uint8_t pretun_idx = 0; + uint32_t tun_type_index; + + tun_type_index = ((tun_type << 4) & 0xf0) | (pretun_idx & 0x07); + + set_tun->head.jump_id = NFP_FL_ACTION_OPCODE_SET_TUNNEL; + set_tun->head.len_lw = sizeof(struct nfp_fl_act_set_tun) >> NFP_FL_LW_SIZ; + set_tun->tun_type_index = rte_cpu_to_be_32(tun_type_index); + set_tun->tun_id = rte_cpu_to_be_64(tun_id); + set_tun->ttl = ttl; + set_tun->tos = tos; +} + +__rte_unused static int +nfp_flower_add_tun_neigh_v4_encap(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_fl_rule_metadata *nfp_flow_meta, + struct nfp_fl_tun *tun, + const struct rte_ether_hdr *eth, + const struct rte_flow_item_ipv4 *ipv4) +{ + struct nfp_fl_tun *tmp; + struct nfp_flow_priv *priv; + struct nfp_flower_in_port *port; + struct nfp_flower_cmsg_tun_neigh_v4 payload; + + tun->payload.v6_flag = 0; + tun->payload.dst.dst_ipv4 = ipv4->hdr.dst_addr; + tun->payload.src.src_ipv4 = ipv4->hdr.src_addr; + memcpy(tun->payload.dst_addr, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + memcpy(tun->payload.src_addr, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + + tun->ref_cnt = 1; + priv = app_fw_flower->flow_priv; + LIST_FOREACH(tmp, &priv->nn_list, next) { + if (memcmp(&tmp->payload, &tun->payload, sizeof(struct nfp_fl_tun_entry)) == 0) { + tmp->ref_cnt++; + return 0; + } + } + + LIST_INSERT_HEAD(&priv->nn_list, tun, next); + + port = (struct nfp_flower_in_port *)((char *)nfp_flow_meta + + sizeof(struct nfp_fl_rule_metadata) + + sizeof(struct nfp_flower_meta_tci)); + + memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v4)); + payload.dst_ipv4 = ipv4->hdr.dst_addr; + payload.src_ipv4 = ipv4->hdr.src_addr; + memcpy(payload.common.dst_mac, eth->dst_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + memcpy(payload.common.src_mac, eth->src_addr.addr_bytes, RTE_ETHER_ADDR_LEN); + payload.common.port_id = port->in_port; + + return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload); +} + +__rte_unused static int +nfp_flower_del_tun_neigh_v4(struct nfp_app_fw_flower *app_fw_flower, + rte_be32_t ipv4) +{ + struct nfp_flower_cmsg_tun_neigh_v4 payload; + + memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v4)); + payload.dst_ipv4 = ipv4; + + return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload); +} + static int nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor, const struct rte_flow_action actions[], @@ -2487,6 +2572,9 @@ struct nfp_mask_id_entry { goto free_mask_table; } + /* neighbor next list */ + LIST_INIT(&priv->nn_list); + return 0; free_mask_table: diff --git a/drivers/net/nfp/nfp_flow.h b/drivers/net/nfp/nfp_flow.h index 0ad89e5..892dbc0 100644 --- a/drivers/net/nfp/nfp_flow.h +++ b/drivers/net/nfp/nfp_flow.h @@ -90,6 +90,11 @@ enum nfp_flower_tun_type { NFP_FL_TUN_GENEVE = 4, }; +enum nfp_flow_type { + NFP_FLOW_COMMON, + NFP_FLOW_ENCAP, +}; + struct nfp_fl_key_ls { uint32_t key_layer_two; uint8_t key_layer; @@ -118,6 +123,24 @@ struct nfp_fl_payload { char *action_data; }; +struct nfp_fl_tun { + LIST_ENTRY(nfp_fl_tun) next; + uint8_t ref_cnt; + struct nfp_fl_tun_entry { + uint8_t v6_flag; + uint8_t dst_addr[RTE_ETHER_ADDR_LEN]; + uint8_t src_addr[RTE_ETHER_ADDR_LEN]; + union { + rte_be32_t dst_ipv4; + uint8_t dst_ipv6[16]; + } dst; + union { + rte_be32_t src_ipv4; + uint8_t src_ipv6[16]; + } src; + } payload; +}; + #define CIRC_CNT(head, tail, size) (((head) - (tail)) & ((size) - 1)) #define CIRC_SPACE(head, tail, size) CIRC_CNT((tail), ((head) + 1), (size)) struct circ_buf { @@ -161,13 +184,17 @@ struct nfp_flow_priv { struct nfp_fl_stats_id stats_ids; /**< The stats id ring. */ struct nfp_fl_stats *stats; /**< Store stats of flow. */ rte_spinlock_t stats_lock; /** < Lock the update of 'stats' field. */ + /* neighbor next */ + LIST_HEAD(, nfp_fl_tun)nn_list; /**< Store nn entry */ }; struct rte_flow { struct nfp_fl_payload payload; + struct nfp_fl_tun tun; size_t length; uint32_t hash_key; bool install_flag; + enum nfp_flow_type type; }; int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev); -- 1.8.3.1