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 4BED9A0560; Tue, 18 Oct 2022 05:23:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5DD95427EA; Tue, 18 Oct 2022 05:23:10 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2092.outbound.protection.outlook.com [40.107.223.92]) by mails.dpdk.org (Postfix) with ESMTP id 6938541181 for ; Tue, 18 Oct 2022 05:23:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKxICAUVFSsEOy2AVVDEcvqUcYLJnm7bq0yNhQvHtjEbO+1Owqs/y3NW3QKABoplmsCLDaDxXtxT2MMIULpMdqqxW061hCssQopdQyqy43sfcVPu3mNj7ZF/VibI9XxeboEGA8K/XDVz60qIoA6PrqckotEhb/puuKqmtmn9nhwaoPv6QvGtg81leafGh1apxQmHvZvpJf+HRVd/57Sy9l7ZVZZ9ABZLQBjPTRTLSOJw5xCIww8eaFFCJpgJNnz+fKZDhamAy/kmhgcX6EVHOmVRQEQlN0JrOYKZGyjDu3L0JK9vmMIf/DOPGnlVI4uC/g0KLG6EUPgLHKTs9zQing== 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=TDUUDEJKkP/AIJPjzpvN7DarPK9rbabifcratuPi1FQ=; b=EA/mWYtNYSsGK60NQnRSHHu4sM7LguohKJmmluxMonsiNBgZpCGnAr/hGzTAVBbcQfyLig7SsqyDxXzs0BxyHamA9ahI6EqXpyh7s2uGAkFYQ0XIXvck9c+EPXpU3ws5iNq2PH6BsRkslL/go0WuNGsUh6hSqzfJDbagF9Wxjt11i7ulw08KqB8wD73tc9UKZUOpkAGNzpLIJwK7870zpx/GRyF9a0V9Y9JYp9ouU1gMnIM7wKvowyWQDlT9IQXvwrzIzCAS1DoqGx3wXcfneFTRsorkdsuAkcu7W7glEklpqkKBIME0Yn+0hpTKKNMDwxSHKcx33QUfqXqiFlmF9g== 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=TDUUDEJKkP/AIJPjzpvN7DarPK9rbabifcratuPi1FQ=; b=kY+TO24O0H9pgfAeHGNH2PrEe7ppzEj3M/owcAmVGtEqCcfAWx7LO6dF0+RyxSP9ZfCoS4vnYGVKDE5spilcRpYVj130v+ValeJCuJXkonRJUyJeKmYzhejzimEYRXM3pjPVXmzoT8R6YuVdKbsqCg/Y4Wmw87s0BWX4drz4qgA= 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:06 +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:06 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com, Chaoyong He Subject: [PATCH 04/25] net/nfp: prepare for the encap action of IPv6 tunnel Date: Tue, 18 Oct 2022 11:22:18 +0800 Message-Id: <1666063359-34283-5-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: 727c190e-c76d-41d5-0231-08dab0b81304 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PfA4I+CEQaGWiKCTwAEHN3K61q0/08cjaslkmrchYBZRv0LkeJ13xGA3XGyDoqIirAGS9sqATWNCr5r4cx0vCV/wa9nAHyyyESBMRwDjGwvicmd/TDUNQ6soeysDQHkGl6IURMJ1hkVgPMxOaAVO7sZfvGqTTWY31AGHmqc4InVIvfob9+V8wQ08IZsTFcwXs3zzl3i/jnJbmg/THq/EBNYE/3Rl+7ZkV3QGIGvhsxnjSIezitEoyuSWLhF8MnlwHI9KdwpaTa1/0cF2HoqktH7gDSDRjFxO3v/V7WuHWY++0N06ZzU9CH0BPGIz2Ayu17EYxiRimlTT7jn/9VlJ5FgbtLu32CnsSoTditCyK8XNTA/MTfK7UaDaI37e4WQwElRjjS3vet3kmlyws0hcgfEoD5wN6ow/F6gEd/wjobalhr/vk7bbbnfAy5anoNLrqtsxj54K7ZfhuutZ3d4EBVgCuwAWWh2adFQ0D4+uqLuD6/Y5Ep/kD1rdjXHHpOVouyaTU2XJRf+UXS79xioplcAkw/F+FEvENPQlhcDZ4x4l3qukvE9pL72IX97qSKSBbSKkSneAtPwoP/ABjQeTYISDDWv5nYbV+hmW6+mObUmUZUuC5bRRaK1GuIbwANO8KrIawtUAuoTAN7xijLyauX/x8RM8CvEhSVua384NYQBUzO7nITkO8IQzU5fEiPEXihSHM5ftreuSsZ5oRCoMlD/cTr7OFMwh6Z8CKj7wbRSs8X1rEosMaAmqGzYUQuTLnZZh8r12VKwyKX9enXFZRm/sghb7hxNOabR3uaGHyrqlboatVV6m/IO6k41hWSra 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)(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?ZmVhODRqL1ZRYkxDNlBDWEIrNzB0aXVsQ29hVjJJb3BuTHJpY0hGaFpna1B5?= =?utf-8?B?QitMQzVnRk9rSmdURlJkTG5uYmZ6Y0lnbUtRQlpGVzFvOEpscjg3RVhma0tk?= =?utf-8?B?UkVQRjhqYWV2YVg3TkJFSXprREJTaUxxUUxrSXdXdm41ZC9Hbm4wcXMrWndq?= =?utf-8?B?cmFGOVJMek15RW5raW1leGUwM1NKaDVKd1FSLzlISGd5ZkhDakV0eEM0UTZD?= =?utf-8?B?RHF5UDJqN2dUM2FWUmRETjUvWTJDZ3FxUHVHY2xmMWh2ajY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h?= =?utf-8?B?c0Z2TFNWK3AzVzJ4TDBGTnRZOXZyQ0dNSUVxSit4VWVBcW5yTDJzbXgrRmIz?= =?utf-8?B?Vy94UHA4djVJd3ZWd3FuOEV5YklUUFp2YUxFdFRPT044am5CNlVCRnhDREts?= =?utf-8?B?UXc9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 727c190e-c76d-41d5-0231-08dab0b81304 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:06.7097 (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: nYwizplBG2wHHhLyf0hUHxb937IZSH53PvCxk/0aK+/4QNMk1P5P2QCVh2J2L5ef7YCvDSrtsqzo4Pcc4ecat/dFWuuGwPJ3FbkD83MSJxQ= 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 IPv6 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 | 40 ++++++++++++ drivers/net/nfp/nfp_flow.c | 105 ++++++++++++++++++++++++++++++- 3 files changed, 173 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.c b/drivers/net/nfp/flower/nfp_flower_cmsg.c index 7021d1f..8983178 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.c +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.c @@ -275,3 +275,32 @@ return 0; } + +int +nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_flower_cmsg_tun_neigh_v6 *payload) +{ + uint16_t cnt; + size_t msg_len; + struct rte_mbuf *mbuf; + struct nfp_flower_cmsg_tun_neigh_v6 *msg; + + mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool); + if (mbuf == NULL) { + PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v6 tun neigh"); + return -ENOMEM; + } + + msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v6); + msg = nfp_flower_cmsg_init(mbuf, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6, 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 e44e311..d1e0562 100644 --- a/drivers/net/nfp/flower/nfp_flower_cmsg.h +++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h @@ -160,6 +160,42 @@ struct nfp_flower_cmsg_tun_neigh_v4 { }; /* + * NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6 + * 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_IPV6 [0] | + * +---------------------------------------------------------------+ + * 1 | DST_IPV6 [1] | + * +---------------------------------------------------------------+ + * 2 | DST_IPV6 [2] | + * +---------------------------------------------------------------+ + * 3 | DST_IPV6 [3] | + * +---------------------------------------------------------------+ + * 4 | SRC_IPV6 [0] | + * +---------------------------------------------------------------+ + * 5 | SRC_IPV6 [1] | + * +---------------------------------------------------------------+ + * 6 | SRC_IPV6 [2] | + * +---------------------------------------------------------------+ + * 7 | SRC_IPV6 [3] | + * +---------------------------------------------------------------+ + * 8 | DST_MAC_B5_B4_B3_B2 | + * +-------------------------------+-------------------------------+ + * 9 | DST_MAC_B1_B0 | SRC_MAC_B5_B4 | + * +-------------------------------+-------------------------------+ + * 10 | SRC_MAC_B3_B2_B1_B0 | + * +---------------+---------------+---------------+---------------+ + * 11 | Egress Port (NFP internal) | + * +---------------------------------------------------------------+ + */ +struct nfp_flower_cmsg_tun_neigh_v6 { + uint8_t dst_ipv6[16]; + uint8_t src_ipv6[16]; + 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 * -----\ 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 @@ -629,6 +665,8 @@ struct nfp_fl_act_pre_tun { }; }; +#define NFP_FL_PRE_TUN_IPV6 (1 << 0) + /* * Set tunnel * 3 2 1 @@ -676,5 +714,7 @@ 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); +int nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower, + struct nfp_flower_cmsg_tun_neigh_v6 *payload); #endif /* _NFP_CMSG_H_ */ diff --git a/drivers/net/nfp/nfp_flow.c b/drivers/net/nfp/nfp_flow.c index 6efb95a..b8e666c 100644 --- a/drivers/net/nfp/nfp_flow.c +++ b/drivers/net/nfp/nfp_flow.c @@ -1800,6 +1800,16 @@ struct nfp_mask_id_entry { } __rte_unused static void +nfp_flow_pre_tun_v6_process(struct nfp_fl_act_pre_tun *pre_tun, + const uint8_t ipv6_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->flags = rte_cpu_to_be_16(NFP_FL_PRE_TUN_IPV6); + memcpy(pre_tun->ipv6_dst, ipv6_dst, sizeof(pre_tun->ipv6_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, @@ -1863,7 +1873,7 @@ struct nfp_mask_id_entry { return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload); } -__rte_unused static int +static int nfp_flower_del_tun_neigh_v4(struct nfp_app_fw_flower *app_fw_flower, rte_be32_t ipv4) { @@ -1875,6 +1885,99 @@ struct nfp_mask_id_entry { return nfp_flower_cmsg_tun_neigh_v4_rule(app_fw_flower, &payload); } +__rte_unused static int +nfp_flower_add_tun_neigh_v6_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_ipv6 *ipv6) +{ + struct nfp_fl_tun *tmp; + struct nfp_flow_priv *priv; + struct nfp_flower_in_port *port; + struct nfp_flower_cmsg_tun_neigh_v6 payload; + + tun->payload.v6_flag = 1; + memcpy(tun->payload.dst.dst_ipv6, ipv6->hdr.dst_addr, sizeof(tun->payload.dst.dst_ipv6)); + memcpy(tun->payload.src.src_ipv6, ipv6->hdr.src_addr, sizeof(tun->payload.src.src_ipv6)); + 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_v6)); + memcpy(payload.dst_ipv6, ipv6->hdr.dst_addr, sizeof(payload.dst_ipv6)); + memcpy(payload.src_ipv6, ipv6->hdr.src_addr, sizeof(payload.src_ipv6)); + 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_v6_rule(app_fw_flower, &payload); +} + +static int +nfp_flower_del_tun_neigh_v6(struct nfp_app_fw_flower *app_fw_flower, + uint8_t *ipv6) +{ + struct nfp_flower_cmsg_tun_neigh_v6 payload; + + memset(&payload, 0, sizeof(struct nfp_flower_cmsg_tun_neigh_v6)); + memcpy(payload.dst_ipv6, ipv6, sizeof(payload.dst_ipv6)); + + return nfp_flower_cmsg_tun_neigh_v6_rule(app_fw_flower, &payload); +} + +__rte_unused static int +nfp_flower_del_tun_neigh(struct nfp_app_fw_flower *app_fw_flower, + struct rte_flow *nfp_flow) +{ + int ret; + bool flag = false; + struct nfp_fl_tun *tmp; + struct nfp_fl_tun *tun; + + tun = &nfp_flow->tun; + LIST_FOREACH(tmp, &app_fw_flower->flow_priv->nn_list, next) { + ret = memcmp(&tmp->payload, &tun->payload, sizeof(struct nfp_fl_tun_entry)); + if (ret == 0) { + tmp->ref_cnt--; + flag = true; + break; + } + } + + if (!flag) { + PMD_DRV_LOG(DEBUG, "Can't find nn entry in the nn list"); + return -EINVAL; + } + + if (tmp->ref_cnt == 0) { + LIST_REMOVE(tmp, next); + if (tmp->payload.v6_flag != 0) { + return nfp_flower_del_tun_neigh_v6(app_fw_flower, + tmp->payload.dst.dst_ipv6); + } else { + return nfp_flower_del_tun_neigh_v4(app_fw_flower, + tmp->payload.dst.dst_ipv4); + } + } + + return 0; +} + static int nfp_flow_compile_action(__rte_unused struct nfp_flower_representor *representor, const struct rte_flow_action actions[], -- 1.8.3.1