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

Generated by: LCOV version 1.14