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 F3AE5A0560; Tue, 18 Oct 2022 05:23:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 483D941611; Tue, 18 Oct 2022 05:23:09 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2116.outbound.protection.outlook.com [40.107.92.116]) by mails.dpdk.org (Postfix) with ESMTP id 84B0441145 for ; Tue, 18 Oct 2022 05:23:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lkkak+Mb7w6JF/B7jPhlrFg1HhgWL2ANx6ASl0AgiCKDJfQ/th0TXUAFkCE5xbMVaWfaPRoj41Cs6vx4YUaH7f6oYVmFhPF1HzKB1tIYDC4G0ODPjOb3wWT9MeLh7BfCzviuKPsNMrH10y+aumtpABA6Di1Pq/p3j0NM3gpyy5q1vmSrlJUVZz+j2hvp2gogL2iFe6hoeFgFo3d8H8fcJnDsenJBp9PdgzqGHyQCbmdk0UxwmwB4OCU0jok5XznpObsiD0tqbR1vizPcbMru3kD8wRODE+47l3U6eI5Rvi7rCNdzJTOdzcY0aZvRnOeCQFrQpEe5GkM9PVNBGB98JA== 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=4CUk+G9h76MfIOsBBGYwPHwwuniuOrxw2oN7NyllumA=; b=jLtt5zq16pd3EdvOvWSyn0xp+wMrFbXBsJk6W4B2CO1iI4Zk6ZjknpbJRa2eHdYW2+abb5JaFuML3XHX5R87JbQajAE5dNmKDOkhKkgFU/VoX8vJ+w2DdONXdHpNVvQ2ZYpZmqAqLu3Xv3spHaeQZYJ8Iu/bjTUfzBvHWOWtwc6lq3/6YTlMROHn8h98iGDtNpW1XAMC/z5Q4An97JY+vsPatLUQJw35G4OTEZeYFESkDs/lmKM2RpH77E/Nr3FSn8CwuisTJKJ5jla4YXOul4lQ0GB5/8LX4YIjZ/zCeo17TMVdkXBFUecSiJEs2+e06i5wtEPWDfE7T4+NS3athg== 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=4CUk+G9h76MfIOsBBGYwPHwwuniuOrxw2oN7NyllumA=; b=COaG1kfQwnhVCFXwDnt7jHHdvboGcgJwiZHlYZg9mAoBKF3PrhbWEXUIldYSGgo1CCrPBV4FW8hyA2oooeSikangWZPcy6V7Oo3y3SxyqweNSNvs4t7jvIWrIhWEA/yCulrG3GGHdnN4yIXZf7jmNSncPRMchRwN3BrKWPgWZuI= 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 MN2PR13MB4149.namprd13.prod.outlook.com (2603:10b6:208:24f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Tue, 18 Oct 2022 03:23:05 +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; Tue, 18 Oct 2022 03:23:04 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 03/25] net/nfp: prepare for the encap action of IPv4 tunnel Date: Tue, 18 Oct 2022 11:22:17 +0800 Message-Id: <1666063359-34283-4-git-send-email-chaoyong.he@corigine.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666063359-34283-1-git-send-email-chaoyong.he@corigine.com> References: <1666063359-34283-1-git-send-email-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SG2PR01CA0184.apcprd01.prod.exchangelabs.com (2603:1096:4:189::9) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MN2PR13MB4149:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d6010b4-2d9e-4c18-ee1f-08dab0b811e5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EyqwGn+S7DhNy1R4fUmKz45cztY8CaNbtOHXgqC4vh4/e3XtZPmmP+o76ittYwOU3hiQ1KntySf+7ga8UQ4NoeyZ9rnLpj7LRP5cskmoVi4JOnNI9GLWndNdhid8p0+JN7cDMkM1dBbSopJCa7zmEjWBDMTkgbb9W+2ZDVUnyc9q6vYewLiZgmIvKle6rPJ/VbjfsNX0/QTVVGanOwhQdYxNqH0KyaC7zppj6A3F/irE6PtdAXYr+0tvM07aw+A9BcWfJ8d4VGo3GrzCu7xr+XXaoxrp7jPm7c8lCTm4ssi/o8/1X2b/GPaWfJpmmrIQziFv7n64EvQ6AUyaf0ug8gAjo7ovQnlZPopuV29ZlfFNi+LSEmVkVsiHnbV9JT9d0SvKEANreyRzB/EVjx/WmcrDi4+/TU3w0kD+qy+/TVTkHvbruxSeiaHaK3hCJY6mhy/3T7s3DE+gFGwL2kRWCKVLFaDgFFf5LwoSwTnP8jB/Pd4UO84XA3bZLFTSMUeD5T0TftBd+DGheH6a+0D96JXUtE+/LM1pOxaeOLGDpg3G2B/a2Y9mN5IkemYZE9WShzr0o8WCxU/UKM9G4AypP326S1qe/51RIwlMLPB4ThECB2ZWW3iH4x2tX1bJvpsmbv+r14UhxLVO8uXV2lz7GH89RrB2BjUGW8tdwdTiq0psLT64JvlYf4v7/1VCi/Nnij+AubMUB6U9SNThGqu6g1lzWQenG6q7zfYPJINHLSrQi64fjSwRQn+0y09CgItyEa7Z6myNTlvMqb1PViCpBlqr59rSSxCWZ1tvJjcUWRmWqS5mLLkdNjsRDg+ZsnC3 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)(346002)(376002)(396003)(39840400004)(451199015)(38350700002)(86362001)(38100700002)(36756003)(83380400001)(66574015)(5660300002)(52116002)(30864003)(6506007)(2616005)(26005)(6512007)(186003)(6666004)(2906002)(6916009)(316002)(6486002)(107886003)(4326008)(66946007)(66556008)(478600001)(8936002)(44832011)(41300700001)(8676002)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a2dyS1liaHJ1Vk5zYjl1MHdSaFFXMDc1aXVOZWpWQlU5eGhmU3ZkNzlPVU9q?= =?utf-8?B?N3dPUmtHV1VVUU5wc3RQc3dERzFFbjJYdUVHdGFLVnQxM1ZNUUdNUzNneERn?= =?utf-8?B?Qk1rZVhiT3hRQXR5c0ZkbEpLVGNweWlyMVYvU2FVeGNNbUhUZnBwUEo5TGNk?= =?utf-8?B?Z0c0YVhpZFRKNTBNTmRHUHB4Nk83TlZpTnhkZFRpT29YMThFTVdaWWNmR0dL?= =?utf-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EQrRlFiZUNMUGgwcFNxTjZ2enZQTDhtaGRi?= =?utf-8?B?eS82RTZFeVVnZVNIaGYwLzJ5ejRJSWNyWHNpUjBGL3JqQ3NFZm1RT08yY2ts?= =?utf-8?B?bTBsR3NHc1E5OGJVdVpHVEpMVFIwTWtGZm1zOHQvU0wyM2F5YjUxbUxQRElJ?= =?utf-8?B?Zmc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d6010b4-2d9e-4c18-ee1f-08dab0b811e5 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 03:23:04.8504 (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: OvWGD/vmc52sveaFgKf6VoCdtWtrSIdx5cjzOcaVlbVMuX9BJ8T/HdhGdOHJ+MgpoEfTLD+rLzTCQU5zo8EeZ8vlBHrNDHuqRVnmwKhGJlE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR13MB4149 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 1673518..6efb95a 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -1790,6 +1790,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[], @@ -2491,6 +2576,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 b3bd949..14da800 100644 --- a/drivers/net/nfp/nfp_flow.h +++ b/drivers/net/nfp/nfp_flow.h @@ -89,6 +89,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; @@ -117,6 +122,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 { @@ -160,12 +183,16 @@ 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; bool install_flag; + enum nfp_flow_type type; }; int nfp_flow_priv_init(struct nfp_pf_dev *pf_dev); -- 1.8.3.1