LCOV - code coverage report
Current view: top level - drivers/net/nfp/flower - nfp_flower_cmsg.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 231 0.0 %
Date: 2024-01-22 16:26:08 Functions: 0 16 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 94 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2022 Corigine, Inc.
       3                 :            :  * All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "nfp_flower_cmsg.h"
       7                 :            : 
       8                 :            : #include "../nfpcore/nfp_nsp.h"
       9                 :            : #include "../nfp_logs.h"
      10                 :            : #include "nfp_flower_ctrl.h"
      11                 :            : #include "nfp_flower_representor.h"
      12                 :            : 
      13                 :            : static char*
      14                 :            : nfp_flower_cmsg_get_data(struct rte_mbuf *m)
      15                 :            : {
      16                 :          0 :         return rte_pktmbuf_mtod_offset(m, char *, NFP_NET_META_HEADER_SIZE +
      17                 :            :                         NFP_NET_META_FIELD_SIZE + NFP_FLOWER_CMSG_HLEN);
      18                 :            : }
      19                 :            : 
      20                 :            : static void *
      21                 :          0 : nfp_flower_cmsg_init(struct nfp_app_fw_flower *app_fw_flower,
      22                 :            :                 struct rte_mbuf *m,
      23                 :            :                 enum nfp_flower_cmsg_type type,
      24                 :            :                 uint32_t size)
      25                 :            : {
      26                 :            :         char *pkt;
      27                 :            :         uint32_t new_size = size;
      28                 :            :         struct nfp_flower_cmsg_hdr *hdr;
      29                 :            : 
      30                 :          0 :         pkt = rte_pktmbuf_mtod(m, char *);
      31                 :          0 :         PMD_DRV_LOG(DEBUG, "flower_cmsg_init using pkt at %p", pkt);
      32                 :            : 
      33                 :          0 :         new_size += nfp_flower_pkt_add_metadata(app_fw_flower, m, NFP_META_PORT_ID_CTRL);
      34                 :            : 
      35                 :            :         /* Now the ctrl header */
      36                 :            :         hdr = (struct nfp_flower_cmsg_hdr *)pkt;
      37                 :          0 :         hdr->pad     = 0;
      38                 :          0 :         hdr->type    = type;
      39                 :          0 :         hdr->version = NFP_FLOWER_CMSG_VER1;
      40                 :            : 
      41                 :          0 :         pkt = (char *)hdr + NFP_FLOWER_CMSG_HLEN;
      42                 :          0 :         new_size += NFP_FLOWER_CMSG_HLEN;
      43                 :            : 
      44                 :          0 :         m->pkt_len = new_size;
      45                 :          0 :         m->data_len = m->pkt_len;
      46                 :            : 
      47                 :          0 :         return pkt;
      48                 :            : }
      49                 :            : 
      50                 :            : static void
      51                 :          0 : nfp_flower_cmsg_mac_repr_init(struct rte_mbuf *mbuf,
      52                 :            :                 struct nfp_app_fw_flower *app_fw_flower)
      53                 :            : {
      54                 :            :         uint32_t size;
      55                 :            :         uint8_t num_ports;
      56                 :            :         struct nfp_flower_cmsg_mac_repr *msg;
      57                 :            :         enum nfp_flower_cmsg_type type = NFP_FLOWER_CMSG_TYPE_MAC_REPR;
      58                 :            : 
      59                 :          0 :         num_ports = app_fw_flower->num_phyport_reprs;
      60                 :          0 :         size = sizeof(*msg) + (num_ports * sizeof(msg->ports[0]));
      61                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf, type, size);
      62                 :          0 :         memset(msg->reserved, 0, sizeof(msg->reserved));
      63                 :          0 :         msg->num_ports = num_ports;
      64                 :          0 : }
      65                 :            : 
      66                 :            : static void
      67                 :            : nfp_flower_cmsg_mac_repr_fill(struct rte_mbuf *m,
      68                 :            :                 uint8_t idx,
      69                 :            :                 uint32_t nbi,
      70                 :            :                 uint32_t nbi_port,
      71                 :            :                 uint32_t phys_port)
      72                 :            : {
      73                 :            :         struct nfp_flower_cmsg_mac_repr *msg;
      74                 :            : 
      75                 :            :         msg = (struct nfp_flower_cmsg_mac_repr *)nfp_flower_cmsg_get_data(m);
      76                 :          0 :         msg->ports[idx].idx       = idx;
      77                 :          0 :         msg->ports[idx].info      = nbi & NFP_FLOWER_CMSG_MAC_REPR_NBI;
      78                 :          0 :         msg->ports[idx].nbi_port  = nbi_port;
      79                 :          0 :         msg->ports[idx].phys_port = phys_port;
      80                 :            : }
      81                 :            : 
      82                 :            : int
      83                 :          0 : nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower)
      84                 :            : {
      85                 :            :         uint8_t i;
      86                 :            :         uint16_t cnt;
      87                 :            :         uint32_t nbi;
      88                 :            :         uint32_t nbi_port;
      89                 :            :         uint32_t phys_port;
      90                 :            :         struct rte_mbuf *mbuf;
      91                 :            :         struct nfp_eth_table *nfp_eth_table;
      92                 :            : 
      93                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
      94         [ #  # ]:          0 :         if (mbuf == NULL) {
      95                 :          0 :                 PMD_DRV_LOG(ERR, "Could not allocate mac repr cmsg");
      96                 :          0 :                 return -ENOMEM;
      97                 :            :         }
      98                 :            : 
      99                 :          0 :         nfp_flower_cmsg_mac_repr_init(mbuf, app_fw_flower);
     100                 :            : 
     101                 :            :         /* Fill in the mac repr cmsg */
     102                 :          0 :         nfp_eth_table = app_fw_flower->pf_hw->pf_dev->nfp_eth_table;
     103         [ #  # ]:          0 :         for (i = 0; i < app_fw_flower->num_phyport_reprs; i++) {
     104                 :          0 :                 nbi = nfp_eth_table->ports[i].nbi;
     105                 :          0 :                 nbi_port = nfp_eth_table->ports[i].base;
     106                 :          0 :                 phys_port = nfp_eth_table->ports[i].index;
     107                 :            : 
     108                 :            :                 nfp_flower_cmsg_mac_repr_fill(mbuf, i, nbi, nbi_port, phys_port);
     109                 :            :         }
     110                 :            : 
     111                 :            :         /* Send the cmsg via the ctrl vNIC */
     112                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     113         [ #  # ]:          0 :         if (cnt == 0) {
     114                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     115                 :          0 :                 rte_pktmbuf_free(mbuf);
     116                 :          0 :                 return -EIO;
     117                 :            :         }
     118                 :            : 
     119                 :            :         return 0;
     120                 :            : }
     121                 :            : 
     122                 :            : int
     123                 :          0 : nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
     124                 :            :                 struct nfp_flower_representor *repr)
     125                 :            : {
     126                 :            :         uint16_t cnt;
     127                 :            :         struct rte_mbuf *mbuf;
     128                 :            :         struct nfp_flower_cmsg_port_reify *msg;
     129                 :            : 
     130                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     131         [ #  # ]:          0 :         if (mbuf == NULL) {
     132                 :          0 :                 PMD_DRV_LOG(DEBUG, "alloc mbuf for repr reify failed");
     133                 :          0 :                 return -ENOMEM;
     134                 :            :         }
     135                 :            : 
     136                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     137                 :            :                         NFP_FLOWER_CMSG_TYPE_PORT_REIFY, sizeof(*msg));
     138         [ #  # ]:          0 :         msg->portnum  = rte_cpu_to_be_32(repr->port_id);
     139                 :          0 :         msg->reserved = 0;
     140                 :          0 :         msg->info     = rte_cpu_to_be_16(1);
     141                 :            : 
     142                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     143         [ #  # ]:          0 :         if (cnt == 0) {
     144                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     145                 :          0 :                 rte_pktmbuf_free(mbuf);
     146                 :          0 :                 return -EIO;
     147                 :            :         }
     148                 :            : 
     149                 :            :         return 0;
     150                 :            : }
     151                 :            : 
     152                 :            : int
     153                 :          0 : nfp_flower_cmsg_port_mod(struct nfp_app_fw_flower *app_fw_flower,
     154                 :            :                 uint32_t port_id, bool carrier_ok)
     155                 :            : {
     156                 :            :         uint16_t cnt;
     157                 :            :         struct rte_mbuf *mbuf;
     158                 :            :         struct nfp_flower_cmsg_port_mod *msg;
     159                 :            : 
     160                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     161         [ #  # ]:          0 :         if (mbuf == NULL) {
     162                 :          0 :                 PMD_DRV_LOG(DEBUG, "alloc mbuf for repr portmod failed");
     163                 :          0 :                 return -ENOMEM;
     164                 :            :         }
     165                 :            : 
     166                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     167                 :            :                         NFP_FLOWER_CMSG_TYPE_PORT_MOD, sizeof(*msg));
     168         [ #  # ]:          0 :         msg->portnum  = rte_cpu_to_be_32(port_id);
     169                 :          0 :         msg->reserved = 0;
     170                 :          0 :         msg->info     = carrier_ok;
     171                 :          0 :         msg->mtu      = 9000;
     172                 :            : 
     173                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     174         [ #  # ]:          0 :         if (cnt == 0) {
     175                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     176                 :          0 :                 rte_pktmbuf_free(mbuf);
     177                 :          0 :                 return -EIO;
     178                 :            :         }
     179                 :            : 
     180                 :            :         return 0;
     181                 :            : }
     182                 :            : 
     183                 :            : int
     184                 :          0 : nfp_flower_cmsg_flow_delete(struct nfp_app_fw_flower *app_fw_flower,
     185                 :            :                 struct rte_flow *flow)
     186                 :            : {
     187                 :            :         char *msg;
     188                 :            :         uint16_t cnt;
     189                 :            :         uint32_t msg_len;
     190                 :            :         struct rte_mbuf *mbuf;
     191                 :            :         struct nfp_fl_rule_metadata *nfp_flow_meta;
     192                 :            : 
     193                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     194         [ #  # ]:          0 :         if (mbuf == NULL) {
     195                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for flow delete.");
     196                 :          0 :                 return -ENOMEM;
     197                 :            :         }
     198                 :            : 
     199                 :            :         /* Copy the flow to mbuf */
     200                 :          0 :         nfp_flow_meta = flow->payload.meta;
     201                 :          0 :         msg_len = (nfp_flow_meta->key_len + nfp_flow_meta->mask_len +
     202                 :          0 :                         nfp_flow_meta->act_len) << NFP_FL_LW_SIZ;
     203                 :          0 :         msg_len += sizeof(struct nfp_fl_rule_metadata);
     204                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     205                 :            :                         NFP_FLOWER_CMSG_TYPE_FLOW_DEL, msg_len);
     206         [ #  # ]:          0 :         rte_memcpy(msg, flow->payload.meta, msg_len);
     207                 :            : 
     208                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     209         [ #  # ]:          0 :         if (cnt == 0) {
     210                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     211                 :          0 :                 rte_pktmbuf_free(mbuf);
     212                 :          0 :                 return -EIO;
     213                 :            :         }
     214                 :            : 
     215                 :            :         return 0;
     216                 :            : }
     217                 :            : 
     218                 :            : int
     219                 :          0 : nfp_flower_cmsg_flow_add(struct nfp_app_fw_flower *app_fw_flower,
     220                 :            :                 struct rte_flow *flow)
     221                 :            : {
     222                 :            :         char *msg;
     223                 :            :         uint16_t cnt;
     224                 :            :         uint32_t msg_len;
     225                 :            :         struct rte_mbuf *mbuf;
     226                 :            :         struct nfp_fl_rule_metadata *nfp_flow_meta;
     227                 :            : 
     228                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     229         [ #  # ]:          0 :         if (mbuf == NULL) {
     230                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for flow add.");
     231                 :          0 :                 return -ENOMEM;
     232                 :            :         }
     233                 :            : 
     234                 :            :         /* Copy the flow to mbuf */
     235                 :          0 :         nfp_flow_meta = flow->payload.meta;
     236                 :          0 :         msg_len = (nfp_flow_meta->key_len + nfp_flow_meta->mask_len +
     237                 :          0 :                         nfp_flow_meta->act_len) << NFP_FL_LW_SIZ;
     238                 :          0 :         msg_len += sizeof(struct nfp_fl_rule_metadata);
     239                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     240                 :            :                         NFP_FLOWER_CMSG_TYPE_FLOW_ADD, msg_len);
     241         [ #  # ]:          0 :         rte_memcpy(msg, flow->payload.meta, msg_len);
     242                 :            : 
     243                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     244         [ #  # ]:          0 :         if (cnt == 0) {
     245                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     246                 :          0 :                 rte_pktmbuf_free(mbuf);
     247                 :          0 :                 return -EIO;
     248                 :            :         }
     249                 :            : 
     250                 :            :         return 0;
     251                 :            : }
     252                 :            : 
     253                 :            : int
     254                 :          0 : nfp_flower_cmsg_tun_neigh_v4_rule(struct nfp_app_fw_flower *app_fw_flower,
     255                 :            :                 struct nfp_flower_cmsg_tun_neigh_v4 *payload)
     256                 :            : {
     257                 :            :         uint16_t cnt;
     258                 :            :         size_t msg_len;
     259                 :            :         struct rte_mbuf *mbuf;
     260                 :            :         struct nfp_flower_cmsg_tun_neigh_v4 *msg;
     261                 :            : 
     262                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     263         [ #  # ]:          0 :         if (mbuf == NULL) {
     264                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v4 tun neigh");
     265                 :          0 :                 return -ENOMEM;
     266                 :            :         }
     267                 :            : 
     268                 :            :         msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v4);
     269         [ #  # ]:          0 :         if (!nfp_flower_support_decap_v2(app_fw_flower))
     270                 :            :                 msg_len -= sizeof(struct nfp_flower_tun_neigh_ext);
     271                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     272                 :            :                         NFP_FLOWER_CMSG_TYPE_TUN_NEIGH, msg_len);
     273                 :            :         memcpy(msg, payload, msg_len);
     274                 :            : 
     275                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     276         [ #  # ]:          0 :         if (cnt == 0) {
     277                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     278                 :          0 :                 rte_pktmbuf_free(mbuf);
     279                 :          0 :                 return -EIO;
     280                 :            :         }
     281                 :            : 
     282                 :            :         return 0;
     283                 :            : }
     284                 :            : 
     285                 :            : int
     286                 :          0 : nfp_flower_cmsg_tun_neigh_v6_rule(struct nfp_app_fw_flower *app_fw_flower,
     287                 :            :                 struct nfp_flower_cmsg_tun_neigh_v6 *payload)
     288                 :            : {
     289                 :            :         uint16_t cnt;
     290                 :            :         size_t msg_len;
     291                 :            :         struct rte_mbuf *mbuf;
     292                 :            :         struct nfp_flower_cmsg_tun_neigh_v6 *msg;
     293                 :            : 
     294                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     295         [ #  # ]:          0 :         if (mbuf == NULL) {
     296                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v6 tun neigh");
     297                 :          0 :                 return -ENOMEM;
     298                 :            :         }
     299                 :            : 
     300                 :            :         msg_len = sizeof(struct nfp_flower_cmsg_tun_neigh_v6);
     301         [ #  # ]:          0 :         if (!nfp_flower_support_decap_v2(app_fw_flower))
     302                 :            :                 msg_len -= sizeof(struct nfp_flower_tun_neigh_ext);
     303                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     304                 :            :                         NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6, msg_len);
     305                 :            :         memcpy(msg, payload, msg_len);
     306                 :            : 
     307                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     308         [ #  # ]:          0 :         if (cnt == 0) {
     309                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     310                 :          0 :                 rte_pktmbuf_free(mbuf);
     311                 :          0 :                 return -EIO;
     312                 :            :         }
     313                 :            : 
     314                 :            :         return 0;
     315                 :            : }
     316                 :            : 
     317                 :            : int
     318                 :          0 : nfp_flower_cmsg_tun_off_v4(struct nfp_app_fw_flower *app_fw_flower)
     319                 :            : {
     320                 :            :         uint16_t cnt;
     321                 :            :         uint32_t count = 0;
     322                 :            :         struct rte_mbuf *mbuf;
     323                 :            :         struct nfp_flow_priv *priv;
     324                 :            :         struct nfp_ipv4_addr_entry *entry;
     325                 :            :         struct nfp_flower_cmsg_tun_ipv4_addr *msg;
     326                 :            : 
     327                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     328         [ #  # ]:          0 :         if (mbuf == NULL) {
     329                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v4 tun addr");
     330                 :          0 :                 return -ENOMEM;
     331                 :            :         }
     332                 :            : 
     333                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     334                 :            :                         NFP_FLOWER_CMSG_TYPE_TUN_IPS, sizeof(*msg));
     335                 :            : 
     336                 :          0 :         priv = app_fw_flower->flow_priv;
     337                 :          0 :         rte_spinlock_lock(&priv->ipv4_off_lock);
     338         [ #  # ]:          0 :         LIST_FOREACH(entry, &priv->ipv4_off_list, next) {
     339         [ #  # ]:          0 :                 if (count >= NFP_FL_IPV4_ADDRS_MAX) {
     340                 :            :                         rte_spinlock_unlock(&priv->ipv4_off_lock);
     341                 :          0 :                         PMD_DRV_LOG(ERR, "IPv4 offload exceeds limit.");
     342                 :          0 :                         return -ERANGE;
     343                 :            :                 }
     344                 :          0 :                 msg->ipv4_addr[count] = entry->ipv4_addr;
     345                 :          0 :                 count++;
     346                 :            :         }
     347         [ #  # ]:          0 :         msg->count = rte_cpu_to_be_32(count);
     348                 :            :         rte_spinlock_unlock(&priv->ipv4_off_lock);
     349                 :            : 
     350                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     351         [ #  # ]:          0 :         if (cnt == 0) {
     352                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     353                 :          0 :                 rte_pktmbuf_free(mbuf);
     354                 :          0 :                 return -EIO;
     355                 :            :         }
     356                 :            : 
     357                 :            :         return 0;
     358                 :            : }
     359                 :            : 
     360                 :            : int
     361                 :          0 : nfp_flower_cmsg_tun_off_v6(struct nfp_app_fw_flower *app_fw_flower)
     362                 :            : {
     363                 :            :         uint16_t cnt;
     364                 :            :         uint32_t count = 0;
     365                 :            :         struct rte_mbuf *mbuf;
     366                 :            :         struct nfp_flow_priv *priv;
     367                 :            :         struct nfp_ipv6_addr_entry *entry;
     368                 :            :         struct nfp_flower_cmsg_tun_ipv6_addr *msg;
     369                 :            : 
     370                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     371         [ #  # ]:          0 :         if (mbuf == NULL) {
     372                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for v6 tun addr");
     373                 :          0 :                 return -ENOMEM;
     374                 :            :         }
     375                 :            : 
     376                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     377                 :            :                         NFP_FLOWER_CMSG_TYPE_TUN_IPS_V6, sizeof(*msg));
     378                 :            : 
     379                 :          0 :         priv = app_fw_flower->flow_priv;
     380                 :          0 :         rte_spinlock_lock(&priv->ipv6_off_lock);
     381         [ #  # ]:          0 :         LIST_FOREACH(entry, &priv->ipv6_off_list, next) {
     382         [ #  # ]:          0 :                 if (count >= NFP_FL_IPV6_ADDRS_MAX) {
     383                 :            :                         rte_spinlock_unlock(&priv->ipv6_off_lock);
     384                 :          0 :                         PMD_DRV_LOG(ERR, "IPv6 offload exceeds limit.");
     385                 :          0 :                         return -ERANGE;
     386                 :            :                 }
     387                 :          0 :                 memcpy(&msg->ipv6_addr[count * 16], entry->ipv6_addr, 16UL);
     388                 :          0 :                 count++;
     389                 :            :         }
     390         [ #  # ]:          0 :         msg->count = rte_cpu_to_be_32(count);
     391                 :            :         rte_spinlock_unlock(&priv->ipv6_off_lock);
     392                 :            : 
     393                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     394         [ #  # ]:          0 :         if (cnt == 0) {
     395                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     396                 :          0 :                 rte_pktmbuf_free(mbuf);
     397                 :          0 :                 return -EIO;
     398                 :            :         }
     399                 :            : 
     400                 :            :         return 0;
     401                 :            : }
     402                 :            : 
     403                 :            : int
     404                 :          0 : nfp_flower_cmsg_pre_tunnel_rule(struct nfp_app_fw_flower *app_fw_flower,
     405                 :            :                 struct nfp_fl_rule_metadata *nfp_flow_meta,
     406                 :            :                 uint16_t mac_idx,
     407                 :            :                 bool is_del)
     408                 :            : {
     409                 :            :         uint16_t cnt;
     410                 :            :         struct rte_mbuf *mbuf;
     411                 :            :         struct nfp_flower_meta_tci *meta_tci;
     412                 :            :         struct nfp_flower_cmsg_pre_tun_rule *msg;
     413                 :            : 
     414                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     415         [ #  # ]:          0 :         if (mbuf == NULL) {
     416                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for pre tunnel rule");
     417                 :          0 :                 return -ENOMEM;
     418                 :            :         }
     419                 :            : 
     420                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     421                 :            :                         NFP_FLOWER_CMSG_TYPE_PRE_TUN_RULE, sizeof(*msg));
     422                 :            : 
     423                 :            :         meta_tci = (struct nfp_flower_meta_tci *)((char *)nfp_flow_meta +
     424                 :            :                         sizeof(struct nfp_fl_rule_metadata));
     425         [ #  # ]:          0 :         if (meta_tci->tci)
     426                 :          0 :                 msg->vlan_tci = meta_tci->tci;
     427                 :            :         else
     428                 :          0 :                 msg->vlan_tci = 0xffff;
     429                 :            : 
     430         [ #  # ]:          0 :         if (is_del)
     431                 :          0 :                 msg->flags = rte_cpu_to_be_32(NFP_TUN_PRE_TUN_RULE_DEL);
     432                 :            : 
     433         [ #  # ]:          0 :         msg->port_idx = rte_cpu_to_be_16(mac_idx);
     434                 :          0 :         msg->host_ctx_id = nfp_flow_meta->host_ctx_id;
     435                 :            : 
     436                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     437         [ #  # ]:          0 :         if (cnt == 0) {
     438                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     439                 :          0 :                 rte_pktmbuf_free(mbuf);
     440                 :          0 :                 return -EIO;
     441                 :            :         }
     442                 :            : 
     443                 :            :         return 0;
     444                 :            : }
     445                 :            : 
     446                 :            : int
     447                 :          0 : nfp_flower_cmsg_tun_mac_rule(struct nfp_app_fw_flower *app_fw_flower,
     448                 :            :                 struct rte_ether_addr *mac,
     449                 :            :                 uint16_t mac_idx,
     450                 :            :                 bool is_del)
     451                 :            : {
     452                 :            :         uint16_t cnt;
     453                 :            :         struct rte_mbuf *mbuf;
     454                 :            :         struct nfp_flower_cmsg_tun_mac *msg;
     455                 :            : 
     456                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     457         [ #  # ]:          0 :         if (mbuf == NULL) {
     458                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for tunnel mac");
     459                 :          0 :                 return -ENOMEM;
     460                 :            :         }
     461                 :            : 
     462                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     463                 :            :                         NFP_FLOWER_CMSG_TYPE_TUN_MAC, sizeof(*msg));
     464                 :            : 
     465                 :          0 :         msg->count = rte_cpu_to_be_16(1);
     466   [ #  #  #  # ]:          0 :         msg->index = rte_cpu_to_be_16(mac_idx);
     467                 :            :         rte_ether_addr_copy(mac, &msg->addr);
     468         [ #  # ]:          0 :         if (is_del)
     469                 :          0 :                 msg->flags = rte_cpu_to_be_16(NFP_TUN_MAC_OFFLOAD_DEL_FLAG);
     470                 :            : 
     471                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     472         [ #  # ]:          0 :         if (cnt == 0) {
     473                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     474                 :          0 :                 rte_pktmbuf_free(mbuf);
     475                 :          0 :                 return -EIO;
     476                 :            :         }
     477                 :            : 
     478                 :            :         return 0;
     479                 :            : }
     480                 :            : 
     481                 :            : int
     482                 :          0 : nfp_flower_cmsg_qos_add(struct nfp_app_fw_flower *app_fw_flower,
     483                 :            :                 struct nfp_profile_conf *conf)
     484                 :            : {
     485                 :            :         char *msg;
     486                 :            :         uint16_t cnt;
     487                 :            :         uint32_t len;
     488                 :            :         struct rte_mbuf *mbuf;
     489                 :            : 
     490                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     491         [ #  # ]:          0 :         if (mbuf == NULL) {
     492                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for qos add");
     493                 :          0 :                 return -ENOMEM;
     494                 :            :         }
     495                 :            : 
     496                 :            :         len = sizeof(struct nfp_profile_conf);
     497                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     498                 :            :                         NFP_FLOWER_CMSG_TYPE_QOS_MOD, len);
     499                 :            :         rte_memcpy(msg, conf, len);
     500                 :            : 
     501                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     502         [ #  # ]:          0 :         if (cnt == 0) {
     503                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     504                 :          0 :                 rte_pktmbuf_free(mbuf);
     505                 :          0 :                 return -EIO;
     506                 :            :         }
     507                 :            : 
     508                 :            :         return 0;
     509                 :            : }
     510                 :            : 
     511                 :            : int
     512                 :          0 : nfp_flower_cmsg_qos_delete(struct nfp_app_fw_flower *app_fw_flower,
     513                 :            :                 struct nfp_profile_conf *conf)
     514                 :            : {
     515                 :            :         char *msg;
     516                 :            :         uint16_t cnt;
     517                 :            :         uint32_t len;
     518                 :            :         struct rte_mbuf *mbuf;
     519                 :            : 
     520                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     521         [ #  # ]:          0 :         if (mbuf == NULL) {
     522                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for qos delete");
     523                 :          0 :                 return -ENOMEM;
     524                 :            :         }
     525                 :            : 
     526                 :            :         len = sizeof(struct nfp_profile_conf);
     527                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     528                 :            :                         NFP_FLOWER_CMSG_TYPE_QOS_DEL, len);
     529                 :            :         rte_memcpy(msg, conf, len);
     530                 :            : 
     531                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     532         [ #  # ]:          0 :         if (cnt == 0) {
     533                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     534                 :          0 :                 rte_pktmbuf_free(mbuf);
     535                 :          0 :                 return -EIO;
     536                 :            :         }
     537                 :            : 
     538                 :            :         return 0;
     539                 :            : }
     540                 :            : 
     541                 :            : int
     542                 :          0 : nfp_flower_cmsg_qos_stats(struct nfp_app_fw_flower *app_fw_flower,
     543                 :            :                 struct nfp_cfg_head *head)
     544                 :            : {
     545                 :            :         char *msg;
     546                 :            :         uint16_t cnt;
     547                 :            :         uint32_t len;
     548                 :            :         struct rte_mbuf *mbuf;
     549                 :            : 
     550                 :          0 :         mbuf = rte_pktmbuf_alloc(app_fw_flower->ctrl_pktmbuf_pool);
     551         [ #  # ]:          0 :         if (mbuf == NULL) {
     552                 :          0 :                 PMD_DRV_LOG(DEBUG, "Failed to alloc mbuf for qos stats");
     553                 :          0 :                 return -ENOMEM;
     554                 :            :         }
     555                 :            : 
     556                 :            :         len = sizeof(struct nfp_cfg_head);
     557                 :          0 :         msg = nfp_flower_cmsg_init(app_fw_flower, mbuf,
     558                 :            :                         NFP_FLOWER_CMSG_TYPE_QOS_STATS, len);
     559                 :            :         rte_memcpy(msg, head, len);
     560                 :            : 
     561                 :          0 :         cnt = nfp_flower_ctrl_vnic_xmit(app_fw_flower, mbuf);
     562         [ #  # ]:          0 :         if (cnt == 0) {
     563                 :          0 :                 PMD_DRV_LOG(ERR, "Send cmsg through ctrl vnic failed.");
     564                 :          0 :                 rte_pktmbuf_free(mbuf);
     565                 :          0 :                 return -EIO;
     566                 :            :         }
     567                 :            : 
     568                 :            :         return 0;
     569                 :            : }

Generated by: LCOV version 1.14