1 // SPDX-License-Identifier: GPL-2.0
2 /* Marvell RVU Ethernet driver
4 * Copyright (C) 2020 Marvell.
9 #include <linux/sort.h>
11 #include "otx2_common.h"
13 #define OTX2_DEFAULT_ACTION 0x1
15 static int otx2_mcam_entry_init(struct otx2_nic *pfvf);
18 struct ethtool_rx_flow_spec flow_spec;
19 struct list_head list;
24 #define DMAC_FILTER_RULE BIT(0)
25 #define PFC_FLOWCTRL_RULE BIT(1)
35 static void otx2_clear_ntuple_flow_info(struct otx2_nic *pfvf, struct otx2_flow_config *flow_cfg)
37 devm_kfree(pfvf->dev, flow_cfg->flow_ent);
38 flow_cfg->flow_ent = NULL;
39 flow_cfg->max_flows = 0;
42 static int otx2_free_ntuple_mcam_entries(struct otx2_nic *pfvf)
44 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
45 struct npc_mcam_free_entry_req *req;
48 if (!flow_cfg->max_flows)
51 mutex_lock(&pfvf->mbox.lock);
52 for (ent = 0; ent < flow_cfg->max_flows; ent++) {
53 req = otx2_mbox_alloc_msg_npc_mcam_free_entry(&pfvf->mbox);
57 req->entry = flow_cfg->flow_ent[ent];
59 /* Send message to AF to free MCAM entries */
60 err = otx2_sync_mbox_msg(&pfvf->mbox);
64 mutex_unlock(&pfvf->mbox.lock);
65 otx2_clear_ntuple_flow_info(pfvf, flow_cfg);
69 static int mcam_entry_cmp(const void *a, const void *b)
71 return *(u16 *)a - *(u16 *)b;
74 int otx2_alloc_mcam_entries(struct otx2_nic *pfvf, u16 count)
76 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
77 struct npc_mcam_alloc_entry_req *req;
78 struct npc_mcam_alloc_entry_rsp *rsp;
79 int ent, allocated = 0;
81 /* Free current ones and allocate new ones with requested count */
82 otx2_free_ntuple_mcam_entries(pfvf);
87 flow_cfg->flow_ent = devm_kmalloc_array(pfvf->dev, count,
88 sizeof(u16), GFP_KERNEL);
89 if (!flow_cfg->flow_ent) {
90 netdev_err(pfvf->netdev,
91 "%s: Unable to allocate memory for flow entries\n",
96 mutex_lock(&pfvf->mbox.lock);
98 /* In a single request a max of NPC_MAX_NONCONTIG_ENTRIES MCAM entries
99 * can only be allocated.
101 while (allocated < count) {
102 req = otx2_mbox_alloc_msg_npc_mcam_alloc_entry(&pfvf->mbox);
107 req->count = (count - allocated) > NPC_MAX_NONCONTIG_ENTRIES ?
108 NPC_MAX_NONCONTIG_ENTRIES : count - allocated;
110 /* Allocate higher priority entries for PFs, so that VF's entries
111 * will be on top of PF.
113 if (!is_otx2_vf(pfvf->pcifunc)) {
114 req->priority = NPC_MCAM_HIGHER_PRIO;
115 req->ref_entry = flow_cfg->def_ent[0];
118 /* Send message to AF */
119 if (otx2_sync_mbox_msg(&pfvf->mbox))
122 rsp = (struct npc_mcam_alloc_entry_rsp *)otx2_mbox_get_rsp
123 (&pfvf->mbox.mbox, 0, &req->hdr);
125 for (ent = 0; ent < rsp->count; ent++)
126 flow_cfg->flow_ent[ent + allocated] = rsp->entry_list[ent];
128 allocated += rsp->count;
130 /* If this request is not fulfilled, no need to send
133 if (rsp->count != req->count)
137 /* Multiple MCAM entry alloc requests could result in non-sequential
138 * MCAM entries in the flow_ent[] array. Sort them in an ascending order,
139 * otherwise user installed ntuple filter index and MCAM entry index will
143 sort(&flow_cfg->flow_ent[0], allocated,
144 sizeof(flow_cfg->flow_ent[0]), mcam_entry_cmp, NULL);
147 mutex_unlock(&pfvf->mbox.lock);
149 flow_cfg->max_flows = allocated;
152 pfvf->flags |= OTX2_FLAG_MCAM_ENTRIES_ALLOC;
153 pfvf->flags |= OTX2_FLAG_NTUPLE_SUPPORT;
156 if (allocated != count)
157 netdev_info(pfvf->netdev,
158 "Unable to allocate %d MCAM entries, got only %d\n",
162 EXPORT_SYMBOL(otx2_alloc_mcam_entries);
164 static int otx2_mcam_entry_init(struct otx2_nic *pfvf)
166 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
167 struct npc_get_field_status_req *freq;
168 struct npc_get_field_status_rsp *frsp;
169 struct npc_mcam_alloc_entry_req *req;
170 struct npc_mcam_alloc_entry_rsp *rsp;
171 int vf_vlan_max_flows;
174 vf_vlan_max_flows = pfvf->total_vfs * OTX2_PER_VF_VLAN_FLOWS;
175 count = OTX2_MAX_UNICAST_FLOWS +
176 OTX2_MAX_VLAN_FLOWS + vf_vlan_max_flows;
178 flow_cfg->def_ent = devm_kmalloc_array(pfvf->dev, count,
179 sizeof(u16), GFP_KERNEL);
180 if (!flow_cfg->def_ent)
183 mutex_lock(&pfvf->mbox.lock);
185 req = otx2_mbox_alloc_msg_npc_mcam_alloc_entry(&pfvf->mbox);
187 mutex_unlock(&pfvf->mbox.lock);
194 /* Send message to AF */
195 if (otx2_sync_mbox_msg(&pfvf->mbox)) {
196 mutex_unlock(&pfvf->mbox.lock);
200 rsp = (struct npc_mcam_alloc_entry_rsp *)otx2_mbox_get_rsp
201 (&pfvf->mbox.mbox, 0, &req->hdr);
203 if (rsp->count != req->count) {
204 netdev_info(pfvf->netdev,
205 "Unable to allocate MCAM entries for ucast, vlan and vf_vlan\n");
206 mutex_unlock(&pfvf->mbox.lock);
207 devm_kfree(pfvf->dev, flow_cfg->def_ent);
211 for (ent = 0; ent < rsp->count; ent++)
212 flow_cfg->def_ent[ent] = rsp->entry_list[ent];
214 flow_cfg->vf_vlan_offset = 0;
215 flow_cfg->unicast_offset = vf_vlan_max_flows;
216 flow_cfg->rx_vlan_offset = flow_cfg->unicast_offset +
217 OTX2_MAX_UNICAST_FLOWS;
218 pfvf->flags |= OTX2_FLAG_UCAST_FLTR_SUPPORT;
220 /* Check if NPC_DMAC field is supported
221 * by the mkex profile before setting VLAN support flag.
223 freq = otx2_mbox_alloc_msg_npc_get_field_status(&pfvf->mbox);
225 mutex_unlock(&pfvf->mbox.lock);
229 freq->field = NPC_DMAC;
230 if (otx2_sync_mbox_msg(&pfvf->mbox)) {
231 mutex_unlock(&pfvf->mbox.lock);
235 frsp = (struct npc_get_field_status_rsp *)otx2_mbox_get_rsp
236 (&pfvf->mbox.mbox, 0, &freq->hdr);
239 pfvf->flags |= OTX2_FLAG_RX_VLAN_SUPPORT;
240 pfvf->flags |= OTX2_FLAG_VF_VLAN_SUPPORT;
243 pfvf->flags |= OTX2_FLAG_MCAM_ENTRIES_ALLOC;
244 mutex_unlock(&pfvf->mbox.lock);
246 /* Allocate entries for Ntuple filters */
247 count = otx2_alloc_mcam_entries(pfvf, OTX2_DEFAULT_FLOWCOUNT);
249 otx2_clear_ntuple_flow_info(pfvf, flow_cfg);
253 pfvf->flags |= OTX2_FLAG_TC_FLOWER_SUPPORT;
258 /* TODO : revisit on size */
259 #define OTX2_DMAC_FLTR_BITMAP_SZ (4 * 2048 + 32)
261 int otx2vf_mcam_flow_init(struct otx2_nic *pfvf)
263 struct otx2_flow_config *flow_cfg;
265 pfvf->flow_cfg = devm_kzalloc(pfvf->dev,
266 sizeof(struct otx2_flow_config),
271 pfvf->flow_cfg->dmacflt_bmap = devm_kcalloc(pfvf->dev,
272 BITS_TO_LONGS(OTX2_DMAC_FLTR_BITMAP_SZ),
273 sizeof(long), GFP_KERNEL);
274 if (!pfvf->flow_cfg->dmacflt_bmap)
277 flow_cfg = pfvf->flow_cfg;
278 INIT_LIST_HEAD(&flow_cfg->flow_list);
279 flow_cfg->max_flows = 0;
283 EXPORT_SYMBOL(otx2vf_mcam_flow_init);
285 int otx2_mcam_flow_init(struct otx2_nic *pf)
289 pf->flow_cfg = devm_kzalloc(pf->dev, sizeof(struct otx2_flow_config),
294 pf->flow_cfg->dmacflt_bmap = devm_kcalloc(pf->dev,
295 BITS_TO_LONGS(OTX2_DMAC_FLTR_BITMAP_SZ),
296 sizeof(long), GFP_KERNEL);
297 if (!pf->flow_cfg->dmacflt_bmap)
300 INIT_LIST_HEAD(&pf->flow_cfg->flow_list);
302 /* Allocate bare minimum number of MCAM entries needed for
303 * unicast and ntuple filters.
305 err = otx2_mcam_entry_init(pf);
309 /* Check if MCAM entries are allocate or not */
310 if (!(pf->flags & OTX2_FLAG_UCAST_FLTR_SUPPORT))
313 pf->mac_table = devm_kzalloc(pf->dev, sizeof(struct otx2_mac_table)
314 * OTX2_MAX_UNICAST_FLOWS, GFP_KERNEL);
318 otx2_dmacflt_get_max_cnt(pf);
320 /* DMAC filters are not allocated */
321 if (!pf->flow_cfg->dmacflt_max_flows)
324 pf->flow_cfg->bmap_to_dmacindex =
325 devm_kzalloc(pf->dev, sizeof(u32) *
326 pf->flow_cfg->dmacflt_max_flows,
329 if (!pf->flow_cfg->bmap_to_dmacindex)
332 pf->flags |= OTX2_FLAG_DMACFLTR_SUPPORT;
337 void otx2_mcam_flow_del(struct otx2_nic *pf)
339 otx2_destroy_mcam_flows(pf);
341 EXPORT_SYMBOL(otx2_mcam_flow_del);
343 /* On success adds mcam entry
344 * On failure enable promisous mode
346 static int otx2_do_add_macfilter(struct otx2_nic *pf, const u8 *mac)
348 struct otx2_flow_config *flow_cfg = pf->flow_cfg;
349 struct npc_install_flow_req *req;
352 if (!(pf->flags & OTX2_FLAG_UCAST_FLTR_SUPPORT))
355 /* dont have free mcam entries or uc list is greater than alloted */
356 if (netdev_uc_count(pf->netdev) > OTX2_MAX_UNICAST_FLOWS)
359 mutex_lock(&pf->mbox.lock);
360 req = otx2_mbox_alloc_msg_npc_install_flow(&pf->mbox);
362 mutex_unlock(&pf->mbox.lock);
366 /* unicast offset starts with 32 0..31 for ntuple */
367 for (i = 0; i < OTX2_MAX_UNICAST_FLOWS; i++) {
368 if (pf->mac_table[i].inuse)
370 ether_addr_copy(pf->mac_table[i].addr, mac);
371 pf->mac_table[i].inuse = true;
372 pf->mac_table[i].mcam_entry =
373 flow_cfg->def_ent[i + flow_cfg->unicast_offset];
374 req->entry = pf->mac_table[i].mcam_entry;
378 ether_addr_copy(req->packet.dmac, mac);
379 eth_broadcast_addr((u8 *)&req->mask.dmac);
380 req->features = BIT_ULL(NPC_DMAC);
381 req->channel = pf->hw.rx_chan_base;
382 req->intf = NIX_INTF_RX;
383 req->op = NIX_RX_ACTION_DEFAULT;
386 err = otx2_sync_mbox_msg(&pf->mbox);
387 mutex_unlock(&pf->mbox.lock);
392 int otx2_add_macfilter(struct net_device *netdev, const u8 *mac)
394 struct otx2_nic *pf = netdev_priv(netdev);
396 if (!bitmap_empty(pf->flow_cfg->dmacflt_bmap,
397 pf->flow_cfg->dmacflt_max_flows))
399 "Add %pM to CGX/RPM DMAC filters list as well\n",
402 return otx2_do_add_macfilter(pf, mac);
405 static bool otx2_get_mcamentry_for_mac(struct otx2_nic *pf, const u8 *mac,
410 for (i = 0; i < OTX2_MAX_UNICAST_FLOWS; i++) {
411 if (!pf->mac_table[i].inuse)
414 if (ether_addr_equal(pf->mac_table[i].addr, mac)) {
415 *mcam_entry = pf->mac_table[i].mcam_entry;
416 pf->mac_table[i].inuse = false;
423 int otx2_del_macfilter(struct net_device *netdev, const u8 *mac)
425 struct otx2_nic *pf = netdev_priv(netdev);
426 struct npc_delete_flow_req *req;
429 /* check does mcam entry exists for given mac */
430 if (!otx2_get_mcamentry_for_mac(pf, mac, &mcam_entry))
433 mutex_lock(&pf->mbox.lock);
434 req = otx2_mbox_alloc_msg_npc_delete_flow(&pf->mbox);
436 mutex_unlock(&pf->mbox.lock);
439 req->entry = mcam_entry;
440 /* Send message to AF */
441 err = otx2_sync_mbox_msg(&pf->mbox);
442 mutex_unlock(&pf->mbox.lock);
447 static struct otx2_flow *otx2_find_flow(struct otx2_nic *pfvf, u32 location)
449 struct otx2_flow *iter;
451 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) {
452 if (iter->location == location)
459 static void otx2_add_flow_to_list(struct otx2_nic *pfvf, struct otx2_flow *flow)
461 struct list_head *head = &pfvf->flow_cfg->flow_list;
462 struct otx2_flow *iter;
464 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) {
465 if (iter->location > flow->location)
470 list_add(&flow->list, head);
473 int otx2_get_maxflows(struct otx2_flow_config *flow_cfg)
478 if (flow_cfg->nr_flows == flow_cfg->max_flows ||
479 !bitmap_empty(flow_cfg->dmacflt_bmap,
480 flow_cfg->dmacflt_max_flows))
481 return flow_cfg->max_flows + flow_cfg->dmacflt_max_flows;
483 return flow_cfg->max_flows;
485 EXPORT_SYMBOL(otx2_get_maxflows);
487 int otx2_get_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc,
490 struct otx2_flow *iter;
492 if (location >= otx2_get_maxflows(pfvf->flow_cfg))
495 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) {
496 if (iter->location == location) {
497 nfc->fs = iter->flow_spec;
498 nfc->rss_context = iter->rss_ctx_id;
506 int otx2_get_all_flows(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc,
509 u32 rule_cnt = nfc->rule_cnt;
514 nfc->data = otx2_get_maxflows(pfvf->flow_cfg);
515 while ((!err || err == -ENOENT) && idx < rule_cnt) {
516 err = otx2_get_flow(pfvf, nfc, location);
518 rule_locs[idx++] = location;
521 nfc->rule_cnt = rule_cnt;
526 static int otx2_prepare_ipv4_flow(struct ethtool_rx_flow_spec *fsp,
527 struct npc_install_flow_req *req,
530 struct ethtool_usrip4_spec *ipv4_usr_mask = &fsp->m_u.usr_ip4_spec;
531 struct ethtool_usrip4_spec *ipv4_usr_hdr = &fsp->h_u.usr_ip4_spec;
532 struct ethtool_tcpip4_spec *ipv4_l4_mask = &fsp->m_u.tcp_ip4_spec;
533 struct ethtool_tcpip4_spec *ipv4_l4_hdr = &fsp->h_u.tcp_ip4_spec;
534 struct ethtool_ah_espip4_spec *ah_esp_hdr = &fsp->h_u.ah_ip4_spec;
535 struct ethtool_ah_espip4_spec *ah_esp_mask = &fsp->m_u.ah_ip4_spec;
536 struct flow_msg *pmask = &req->mask;
537 struct flow_msg *pkt = &req->packet;
541 if (ipv4_usr_mask->ip4src) {
542 memcpy(&pkt->ip4src, &ipv4_usr_hdr->ip4src,
543 sizeof(pkt->ip4src));
544 memcpy(&pmask->ip4src, &ipv4_usr_mask->ip4src,
545 sizeof(pmask->ip4src));
546 req->features |= BIT_ULL(NPC_SIP_IPV4);
548 if (ipv4_usr_mask->ip4dst) {
549 memcpy(&pkt->ip4dst, &ipv4_usr_hdr->ip4dst,
550 sizeof(pkt->ip4dst));
551 memcpy(&pmask->ip4dst, &ipv4_usr_mask->ip4dst,
552 sizeof(pmask->ip4dst));
553 req->features |= BIT_ULL(NPC_DIP_IPV4);
555 if (ipv4_usr_mask->tos) {
556 pkt->tos = ipv4_usr_hdr->tos;
557 pmask->tos = ipv4_usr_mask->tos;
558 req->features |= BIT_ULL(NPC_TOS);
560 if (ipv4_usr_mask->proto) {
561 switch (ipv4_usr_hdr->proto) {
563 req->features |= BIT_ULL(NPC_IPPROTO_ICMP);
566 req->features |= BIT_ULL(NPC_IPPROTO_TCP);
569 req->features |= BIT_ULL(NPC_IPPROTO_UDP);
572 req->features |= BIT_ULL(NPC_IPPROTO_SCTP);
575 req->features |= BIT_ULL(NPC_IPPROTO_AH);
578 req->features |= BIT_ULL(NPC_IPPROTO_ESP);
584 pkt->etype = cpu_to_be16(ETH_P_IP);
585 pmask->etype = cpu_to_be16(0xFFFF);
586 req->features |= BIT_ULL(NPC_ETYPE);
591 pkt->etype = cpu_to_be16(ETH_P_IP);
592 pmask->etype = cpu_to_be16(0xFFFF);
593 req->features |= BIT_ULL(NPC_ETYPE);
594 if (ipv4_l4_mask->ip4src) {
595 memcpy(&pkt->ip4src, &ipv4_l4_hdr->ip4src,
596 sizeof(pkt->ip4src));
597 memcpy(&pmask->ip4src, &ipv4_l4_mask->ip4src,
598 sizeof(pmask->ip4src));
599 req->features |= BIT_ULL(NPC_SIP_IPV4);
601 if (ipv4_l4_mask->ip4dst) {
602 memcpy(&pkt->ip4dst, &ipv4_l4_hdr->ip4dst,
603 sizeof(pkt->ip4dst));
604 memcpy(&pmask->ip4dst, &ipv4_l4_mask->ip4dst,
605 sizeof(pmask->ip4dst));
606 req->features |= BIT_ULL(NPC_DIP_IPV4);
608 if (ipv4_l4_mask->tos) {
609 pkt->tos = ipv4_l4_hdr->tos;
610 pmask->tos = ipv4_l4_mask->tos;
611 req->features |= BIT_ULL(NPC_TOS);
613 if (ipv4_l4_mask->psrc) {
614 memcpy(&pkt->sport, &ipv4_l4_hdr->psrc,
616 memcpy(&pmask->sport, &ipv4_l4_mask->psrc,
617 sizeof(pmask->sport));
618 if (flow_type == UDP_V4_FLOW)
619 req->features |= BIT_ULL(NPC_SPORT_UDP);
620 else if (flow_type == TCP_V4_FLOW)
621 req->features |= BIT_ULL(NPC_SPORT_TCP);
623 req->features |= BIT_ULL(NPC_SPORT_SCTP);
625 if (ipv4_l4_mask->pdst) {
626 memcpy(&pkt->dport, &ipv4_l4_hdr->pdst,
628 memcpy(&pmask->dport, &ipv4_l4_mask->pdst,
629 sizeof(pmask->dport));
630 if (flow_type == UDP_V4_FLOW)
631 req->features |= BIT_ULL(NPC_DPORT_UDP);
632 else if (flow_type == TCP_V4_FLOW)
633 req->features |= BIT_ULL(NPC_DPORT_TCP);
635 req->features |= BIT_ULL(NPC_DPORT_SCTP);
637 if (flow_type == UDP_V4_FLOW)
638 req->features |= BIT_ULL(NPC_IPPROTO_UDP);
639 else if (flow_type == TCP_V4_FLOW)
640 req->features |= BIT_ULL(NPC_IPPROTO_TCP);
642 req->features |= BIT_ULL(NPC_IPPROTO_SCTP);
646 pkt->etype = cpu_to_be16(ETH_P_IP);
647 pmask->etype = cpu_to_be16(0xFFFF);
648 req->features |= BIT_ULL(NPC_ETYPE);
649 if (ah_esp_mask->ip4src) {
650 memcpy(&pkt->ip4src, &ah_esp_hdr->ip4src,
651 sizeof(pkt->ip4src));
652 memcpy(&pmask->ip4src, &ah_esp_mask->ip4src,
653 sizeof(pmask->ip4src));
654 req->features |= BIT_ULL(NPC_SIP_IPV4);
656 if (ah_esp_mask->ip4dst) {
657 memcpy(&pkt->ip4dst, &ah_esp_hdr->ip4dst,
658 sizeof(pkt->ip4dst));
659 memcpy(&pmask->ip4dst, &ah_esp_mask->ip4dst,
660 sizeof(pmask->ip4dst));
661 req->features |= BIT_ULL(NPC_DIP_IPV4);
663 if (ah_esp_mask->tos) {
664 pkt->tos = ah_esp_hdr->tos;
665 pmask->tos = ah_esp_mask->tos;
666 req->features |= BIT_ULL(NPC_TOS);
669 /* NPC profile doesn't extract AH/ESP header fields */
670 if (ah_esp_mask->spi & ah_esp_hdr->spi)
673 if (flow_type == AH_V4_FLOW)
674 req->features |= BIT_ULL(NPC_IPPROTO_AH);
676 req->features |= BIT_ULL(NPC_IPPROTO_ESP);
685 static int otx2_prepare_ipv6_flow(struct ethtool_rx_flow_spec *fsp,
686 struct npc_install_flow_req *req,
689 struct ethtool_usrip6_spec *ipv6_usr_mask = &fsp->m_u.usr_ip6_spec;
690 struct ethtool_usrip6_spec *ipv6_usr_hdr = &fsp->h_u.usr_ip6_spec;
691 struct ethtool_tcpip6_spec *ipv6_l4_mask = &fsp->m_u.tcp_ip6_spec;
692 struct ethtool_tcpip6_spec *ipv6_l4_hdr = &fsp->h_u.tcp_ip6_spec;
693 struct ethtool_ah_espip6_spec *ah_esp_hdr = &fsp->h_u.ah_ip6_spec;
694 struct ethtool_ah_espip6_spec *ah_esp_mask = &fsp->m_u.ah_ip6_spec;
695 struct flow_msg *pmask = &req->mask;
696 struct flow_msg *pkt = &req->packet;
700 if (!ipv6_addr_any((struct in6_addr *)ipv6_usr_mask->ip6src)) {
701 memcpy(&pkt->ip6src, &ipv6_usr_hdr->ip6src,
702 sizeof(pkt->ip6src));
703 memcpy(&pmask->ip6src, &ipv6_usr_mask->ip6src,
704 sizeof(pmask->ip6src));
705 req->features |= BIT_ULL(NPC_SIP_IPV6);
707 if (!ipv6_addr_any((struct in6_addr *)ipv6_usr_mask->ip6dst)) {
708 memcpy(&pkt->ip6dst, &ipv6_usr_hdr->ip6dst,
709 sizeof(pkt->ip6dst));
710 memcpy(&pmask->ip6dst, &ipv6_usr_mask->ip6dst,
711 sizeof(pmask->ip6dst));
712 req->features |= BIT_ULL(NPC_DIP_IPV6);
714 if (ipv6_usr_hdr->l4_proto == IPPROTO_FRAGMENT) {
715 pkt->next_header = ipv6_usr_hdr->l4_proto;
716 pmask->next_header = ipv6_usr_mask->l4_proto;
717 req->features |= BIT_ULL(NPC_IPFRAG_IPV6);
719 pkt->etype = cpu_to_be16(ETH_P_IPV6);
720 pmask->etype = cpu_to_be16(0xFFFF);
721 req->features |= BIT_ULL(NPC_ETYPE);
726 pkt->etype = cpu_to_be16(ETH_P_IPV6);
727 pmask->etype = cpu_to_be16(0xFFFF);
728 req->features |= BIT_ULL(NPC_ETYPE);
729 if (!ipv6_addr_any((struct in6_addr *)ipv6_l4_mask->ip6src)) {
730 memcpy(&pkt->ip6src, &ipv6_l4_hdr->ip6src,
731 sizeof(pkt->ip6src));
732 memcpy(&pmask->ip6src, &ipv6_l4_mask->ip6src,
733 sizeof(pmask->ip6src));
734 req->features |= BIT_ULL(NPC_SIP_IPV6);
736 if (!ipv6_addr_any((struct in6_addr *)ipv6_l4_mask->ip6dst)) {
737 memcpy(&pkt->ip6dst, &ipv6_l4_hdr->ip6dst,
738 sizeof(pkt->ip6dst));
739 memcpy(&pmask->ip6dst, &ipv6_l4_mask->ip6dst,
740 sizeof(pmask->ip6dst));
741 req->features |= BIT_ULL(NPC_DIP_IPV6);
743 if (ipv6_l4_mask->psrc) {
744 memcpy(&pkt->sport, &ipv6_l4_hdr->psrc,
746 memcpy(&pmask->sport, &ipv6_l4_mask->psrc,
747 sizeof(pmask->sport));
748 if (flow_type == UDP_V6_FLOW)
749 req->features |= BIT_ULL(NPC_SPORT_UDP);
750 else if (flow_type == TCP_V6_FLOW)
751 req->features |= BIT_ULL(NPC_SPORT_TCP);
753 req->features |= BIT_ULL(NPC_SPORT_SCTP);
755 if (ipv6_l4_mask->pdst) {
756 memcpy(&pkt->dport, &ipv6_l4_hdr->pdst,
758 memcpy(&pmask->dport, &ipv6_l4_mask->pdst,
759 sizeof(pmask->dport));
760 if (flow_type == UDP_V6_FLOW)
761 req->features |= BIT_ULL(NPC_DPORT_UDP);
762 else if (flow_type == TCP_V6_FLOW)
763 req->features |= BIT_ULL(NPC_DPORT_TCP);
765 req->features |= BIT_ULL(NPC_DPORT_SCTP);
767 if (flow_type == UDP_V6_FLOW)
768 req->features |= BIT_ULL(NPC_IPPROTO_UDP);
769 else if (flow_type == TCP_V6_FLOW)
770 req->features |= BIT_ULL(NPC_IPPROTO_TCP);
772 req->features |= BIT_ULL(NPC_IPPROTO_SCTP);
776 pkt->etype = cpu_to_be16(ETH_P_IPV6);
777 pmask->etype = cpu_to_be16(0xFFFF);
778 req->features |= BIT_ULL(NPC_ETYPE);
779 if (!ipv6_addr_any((struct in6_addr *)ah_esp_hdr->ip6src)) {
780 memcpy(&pkt->ip6src, &ah_esp_hdr->ip6src,
781 sizeof(pkt->ip6src));
782 memcpy(&pmask->ip6src, &ah_esp_mask->ip6src,
783 sizeof(pmask->ip6src));
784 req->features |= BIT_ULL(NPC_SIP_IPV6);
786 if (!ipv6_addr_any((struct in6_addr *)ah_esp_hdr->ip6dst)) {
787 memcpy(&pkt->ip6dst, &ah_esp_hdr->ip6dst,
788 sizeof(pkt->ip6dst));
789 memcpy(&pmask->ip6dst, &ah_esp_mask->ip6dst,
790 sizeof(pmask->ip6dst));
791 req->features |= BIT_ULL(NPC_DIP_IPV6);
794 /* NPC profile doesn't extract AH/ESP header fields */
795 if ((ah_esp_mask->spi & ah_esp_hdr->spi) ||
796 (ah_esp_mask->tclass & ah_esp_hdr->tclass))
799 if (flow_type == AH_V6_FLOW)
800 req->features |= BIT_ULL(NPC_IPPROTO_AH);
802 req->features |= BIT_ULL(NPC_IPPROTO_ESP);
811 static int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp,
812 struct npc_install_flow_req *req)
814 struct ethhdr *eth_mask = &fsp->m_u.ether_spec;
815 struct ethhdr *eth_hdr = &fsp->h_u.ether_spec;
816 struct flow_msg *pmask = &req->mask;
817 struct flow_msg *pkt = &req->packet;
821 flow_type = fsp->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS);
823 /* bits not set in mask are don't care */
825 if (!is_zero_ether_addr(eth_mask->h_source)) {
826 ether_addr_copy(pkt->smac, eth_hdr->h_source);
827 ether_addr_copy(pmask->smac, eth_mask->h_source);
828 req->features |= BIT_ULL(NPC_SMAC);
830 if (!is_zero_ether_addr(eth_mask->h_dest)) {
831 ether_addr_copy(pkt->dmac, eth_hdr->h_dest);
832 ether_addr_copy(pmask->dmac, eth_mask->h_dest);
833 req->features |= BIT_ULL(NPC_DMAC);
835 if (eth_hdr->h_proto) {
836 memcpy(&pkt->etype, ð_hdr->h_proto,
838 memcpy(&pmask->etype, ð_mask->h_proto,
839 sizeof(pmask->etype));
840 req->features |= BIT_ULL(NPC_ETYPE);
849 ret = otx2_prepare_ipv4_flow(fsp, req, flow_type);
859 ret = otx2_prepare_ipv6_flow(fsp, req, flow_type);
866 if (fsp->flow_type & FLOW_EXT) {
869 if (fsp->m_ext.vlan_etype) {
870 /* Partial masks not supported */
871 if (be16_to_cpu(fsp->m_ext.vlan_etype) != 0xFFFF)
874 vlan_etype = be16_to_cpu(fsp->h_ext.vlan_etype);
875 /* Only ETH_P_8021Q and ETH_P_802AD types supported */
876 if (vlan_etype != ETH_P_8021Q &&
877 vlan_etype != ETH_P_8021AD)
880 memcpy(&pkt->vlan_etype, &fsp->h_ext.vlan_etype,
881 sizeof(pkt->vlan_etype));
882 memcpy(&pmask->vlan_etype, &fsp->m_ext.vlan_etype,
883 sizeof(pmask->vlan_etype));
885 if (vlan_etype == ETH_P_8021Q)
886 req->features |= BIT_ULL(NPC_VLAN_ETYPE_CTAG);
888 req->features |= BIT_ULL(NPC_VLAN_ETYPE_STAG);
891 if (fsp->m_ext.vlan_tci) {
892 memcpy(&pkt->vlan_tci, &fsp->h_ext.vlan_tci,
893 sizeof(pkt->vlan_tci));
894 memcpy(&pmask->vlan_tci, &fsp->m_ext.vlan_tci,
895 sizeof(pmask->vlan_tci));
896 req->features |= BIT_ULL(NPC_OUTER_VID);
899 if (fsp->m_ext.data[1]) {
900 if (flow_type == IP_USER_FLOW) {
901 if (be32_to_cpu(fsp->h_ext.data[1]) != IPV4_FLAG_MORE)
904 pkt->ip_flag = be32_to_cpu(fsp->h_ext.data[1]);
905 pmask->ip_flag = be32_to_cpu(fsp->m_ext.data[1]);
906 req->features |= BIT_ULL(NPC_IPFRAG_IPV4);
907 } else if (fsp->h_ext.data[1] ==
908 cpu_to_be32(OTX2_DEFAULT_ACTION)) {
909 /* Not Drop/Direct to queue but use action
912 req->op = NIX_RX_ACTION_DEFAULT;
917 if (fsp->flow_type & FLOW_MAC_EXT &&
918 !is_zero_ether_addr(fsp->m_ext.h_dest)) {
919 ether_addr_copy(pkt->dmac, fsp->h_ext.h_dest);
920 ether_addr_copy(pmask->dmac, fsp->m_ext.h_dest);
921 req->features |= BIT_ULL(NPC_DMAC);
930 static int otx2_is_flow_rule_dmacfilter(struct otx2_nic *pfvf,
931 struct ethtool_rx_flow_spec *fsp)
933 struct ethhdr *eth_mask = &fsp->m_u.ether_spec;
934 struct ethhdr *eth_hdr = &fsp->h_u.ether_spec;
935 u64 ring_cookie = fsp->ring_cookie;
938 if (!(pfvf->flags & OTX2_FLAG_DMACFLTR_SUPPORT))
941 flow_type = fsp->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS);
943 /* CGX/RPM block dmac filtering configured for white listing
944 * check for action other than DROP
946 if (flow_type == ETHER_FLOW && ring_cookie != RX_CLS_FLOW_DISC &&
947 !ethtool_get_flow_spec_ring_vf(ring_cookie)) {
948 if (is_zero_ether_addr(eth_mask->h_dest) &&
949 is_valid_ether_addr(eth_hdr->h_dest))
956 static int otx2_add_flow_msg(struct otx2_nic *pfvf, struct otx2_flow *flow)
958 u64 ring_cookie = flow->flow_spec.ring_cookie;
960 int vlan_prio, qidx, pfc_rule = 0;
962 struct npc_install_flow_req *req;
965 mutex_lock(&pfvf->mbox.lock);
966 req = otx2_mbox_alloc_msg_npc_install_flow(&pfvf->mbox);
968 mutex_unlock(&pfvf->mbox.lock);
972 err = otx2_prepare_flow_request(&flow->flow_spec, req);
974 /* free the allocated msg above */
975 otx2_mbox_reset(&pfvf->mbox.mbox, 0);
976 mutex_unlock(&pfvf->mbox.lock);
980 req->entry = flow->entry;
981 req->intf = NIX_INTF_RX;
983 req->channel = pfvf->hw.rx_chan_base;
984 if (ring_cookie == RX_CLS_FLOW_DISC) {
985 req->op = NIX_RX_ACTIONOP_DROP;
987 /* change to unicast only if action of default entry is not
990 if (flow->flow_spec.flow_type & FLOW_RSS) {
991 req->op = NIX_RX_ACTIONOP_RSS;
992 req->index = flow->rss_ctx_id;
993 req->flow_key_alg = pfvf->hw.flowkey_alg_idx;
995 req->op = NIX_RX_ACTIONOP_UCAST;
996 req->index = ethtool_get_flow_spec_ring(ring_cookie);
998 vf = ethtool_get_flow_spec_ring_vf(ring_cookie);
999 if (vf > pci_num_vf(pfvf->pdev)) {
1000 mutex_unlock(&pfvf->mbox.lock);
1005 /* Identify PFC rule if PFC enabled and ntuple rule is vlan */
1006 if (!vf && (req->features & BIT_ULL(NPC_OUTER_VID)) &&
1007 pfvf->pfc_en && req->op != NIX_RX_ACTIONOP_RSS) {
1008 vlan_prio = ntohs(req->packet.vlan_tci) &
1009 ntohs(req->mask.vlan_tci);
1011 /* Get the priority */
1013 flow->rule_type |= PFC_FLOWCTRL_RULE;
1014 /* Check if PFC enabled for this priority */
1015 if (pfvf->pfc_en & BIT(vlan_prio)) {
1023 /* ethtool ring_cookie has (VF + 1) for VF */
1030 /* Send message to AF */
1031 err = otx2_sync_mbox_msg(&pfvf->mbox);
1034 if (!err && pfc_rule)
1035 otx2_update_bpid_in_rqctx(pfvf, vlan_prio, qidx, true);
1038 mutex_unlock(&pfvf->mbox.lock);
1042 static int otx2_add_flow_with_pfmac(struct otx2_nic *pfvf,
1043 struct otx2_flow *flow)
1045 struct otx2_flow *pf_mac;
1046 struct ethhdr *eth_hdr;
1048 pf_mac = kzalloc(sizeof(*pf_mac), GFP_KERNEL);
1053 pf_mac->rule_type |= DMAC_FILTER_RULE;
1054 pf_mac->location = pfvf->flow_cfg->max_flows;
1055 memcpy(&pf_mac->flow_spec, &flow->flow_spec,
1056 sizeof(struct ethtool_rx_flow_spec));
1057 pf_mac->flow_spec.location = pf_mac->location;
1059 /* Copy PF mac address */
1060 eth_hdr = &pf_mac->flow_spec.h_u.ether_spec;
1061 ether_addr_copy(eth_hdr->h_dest, pfvf->netdev->dev_addr);
1063 /* Install DMAC filter with PF mac address */
1064 otx2_dmacflt_add(pfvf, eth_hdr->h_dest, 0);
1066 otx2_add_flow_to_list(pfvf, pf_mac);
1067 pfvf->flow_cfg->nr_flows++;
1068 set_bit(0, pfvf->flow_cfg->dmacflt_bmap);
1073 int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
1075 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
1076 struct ethtool_rx_flow_spec *fsp = &nfc->fs;
1077 struct otx2_flow *flow;
1078 struct ethhdr *eth_hdr;
1083 if (!flow_cfg->max_flows) {
1084 netdev_err(pfvf->netdev,
1085 "Ntuple rule count is 0, allocate and retry\n");
1089 ring = ethtool_get_flow_spec_ring(fsp->ring_cookie);
1090 if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
1093 if (ring >= pfvf->hw.rx_queues && fsp->ring_cookie != RX_CLS_FLOW_DISC)
1096 if (fsp->location >= otx2_get_maxflows(flow_cfg))
1099 flow = otx2_find_flow(pfvf, fsp->location);
1101 flow = kzalloc(sizeof(*flow), GFP_KERNEL);
1104 flow->location = fsp->location;
1105 flow->entry = flow_cfg->flow_ent[flow->location];
1109 flow->flow_spec = *fsp;
1111 if (fsp->flow_type & FLOW_RSS)
1112 flow->rss_ctx_id = nfc->rss_context;
1114 if (otx2_is_flow_rule_dmacfilter(pfvf, &flow->flow_spec)) {
1115 eth_hdr = &flow->flow_spec.h_u.ether_spec;
1117 /* Sync dmac filter table with updated fields */
1118 if (flow->rule_type & DMAC_FILTER_RULE)
1119 return otx2_dmacflt_update(pfvf, eth_hdr->h_dest,
1122 if (bitmap_full(flow_cfg->dmacflt_bmap,
1123 flow_cfg->dmacflt_max_flows)) {
1124 netdev_warn(pfvf->netdev,
1125 "Can't insert the rule %d as max allowed dmac filters are %d\n",
1127 flow_cfg->dmacflt_max_flows,
1128 flow_cfg->dmacflt_max_flows);
1135 /* Install PF mac address to DMAC filter list */
1136 if (!test_bit(0, flow_cfg->dmacflt_bmap))
1137 otx2_add_flow_with_pfmac(pfvf, flow);
1139 flow->rule_type |= DMAC_FILTER_RULE;
1140 flow->entry = find_first_zero_bit(flow_cfg->dmacflt_bmap,
1141 flow_cfg->dmacflt_max_flows);
1142 fsp->location = flow_cfg->max_flows + flow->entry;
1143 flow->flow_spec.location = fsp->location;
1144 flow->location = fsp->location;
1146 set_bit(flow->entry, flow_cfg->dmacflt_bmap);
1147 otx2_dmacflt_add(pfvf, eth_hdr->h_dest, flow->entry);
1150 if (flow->location >= pfvf->flow_cfg->max_flows) {
1151 netdev_warn(pfvf->netdev,
1152 "Can't insert non dmac ntuple rule at %d, allowed range %d-0\n",
1154 flow_cfg->max_flows - 1);
1157 err = otx2_add_flow_msg(pfvf, flow);
1162 if (err == MBOX_MSG_INVALID)
1169 /* add the new flow installed to list */
1171 otx2_add_flow_to_list(pfvf, flow);
1172 flow_cfg->nr_flows++;
1178 static int otx2_remove_flow_msg(struct otx2_nic *pfvf, u16 entry, bool all)
1180 struct npc_delete_flow_req *req;
1183 mutex_lock(&pfvf->mbox.lock);
1184 req = otx2_mbox_alloc_msg_npc_delete_flow(&pfvf->mbox);
1186 mutex_unlock(&pfvf->mbox.lock);
1194 /* Send message to AF */
1195 err = otx2_sync_mbox_msg(&pfvf->mbox);
1196 mutex_unlock(&pfvf->mbox.lock);
1200 static void otx2_update_rem_pfmac(struct otx2_nic *pfvf, int req)
1202 struct otx2_flow *iter;
1203 struct ethhdr *eth_hdr;
1206 list_for_each_entry(iter, &pfvf->flow_cfg->flow_list, list) {
1207 if ((iter->rule_type & DMAC_FILTER_RULE) && iter->entry == 0) {
1208 eth_hdr = &iter->flow_spec.h_u.ether_spec;
1209 if (req == DMAC_ADDR_DEL) {
1210 otx2_dmacflt_remove(pfvf, eth_hdr->h_dest,
1212 clear_bit(0, pfvf->flow_cfg->dmacflt_bmap);
1215 ether_addr_copy(eth_hdr->h_dest,
1216 pfvf->netdev->dev_addr);
1218 otx2_dmacflt_update(pfvf, eth_hdr->h_dest, 0);
1225 list_del(&iter->list);
1227 pfvf->flow_cfg->nr_flows--;
1231 int otx2_remove_flow(struct otx2_nic *pfvf, u32 location)
1233 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
1234 struct otx2_flow *flow;
1237 if (location >= otx2_get_maxflows(flow_cfg))
1240 flow = otx2_find_flow(pfvf, location);
1244 if (flow->rule_type & DMAC_FILTER_RULE) {
1245 struct ethhdr *eth_hdr = &flow->flow_spec.h_u.ether_spec;
1247 /* user not allowed to remove dmac filter with interface mac */
1248 if (ether_addr_equal(pfvf->netdev->dev_addr, eth_hdr->h_dest))
1251 err = otx2_dmacflt_remove(pfvf, eth_hdr->h_dest,
1253 clear_bit(flow->entry, flow_cfg->dmacflt_bmap);
1254 /* If all dmac filters are removed delete macfilter with
1255 * interface mac address and configure CGX/RPM block in
1258 if (bitmap_weight(flow_cfg->dmacflt_bmap,
1259 flow_cfg->dmacflt_max_flows) == 1)
1260 otx2_update_rem_pfmac(pfvf, DMAC_ADDR_DEL);
1263 if (flow->rule_type & PFC_FLOWCTRL_RULE)
1264 otx2_update_bpid_in_rqctx(pfvf, 0,
1265 flow->flow_spec.ring_cookie,
1269 err = otx2_remove_flow_msg(pfvf, flow->entry, false);
1275 list_del(&flow->list);
1277 flow_cfg->nr_flows--;
1282 void otx2_rss_ctx_flow_del(struct otx2_nic *pfvf, int ctx_id)
1284 struct otx2_flow *flow, *tmp;
1287 list_for_each_entry_safe(flow, tmp, &pfvf->flow_cfg->flow_list, list) {
1288 if (flow->rss_ctx_id != ctx_id)
1290 err = otx2_remove_flow(pfvf, flow->location);
1292 netdev_warn(pfvf->netdev,
1293 "Can't delete the rule %d associated with this rss group err:%d",
1294 flow->location, err);
1298 int otx2_destroy_ntuple_flows(struct otx2_nic *pfvf)
1300 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
1301 struct npc_delete_flow_req *req;
1302 struct otx2_flow *iter, *tmp;
1305 if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
1308 if (!flow_cfg->max_flows)
1311 mutex_lock(&pfvf->mbox.lock);
1312 req = otx2_mbox_alloc_msg_npc_delete_flow(&pfvf->mbox);
1314 mutex_unlock(&pfvf->mbox.lock);
1318 req->start = flow_cfg->flow_ent[0];
1319 req->end = flow_cfg->flow_ent[flow_cfg->max_flows - 1];
1320 err = otx2_sync_mbox_msg(&pfvf->mbox);
1321 mutex_unlock(&pfvf->mbox.lock);
1323 list_for_each_entry_safe(iter, tmp, &flow_cfg->flow_list, list) {
1324 list_del(&iter->list);
1326 flow_cfg->nr_flows--;
1331 int otx2_destroy_mcam_flows(struct otx2_nic *pfvf)
1333 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
1334 struct npc_mcam_free_entry_req *req;
1335 struct otx2_flow *iter, *tmp;
1338 if (!(pfvf->flags & OTX2_FLAG_MCAM_ENTRIES_ALLOC))
1341 /* remove all flows */
1342 err = otx2_remove_flow_msg(pfvf, 0, true);
1346 list_for_each_entry_safe(iter, tmp, &flow_cfg->flow_list, list) {
1347 list_del(&iter->list);
1349 flow_cfg->nr_flows--;
1352 mutex_lock(&pfvf->mbox.lock);
1353 req = otx2_mbox_alloc_msg_npc_mcam_free_entry(&pfvf->mbox);
1355 mutex_unlock(&pfvf->mbox.lock);
1360 /* Send message to AF to free MCAM entries */
1361 err = otx2_sync_mbox_msg(&pfvf->mbox);
1363 mutex_unlock(&pfvf->mbox.lock);
1367 pfvf->flags &= ~OTX2_FLAG_MCAM_ENTRIES_ALLOC;
1368 mutex_unlock(&pfvf->mbox.lock);
1373 int otx2_install_rxvlan_offload_flow(struct otx2_nic *pfvf)
1375 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
1376 struct npc_install_flow_req *req;
1379 mutex_lock(&pfvf->mbox.lock);
1380 req = otx2_mbox_alloc_msg_npc_install_flow(&pfvf->mbox);
1382 mutex_unlock(&pfvf->mbox.lock);
1386 req->entry = flow_cfg->def_ent[flow_cfg->rx_vlan_offset];
1387 req->intf = NIX_INTF_RX;
1388 ether_addr_copy(req->packet.dmac, pfvf->netdev->dev_addr);
1389 eth_broadcast_addr((u8 *)&req->mask.dmac);
1390 req->channel = pfvf->hw.rx_chan_base;
1391 req->op = NIX_RX_ACTION_DEFAULT;
1392 req->features = BIT_ULL(NPC_OUTER_VID) | BIT_ULL(NPC_DMAC);
1393 req->vtag0_valid = true;
1394 req->vtag0_type = NIX_AF_LFX_RX_VTAG_TYPE0;
1396 /* Send message to AF */
1397 err = otx2_sync_mbox_msg(&pfvf->mbox);
1398 mutex_unlock(&pfvf->mbox.lock);
1402 static int otx2_delete_rxvlan_offload_flow(struct otx2_nic *pfvf)
1404 struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
1405 struct npc_delete_flow_req *req;
1408 mutex_lock(&pfvf->mbox.lock);
1409 req = otx2_mbox_alloc_msg_npc_delete_flow(&pfvf->mbox);
1411 mutex_unlock(&pfvf->mbox.lock);
1415 req->entry = flow_cfg->def_ent[flow_cfg->rx_vlan_offset];
1416 /* Send message to AF */
1417 err = otx2_sync_mbox_msg(&pfvf->mbox);
1418 mutex_unlock(&pfvf->mbox.lock);
1422 int otx2_enable_rxvlan(struct otx2_nic *pf, bool enable)
1424 struct nix_vtag_config *req;
1425 struct mbox_msghdr *rsp_hdr;
1428 /* Dont have enough mcam entries */
1429 if (!(pf->flags & OTX2_FLAG_RX_VLAN_SUPPORT))
1433 err = otx2_install_rxvlan_offload_flow(pf);
1437 err = otx2_delete_rxvlan_offload_flow(pf);
1442 mutex_lock(&pf->mbox.lock);
1443 req = otx2_mbox_alloc_msg_nix_vtag_cfg(&pf->mbox);
1445 mutex_unlock(&pf->mbox.lock);
1449 /* config strip, capture and size */
1450 req->vtag_size = VTAGSIZE_T4;
1451 req->cfg_type = 1; /* rx vlan cfg */
1452 req->rx.vtag_type = NIX_AF_LFX_RX_VTAG_TYPE0;
1453 req->rx.strip_vtag = enable;
1454 req->rx.capture_vtag = enable;
1456 err = otx2_sync_mbox_msg(&pf->mbox);
1458 mutex_unlock(&pf->mbox.lock);
1462 rsp_hdr = otx2_mbox_get_rsp(&pf->mbox.mbox, 0, &req->hdr);
1463 if (IS_ERR(rsp_hdr)) {
1464 mutex_unlock(&pf->mbox.lock);
1465 return PTR_ERR(rsp_hdr);
1468 mutex_unlock(&pf->mbox.lock);
1472 void otx2_dmacflt_reinstall_flows(struct otx2_nic *pf)
1474 struct otx2_flow *iter;
1475 struct ethhdr *eth_hdr;
1477 list_for_each_entry(iter, &pf->flow_cfg->flow_list, list) {
1478 if (iter->rule_type & DMAC_FILTER_RULE) {
1479 eth_hdr = &iter->flow_spec.h_u.ether_spec;
1480 otx2_dmacflt_add(pf, eth_hdr->h_dest,
1486 void otx2_dmacflt_update_pfmac_flow(struct otx2_nic *pfvf)
1488 otx2_update_rem_pfmac(pfvf, DMAC_ADDR_UPDATE);