LCOV - code coverage report
Current view: top level - drivers/net/intel/ixgbe - ixgbe_ipsec.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 278 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 202 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2010-2017 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <ethdev_driver.h>
       6                 :            : #include <ethdev_pci.h>
       7                 :            : #include <rte_ip.h>
       8                 :            : #include <rte_jhash.h>
       9                 :            : #include <rte_security_driver.h>
      10                 :            : #include <rte_cryptodev.h>
      11                 :            : #include <rte_flow.h>
      12                 :            : 
      13                 :            : #include "base/ixgbe_type.h"
      14                 :            : #include "base/ixgbe_api.h"
      15                 :            : #include "ixgbe_ethdev.h"
      16                 :            : #include "ixgbe_ipsec.h"
      17                 :            : 
      18                 :            : #define RTE_IXGBE_REGISTER_POLL_WAIT_5_MS  5
      19                 :            : 
      20                 :            : #define IXGBE_WAIT_RREAD \
      21                 :            :         IXGBE_WRITE_REG_THEN_POLL_MASK(hw, IXGBE_IPSRXIDX, reg_val, \
      22                 :            :         IPSRXIDX_READ, RTE_IXGBE_REGISTER_POLL_WAIT_5_MS)
      23                 :            : #define IXGBE_WAIT_RWRITE \
      24                 :            :         IXGBE_WRITE_REG_THEN_POLL_MASK(hw, IXGBE_IPSRXIDX, reg_val, \
      25                 :            :         IPSRXIDX_WRITE, RTE_IXGBE_REGISTER_POLL_WAIT_5_MS)
      26                 :            : #define IXGBE_WAIT_TREAD \
      27                 :            :         IXGBE_WRITE_REG_THEN_POLL_MASK(hw, IXGBE_IPSTXIDX, reg_val, \
      28                 :            :         IPSRXIDX_READ, RTE_IXGBE_REGISTER_POLL_WAIT_5_MS)
      29                 :            : #define IXGBE_WAIT_TWRITE \
      30                 :            :         IXGBE_WRITE_REG_THEN_POLL_MASK(hw, IXGBE_IPSTXIDX, reg_val, \
      31                 :            :         IPSRXIDX_WRITE, RTE_IXGBE_REGISTER_POLL_WAIT_5_MS)
      32                 :            : 
      33                 :            : #define CMP_IP(a, b) (\
      34                 :            :         (a).ipv6[0] == (b).ipv6[0] && \
      35                 :            :         (a).ipv6[1] == (b).ipv6[1] && \
      36                 :            :         (a).ipv6[2] == (b).ipv6[2] && \
      37                 :            :         (a).ipv6[3] == (b).ipv6[3])
      38                 :            : 
      39                 :            : 
      40                 :            : static void
      41                 :          0 : ixgbe_crypto_clear_ipsec_tables(struct rte_eth_dev *dev)
      42                 :            : {
      43                 :          0 :         struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
      44                 :            :         struct ixgbe_ipsec *priv = IXGBE_DEV_PRIVATE_TO_IPSEC(
      45                 :            :                                 dev->data->dev_private);
      46                 :            :         int i = 0;
      47                 :            : 
      48                 :            :         /* clear Rx IP table*/
      49         [ #  # ]:          0 :         for (i = 0; i < IPSEC_MAX_RX_IP_COUNT; i++) {
      50                 :          0 :                 uint16_t index = i << 3;
      51                 :          0 :                 uint32_t reg_val = IPSRXIDX_WRITE | IPSRXIDX_TABLE_IP | index;
      52                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(0), 0);
      53                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(1), 0);
      54                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(2), 0);
      55                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(3), 0);
      56   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
      57                 :            :         }
      58                 :            : 
      59                 :            :         /* clear Rx SPI and Rx/Tx SA tables*/
      60         [ #  # ]:          0 :         for (i = 0; i < IPSEC_MAX_SA_COUNT; i++) {
      61                 :          0 :                 uint32_t index = i << 3;
      62                 :          0 :                 uint32_t reg_val = IPSRXIDX_WRITE | IPSRXIDX_TABLE_SPI | index;
      63                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXSPI, 0);
      64                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPIDX, 0);
      65   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
      66                 :          0 :                 reg_val = IPSRXIDX_WRITE | IPSRXIDX_TABLE_KEY | index;
      67                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(0), 0);
      68                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(1), 0);
      69                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(2), 0);
      70                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(3), 0);
      71                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXSALT, 0);
      72                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXMOD, 0);
      73   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
      74                 :          0 :                 reg_val = IPSRXIDX_WRITE | index;
      75                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(0), 0);
      76                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(1), 0);
      77                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(2), 0);
      78                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(3), 0);
      79                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXSALT, 0);
      80   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_TWRITE;
      81                 :            :         }
      82                 :            : 
      83                 :          0 :         memset(priv->rx_ip_tbl, 0, sizeof(priv->rx_ip_tbl));
      84                 :          0 :         memset(priv->rx_sa_tbl, 0, sizeof(priv->rx_sa_tbl));
      85                 :          0 :         memset(priv->tx_sa_tbl, 0, sizeof(priv->tx_sa_tbl));
      86                 :          0 : }
      87                 :            : 
      88                 :            : static int
      89                 :          0 : ixgbe_crypto_add_sa(struct ixgbe_crypto_session *ic_session)
      90                 :            : {
      91                 :          0 :         struct rte_eth_dev *dev = ic_session->dev;
      92                 :          0 :         struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
      93                 :            :         struct ixgbe_ipsec *priv = IXGBE_DEV_PRIVATE_TO_IPSEC(
      94                 :            :                         dev->data->dev_private);
      95                 :            :         uint32_t reg_val;
      96                 :            :         int sa_index = -1;
      97                 :            : 
      98         [ #  # ]:          0 :         if (ic_session->op == IXGBE_OP_AUTHENTICATED_DECRYPTION) {
      99                 :            :                 int i, ip_index = -1;
     100                 :            :                 uint8_t *key;
     101                 :            : 
     102                 :            :                 /* Find a match in the IP table*/
     103         [ #  # ]:          0 :                 for (i = 0; i < IPSEC_MAX_RX_IP_COUNT; i++) {
     104   [ #  #  #  #  :          0 :                         if (CMP_IP(priv->rx_ip_tbl[i].ip,
             #  #  #  # ]
     105                 :            :                                    ic_session->dst_ip)) {
     106                 :            :                                 ip_index = i;
     107                 :            :                                 break;
     108                 :            :                         }
     109                 :            :                 }
     110                 :            :                 /* If no match, find a free entry in the IP table*/
     111         [ #  # ]:          0 :                 if (ip_index < 0) {
     112         [ #  # ]:          0 :                         for (i = 0; i < IPSEC_MAX_RX_IP_COUNT; i++) {
     113         [ #  # ]:          0 :                                 if (priv->rx_ip_tbl[i].ref_count == 0) {
     114                 :            :                                         ip_index = i;
     115                 :            :                                         break;
     116                 :            :                                 }
     117                 :            :                         }
     118                 :            :                 }
     119                 :            : 
     120                 :            :                 /* Fail if no match and no free entries*/
     121         [ #  # ]:          0 :                 if (ip_index < 0) {
     122                 :          0 :                         PMD_DRV_LOG(ERR,
     123                 :            :                                     "No free entry left in the Rx IP table");
     124                 :          0 :                         return -1;
     125                 :            :                 }
     126                 :            : 
     127                 :            :                 /* Find a free entry in the SA table*/
     128         [ #  # ]:          0 :                 for (i = 0; i < IPSEC_MAX_SA_COUNT; i++) {
     129         [ #  # ]:          0 :                         if (priv->rx_sa_tbl[i].used == 0) {
     130                 :            :                                 sa_index = i;
     131                 :            :                                 break;
     132                 :            :                         }
     133                 :            :                 }
     134                 :            :                 /* Fail if no free entries*/
     135         [ #  # ]:          0 :                 if (sa_index < 0) {
     136                 :          0 :                         PMD_DRV_LOG(ERR,
     137                 :            :                                     "No free entry left in the Rx SA table");
     138                 :          0 :                         return -1;
     139                 :            :                 }
     140                 :            : 
     141                 :          0 :                 priv->rx_ip_tbl[ip_index].ip.ipv6[0] =
     142                 :          0 :                                 ic_session->dst_ip.ipv6[0];
     143                 :          0 :                 priv->rx_ip_tbl[ip_index].ip.ipv6[1] =
     144                 :          0 :                                 ic_session->dst_ip.ipv6[1];
     145                 :          0 :                 priv->rx_ip_tbl[ip_index].ip.ipv6[2] =
     146                 :          0 :                                 ic_session->dst_ip.ipv6[2];
     147                 :          0 :                 priv->rx_ip_tbl[ip_index].ip.ipv6[3] =
     148                 :          0 :                                 ic_session->dst_ip.ipv6[3];
     149                 :          0 :                 priv->rx_ip_tbl[ip_index].ref_count++;
     150                 :            : 
     151                 :          0 :                 priv->rx_sa_tbl[sa_index].spi =
     152         [ #  # ]:          0 :                         rte_cpu_to_be_32(ic_session->spi);
     153                 :          0 :                 priv->rx_sa_tbl[sa_index].ip_index = ip_index;
     154                 :            :                 priv->rx_sa_tbl[sa_index].mode = IPSRXMOD_VALID;
     155                 :            :                 if (ic_session->op == IXGBE_OP_AUTHENTICATED_DECRYPTION)
     156                 :          0 :                         priv->rx_sa_tbl[sa_index].mode |=
     157                 :            :                                         (IPSRXMOD_PROTO | IPSRXMOD_DECRYPT);
     158         [ #  # ]:          0 :                 if (ic_session->dst_ip.type == IPv6) {
     159                 :          0 :                         priv->rx_sa_tbl[sa_index].mode |= IPSRXMOD_IPV6;
     160                 :          0 :                         priv->rx_ip_tbl[ip_index].ip.type = IPv6;
     161         [ #  # ]:          0 :                 } else if (ic_session->dst_ip.type == IPv4)
     162                 :          0 :                         priv->rx_ip_tbl[ip_index].ip.type = IPv4;
     163                 :            : 
     164                 :          0 :                 priv->rx_sa_tbl[sa_index].used = 1;
     165                 :            : 
     166                 :            :                 /* write IP table entry*/
     167                 :          0 :                 reg_val = IPSRXIDX_RX_EN | IPSRXIDX_WRITE |
     168                 :          0 :                                 IPSRXIDX_TABLE_IP | (ip_index << 3);
     169         [ #  # ]:          0 :                 if (priv->rx_ip_tbl[ip_index].ip.type == IPv4) {
     170                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(0), 0);
     171                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(1), 0);
     172                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(2), 0);
     173                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(3),
     174                 :            :                                         priv->rx_ip_tbl[ip_index].ip.ipv4);
     175                 :            :                 } else {
     176                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(0),
     177                 :            :                                         priv->rx_ip_tbl[ip_index].ip.ipv6[0]);
     178                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(1),
     179                 :            :                                         priv->rx_ip_tbl[ip_index].ip.ipv6[1]);
     180                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(2),
     181                 :            :                                         priv->rx_ip_tbl[ip_index].ip.ipv6[2]);
     182                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(3),
     183                 :            :                                         priv->rx_ip_tbl[ip_index].ip.ipv6[3]);
     184                 :            :                 }
     185   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
     186                 :            : 
     187                 :            :                 /* write SPI table entry*/
     188                 :          0 :                 reg_val = IPSRXIDX_RX_EN | IPSRXIDX_WRITE |
     189                 :          0 :                                 IPSRXIDX_TABLE_SPI | (sa_index << 3);
     190                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXSPI,
     191                 :            :                                 priv->rx_sa_tbl[sa_index].spi);
     192                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPIDX,
     193                 :            :                                 priv->rx_sa_tbl[sa_index].ip_index);
     194   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
     195                 :            : 
     196                 :            :                 /* write Key table entry*/
     197                 :          0 :                 key = malloc(ic_session->key_len);
     198         [ #  # ]:          0 :                 if (!key)
     199                 :            :                         return -ENOMEM;
     200                 :            : 
     201         [ #  # ]:          0 :                 memcpy(key, ic_session->key, ic_session->key_len);
     202                 :            : 
     203                 :          0 :                 reg_val = IPSRXIDX_RX_EN | IPSRXIDX_WRITE |
     204                 :            :                                 IPSRXIDX_TABLE_KEY | (sa_index << 3);
     205         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(0),
     206                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[12]));
     207         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(1),
     208                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[8]));
     209         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(2),
     210                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[4]));
     211         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(3),
     212                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[0]));
     213         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXSALT,
     214                 :            :                                 rte_cpu_to_be_32(ic_session->salt));
     215                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXMOD,
     216                 :            :                                 priv->rx_sa_tbl[sa_index].mode);
     217   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
     218                 :            : 
     219                 :          0 :                 free(key);
     220                 :            : 
     221                 :            :         } else { /* sess->dir == RTE_CRYPTO_OUTBOUND */
     222                 :            :                 uint8_t *key;
     223                 :            :                 int i;
     224                 :            : 
     225                 :            :                 /* Find a free entry in the SA table*/
     226         [ #  # ]:          0 :                 for (i = 0; i < IPSEC_MAX_SA_COUNT; i++) {
     227         [ #  # ]:          0 :                         if (priv->tx_sa_tbl[i].used == 0) {
     228                 :            :                                 sa_index = i;
     229                 :            :                                 break;
     230                 :            :                         }
     231                 :            :                 }
     232                 :            :                 /* Fail if no free entries*/
     233         [ #  # ]:          0 :                 if (sa_index < 0) {
     234                 :          0 :                         PMD_DRV_LOG(ERR,
     235                 :            :                                     "No free entry left in the Tx SA table");
     236                 :          0 :                         return -1;
     237                 :            :                 }
     238                 :            : 
     239                 :          0 :                 priv->tx_sa_tbl[sa_index].spi =
     240         [ #  # ]:          0 :                         rte_cpu_to_be_32(ic_session->spi);
     241                 :          0 :                 priv->tx_sa_tbl[i].used = 1;
     242                 :          0 :                 ic_session->sa_index = sa_index;
     243                 :            : 
     244                 :          0 :                 key = malloc(ic_session->key_len);
     245         [ #  # ]:          0 :                 if (!key)
     246                 :            :                         return -ENOMEM;
     247                 :            : 
     248         [ #  # ]:          0 :                 memcpy(key, ic_session->key, ic_session->key_len);
     249                 :            : 
     250                 :            :                 /* write Key table entry*/
     251                 :          0 :                 reg_val = IPSRXIDX_RX_EN | IPSRXIDX_WRITE | (sa_index << 3);
     252         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(0),
     253                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[12]));
     254         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(1),
     255                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[8]));
     256         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(2),
     257                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[4]));
     258         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(3),
     259                 :            :                         rte_cpu_to_be_32(*(uint32_t *)&key[0]));
     260         [ #  # ]:          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXSALT,
     261                 :            :                                 rte_cpu_to_be_32(ic_session->salt));
     262   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_TWRITE;
     263                 :            : 
     264                 :          0 :                 free(key);
     265                 :            :         }
     266                 :            : 
     267                 :            :         return 0;
     268                 :            : }
     269                 :            : 
     270                 :            : static int
     271                 :          0 : ixgbe_crypto_remove_sa(struct rte_eth_dev *dev,
     272                 :            :                        struct ixgbe_crypto_session *ic_session)
     273                 :            : {
     274                 :          0 :         struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     275                 :            :         struct ixgbe_ipsec *priv =
     276                 :            :                         IXGBE_DEV_PRIVATE_TO_IPSEC(dev->data->dev_private);
     277                 :            :         uint32_t reg_val;
     278                 :            :         int sa_index = -1;
     279                 :            : 
     280         [ #  # ]:          0 :         if (ic_session->op == IXGBE_OP_AUTHENTICATED_DECRYPTION) {
     281                 :            :                 int i, ip_index = -1;
     282                 :            : 
     283                 :            :                 /* Find a match in the IP table*/
     284         [ #  # ]:          0 :                 for (i = 0; i < IPSEC_MAX_RX_IP_COUNT; i++) {
     285   [ #  #  #  #  :          0 :                         if (CMP_IP(priv->rx_ip_tbl[i].ip, ic_session->dst_ip)) {
             #  #  #  # ]
     286                 :            :                                 ip_index = i;
     287                 :            :                                 break;
     288                 :            :                         }
     289                 :            :                 }
     290                 :            : 
     291                 :            :                 /* Fail if no match*/
     292         [ #  # ]:          0 :                 if (ip_index < 0) {
     293                 :          0 :                         PMD_DRV_LOG(ERR,
     294                 :            :                                     "Entry not found in the Rx IP table");
     295                 :          0 :                         return -1;
     296                 :            :                 }
     297                 :            : 
     298                 :            :                 /* Find a free entry in the SA table*/
     299         [ #  # ]:          0 :                 for (i = 0; i < IPSEC_MAX_SA_COUNT; i++) {
     300         [ #  # ]:          0 :                         if (priv->rx_sa_tbl[i].spi ==
     301         [ #  # ]:          0 :                                   rte_cpu_to_be_32(ic_session->spi)) {
     302                 :            :                                 sa_index = i;
     303                 :            :                                 break;
     304                 :            :                         }
     305                 :            :                 }
     306                 :            :                 /* Fail if no match*/
     307         [ #  # ]:          0 :                 if (sa_index < 0) {
     308                 :          0 :                         PMD_DRV_LOG(ERR,
     309                 :            :                                     "Entry not found in the Rx SA table");
     310                 :          0 :                         return -1;
     311                 :            :                 }
     312                 :            : 
     313                 :            :                 /* Disable and clear Rx SPI and key table entries*/
     314                 :          0 :                 reg_val = IPSRXIDX_WRITE | IPSRXIDX_TABLE_SPI | (sa_index << 3);
     315                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXSPI, 0);
     316                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPIDX, 0);
     317   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
     318                 :          0 :                 reg_val = IPSRXIDX_WRITE | IPSRXIDX_TABLE_KEY | (sa_index << 3);
     319                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(0), 0);
     320                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(1), 0);
     321                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(2), 0);
     322                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXKEY(3), 0);
     323                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXSALT, 0);
     324                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSRXMOD, 0);
     325   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_RWRITE;
     326                 :          0 :                 priv->rx_sa_tbl[sa_index].used = 0;
     327                 :            : 
     328                 :            :                 /* If last used then clear the IP table entry*/
     329                 :          0 :                 priv->rx_ip_tbl[ip_index].ref_count--;
     330         [ #  # ]:          0 :                 if (priv->rx_ip_tbl[ip_index].ref_count == 0) {
     331                 :            :                         reg_val = IPSRXIDX_WRITE | IPSRXIDX_TABLE_IP |
     332                 :            :                                         (ip_index << 3);
     333                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(0), 0);
     334                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(1), 0);
     335                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(2), 0);
     336                 :          0 :                         IXGBE_WRITE_REG(hw, IXGBE_IPSRXIPADDR(3), 0);
     337                 :            :                 }
     338                 :            :         } else { /* session->dir == RTE_CRYPTO_OUTBOUND */
     339                 :            :                 int i;
     340                 :            : 
     341                 :            :                 /* Find a match in the SA table*/
     342         [ #  # ]:          0 :                 for (i = 0; i < IPSEC_MAX_SA_COUNT; i++) {
     343         [ #  # ]:          0 :                         if (priv->tx_sa_tbl[i].spi ==
     344         [ #  # ]:          0 :                                     rte_cpu_to_be_32(ic_session->spi)) {
     345                 :            :                                 sa_index = i;
     346                 :            :                                 break;
     347                 :            :                         }
     348                 :            :                 }
     349                 :            :                 /* Fail if no match entries*/
     350         [ #  # ]:          0 :                 if (sa_index < 0) {
     351                 :          0 :                         PMD_DRV_LOG(ERR,
     352                 :            :                                     "Entry not found in the Tx SA table");
     353                 :          0 :                         return -1;
     354                 :            :                 }
     355                 :          0 :                 reg_val = IPSRXIDX_WRITE | (sa_index << 3);
     356                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(0), 0);
     357                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(1), 0);
     358                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(2), 0);
     359                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXKEY(3), 0);
     360                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_IPSTXSALT, 0);
     361   [ #  #  #  # ]:          0 :                 IXGBE_WAIT_TWRITE;
     362                 :            : 
     363                 :          0 :                 priv->tx_sa_tbl[sa_index].used = 0;
     364                 :            :         }
     365                 :            : 
     366                 :            :         return 0;
     367                 :            : }
     368                 :            : 
     369                 :            : static int
     370                 :          0 : ixgbe_crypto_create_session(void *device,
     371                 :            :                 struct rte_security_session_conf *conf,
     372                 :            :                 struct rte_security_session *session)
     373                 :            : {
     374                 :            :         struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)device;
     375                 :          0 :         struct ixgbe_crypto_session *ic_session = SECURITY_GET_SESS_PRIV(session);
     376                 :            :         struct rte_crypto_aead_xform *aead_xform;
     377                 :          0 :         struct rte_eth_conf *dev_conf = &eth_dev->data->dev_conf;
     378                 :            : 
     379         [ #  # ]:          0 :         if (conf->crypto_xform->type != RTE_CRYPTO_SYM_XFORM_AEAD ||
     380         [ #  # ]:          0 :                         conf->crypto_xform->aead.algo !=
     381                 :            :                                         RTE_CRYPTO_AEAD_AES_GCM) {
     382                 :          0 :                 PMD_DRV_LOG(ERR, "Unsupported crypto transformation mode");
     383                 :          0 :                 return -ENOTSUP;
     384                 :            :         }
     385                 :            :         aead_xform = &conf->crypto_xform->aead;
     386                 :            : 
     387         [ #  # ]:          0 :         if (conf->ipsec.direction == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) {
     388         [ #  # ]:          0 :                 if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_SECURITY) {
     389                 :          0 :                         ic_session->op = IXGBE_OP_AUTHENTICATED_DECRYPTION;
     390                 :            :                 } else {
     391                 :          0 :                         PMD_DRV_LOG(ERR, "IPsec decryption not enabled");
     392                 :          0 :                         return -ENOTSUP;
     393                 :            :                 }
     394                 :            :         } else {
     395         [ #  # ]:          0 :                 if (dev_conf->txmode.offloads & RTE_ETH_TX_OFFLOAD_SECURITY) {
     396                 :          0 :                         ic_session->op = IXGBE_OP_AUTHENTICATED_ENCRYPTION;
     397                 :            :                 } else {
     398                 :          0 :                         PMD_DRV_LOG(ERR, "IPsec encryption not enabled");
     399                 :          0 :                         return -ENOTSUP;
     400                 :            :                 }
     401                 :            :         }
     402                 :            : 
     403                 :          0 :         ic_session->key = aead_xform->key.data;
     404                 :          0 :         ic_session->key_len = aead_xform->key.length;
     405                 :          0 :         memcpy(&ic_session->salt,
     406         [ #  # ]:          0 :                &aead_xform->key.data[aead_xform->key.length], 4);
     407                 :          0 :         ic_session->spi = conf->ipsec.spi;
     408                 :          0 :         ic_session->dev = eth_dev;
     409                 :            : 
     410         [ #  # ]:          0 :         if (ic_session->op == IXGBE_OP_AUTHENTICATED_ENCRYPTION) {
     411         [ #  # ]:          0 :                 if (ixgbe_crypto_add_sa(ic_session)) {
     412                 :          0 :                         PMD_DRV_LOG(ERR, "Failed to add SA");
     413                 :          0 :                         return -EPERM;
     414                 :            :                 }
     415                 :            :         }
     416                 :            : 
     417                 :            :         return 0;
     418                 :            : }
     419                 :            : 
     420                 :            : static unsigned int
     421                 :          0 : ixgbe_crypto_session_get_size(__rte_unused void *device)
     422                 :            : {
     423                 :          0 :         return sizeof(struct ixgbe_crypto_session);
     424                 :            : }
     425                 :            : 
     426                 :            : static int
     427                 :          0 : ixgbe_crypto_remove_session(void *device,
     428                 :            :                 struct rte_security_session *session)
     429                 :            : {
     430                 :            :         struct rte_eth_dev *eth_dev = device;
     431                 :          0 :         struct ixgbe_crypto_session *ic_session = SECURITY_GET_SESS_PRIV(session);
     432                 :            : 
     433         [ #  # ]:          0 :         if (eth_dev != ic_session->dev) {
     434                 :          0 :                 PMD_DRV_LOG(ERR, "Session not bound to this device");
     435                 :          0 :                 return -ENODEV;
     436                 :            :         }
     437                 :            : 
     438         [ #  # ]:          0 :         if (ixgbe_crypto_remove_sa(eth_dev, ic_session)) {
     439                 :          0 :                 PMD_DRV_LOG(ERR, "Failed to remove session");
     440                 :          0 :                 return -EFAULT;
     441                 :            :         }
     442                 :            : 
     443                 :            :         memset(ic_session, 0, sizeof(struct ixgbe_crypto_session));
     444                 :          0 :         return 0;
     445                 :            : }
     446                 :            : 
     447                 :            : static inline uint8_t
     448                 :            : ixgbe_crypto_compute_pad_len(struct rte_mbuf *m)
     449                 :            : {
     450                 :          0 :         if (m->nb_segs == 1) {
     451                 :            :                 /* 16 bytes ICV + 2 bytes ESP trailer + payload padding size
     452                 :            :                  * payload padding size is stored at <pkt_len - 18>
     453                 :            :                  */
     454                 :          0 :                 uint8_t *esp_pad_len = rte_pktmbuf_mtod_offset(m, uint8_t *,
     455                 :            :                                         rte_pktmbuf_pkt_len(m) -
     456                 :            :                                         (ESP_TRAILER_SIZE + ESP_ICV_SIZE));
     457                 :          0 :                 return *esp_pad_len + ESP_TRAILER_SIZE + ESP_ICV_SIZE;
     458                 :            :         }
     459                 :            :         return 0;
     460                 :            : }
     461                 :            : 
     462                 :            : static int
     463                 :          0 : ixgbe_crypto_update_mb(void *device __rte_unused,
     464                 :            :                 struct rte_security_session *session,
     465                 :            :                        struct rte_mbuf *m, void *params __rte_unused)
     466                 :            : {
     467                 :            :         struct ixgbe_crypto_session *ic_session = SECURITY_GET_SESS_PRIV(session);
     468         [ #  # ]:          0 :         if (ic_session->op == IXGBE_OP_AUTHENTICATED_ENCRYPTION) {
     469                 :            :                 union ixgbe_crypto_tx_desc_md *mdata =
     470                 :            :                         (union ixgbe_crypto_tx_desc_md *)
     471                 :            :                                 rte_security_dynfield(m);
     472                 :          0 :                 mdata->enc = 1;
     473         [ #  # ]:          0 :                 mdata->sa_idx = ic_session->sa_index;
     474                 :          0 :                 mdata->pad_len = ixgbe_crypto_compute_pad_len(m);
     475                 :            :         }
     476                 :          0 :         return 0;
     477                 :            : }
     478                 :            : 
     479                 :            : 
     480                 :            : static const struct rte_security_capability *
     481                 :          0 : ixgbe_crypto_capabilities_get(void *device __rte_unused)
     482                 :            : {
     483                 :            :         static const struct rte_cryptodev_capabilities
     484                 :            :         aes_gcm_gmac_crypto_capabilities[] = {
     485                 :            :                 {       /* AES GMAC (128-bit) */
     486                 :            :                         .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
     487                 :            :                         {.sym = {
     488                 :            :                                 .xform_type = RTE_CRYPTO_SYM_XFORM_AUTH,
     489                 :            :                                 {.auth = {
     490                 :            :                                         .algo = RTE_CRYPTO_AUTH_AES_GMAC,
     491                 :            :                                         .block_size = 16,
     492                 :            :                                         .key_size = {
     493                 :            :                                                 .min = 16,
     494                 :            :                                                 .max = 16,
     495                 :            :                                                 .increment = 0
     496                 :            :                                         },
     497                 :            :                                         .digest_size = {
     498                 :            :                                                 .min = 16,
     499                 :            :                                                 .max = 16,
     500                 :            :                                                 .increment = 0
     501                 :            :                                         },
     502                 :            :                                         .iv_size = {
     503                 :            :                                                 .min = 12,
     504                 :            :                                                 .max = 12,
     505                 :            :                                                 .increment = 0
     506                 :            :                                         }
     507                 :            :                                 }, }
     508                 :            :                         }, }
     509                 :            :                 },
     510                 :            :                 {       /* AES GCM (128-bit) */
     511                 :            :                         .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC,
     512                 :            :                         {.sym = {
     513                 :            :                                 .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD,
     514                 :            :                                 {.aead = {
     515                 :            :                                         .algo = RTE_CRYPTO_AEAD_AES_GCM,
     516                 :            :                                         .block_size = 16,
     517                 :            :                                         .key_size = {
     518                 :            :                                                 .min = 16,
     519                 :            :                                                 .max = 16,
     520                 :            :                                                 .increment = 0
     521                 :            :                                         },
     522                 :            :                                         .digest_size = {
     523                 :            :                                                 .min = 16,
     524                 :            :                                                 .max = 16,
     525                 :            :                                                 .increment = 0
     526                 :            :                                         },
     527                 :            :                                         .aad_size = {
     528                 :            :                                                 .min = 0,
     529                 :            :                                                 .max = 65535,
     530                 :            :                                                 .increment = 1
     531                 :            :                                         },
     532                 :            :                                         .iv_size = {
     533                 :            :                                                 .min = 12,
     534                 :            :                                                 .max = 12,
     535                 :            :                                                 .increment = 0
     536                 :            :                                         }
     537                 :            :                                 }, }
     538                 :            :                         }, }
     539                 :            :                 },
     540                 :            :                 {
     541                 :            :                         .op = RTE_CRYPTO_OP_TYPE_UNDEFINED,
     542                 :            :                         {.sym = {
     543                 :            :                                 .xform_type = RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED
     544                 :            :                         }, }
     545                 :            :                 },
     546                 :            :         };
     547                 :            : 
     548                 :            :         static const struct rte_security_capability
     549                 :            :         ixgbe_security_capabilities[] = {
     550                 :            :                 { /* IPsec Inline Crypto ESP Transport Egress */
     551                 :            :                         .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
     552                 :            :                         .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
     553                 :            :                         {.ipsec = {
     554                 :            :                                 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
     555                 :            :                                 .mode = RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT,
     556                 :            :                                 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
     557                 :            :                                 .options = { 0 }
     558                 :            :                         } },
     559                 :            :                         .crypto_capabilities = aes_gcm_gmac_crypto_capabilities,
     560                 :            :                         .ol_flags = RTE_SECURITY_TX_OLOAD_NEED_MDATA
     561                 :            :                 },
     562                 :            :                 { /* IPsec Inline Crypto ESP Transport Ingress */
     563                 :            :                         .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
     564                 :            :                         .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
     565                 :            :                         {.ipsec = {
     566                 :            :                                 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
     567                 :            :                                 .mode = RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT,
     568                 :            :                                 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
     569                 :            :                                 .options = { 0 }
     570                 :            :                         } },
     571                 :            :                         .crypto_capabilities = aes_gcm_gmac_crypto_capabilities,
     572                 :            :                         .ol_flags = 0
     573                 :            :                 },
     574                 :            :                 { /* IPsec Inline Crypto ESP Tunnel Egress */
     575                 :            :                         .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
     576                 :            :                         .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
     577                 :            :                         {.ipsec = {
     578                 :            :                                 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
     579                 :            :                                 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
     580                 :            :                                 .direction = RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
     581                 :            :                                 .options = { 0 }
     582                 :            :                         } },
     583                 :            :                         .crypto_capabilities = aes_gcm_gmac_crypto_capabilities,
     584                 :            :                         .ol_flags = RTE_SECURITY_TX_OLOAD_NEED_MDATA
     585                 :            :                 },
     586                 :            :                 { /* IPsec Inline Crypto ESP Tunnel Ingress */
     587                 :            :                         .action = RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
     588                 :            :                         .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
     589                 :            :                         {.ipsec = {
     590                 :            :                                 .proto = RTE_SECURITY_IPSEC_SA_PROTO_ESP,
     591                 :            :                                 .mode = RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
     592                 :            :                                 .direction = RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
     593                 :            :                                 .options = { 0 }
     594                 :            :                         } },
     595                 :            :                         .crypto_capabilities = aes_gcm_gmac_crypto_capabilities,
     596                 :            :                         .ol_flags = 0
     597                 :            :                 },
     598                 :            :                 {
     599                 :            :                         .action = RTE_SECURITY_ACTION_TYPE_NONE
     600                 :            :                 }
     601                 :            :         };
     602                 :            : 
     603                 :          0 :         return ixgbe_security_capabilities;
     604                 :            : }
     605                 :            : 
     606                 :            : 
     607                 :            : int
     608                 :          0 : ixgbe_crypto_enable_ipsec(struct rte_eth_dev *dev)
     609                 :            : {
     610                 :          0 :         struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     611                 :            :         uint32_t reg;
     612                 :            :         uint64_t rx_offloads;
     613                 :            :         uint64_t tx_offloads;
     614                 :            : 
     615                 :          0 :         rx_offloads = dev->data->dev_conf.rxmode.offloads;
     616                 :          0 :         tx_offloads = dev->data->dev_conf.txmode.offloads;
     617                 :            : 
     618                 :            :         /* sanity checks */
     619         [ #  # ]:          0 :         if (rx_offloads & RTE_ETH_RX_OFFLOAD_TCP_LRO) {
     620                 :          0 :                 PMD_DRV_LOG(ERR, "RSC and IPsec not supported");
     621                 :          0 :                 return -1;
     622                 :            :         }
     623         [ #  # ]:          0 :         if (rx_offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC) {
     624                 :          0 :                 PMD_DRV_LOG(ERR, "HW CRC strip needs to be enabled for IPsec");
     625                 :          0 :                 return -1;
     626                 :            :         }
     627                 :            : 
     628                 :            : 
     629                 :            :         /* Set IXGBE_SECTXBUFFAF to 0x15 as required in the datasheet*/
     630                 :          0 :         IXGBE_WRITE_REG(hw, IXGBE_SECTXBUFFAF, 0x15);
     631                 :            : 
     632                 :            :         /* IFG needs to be set to 3 when we are using security. Otherwise a Tx
     633                 :            :          * hang will occur with heavy traffic.
     634                 :            :          */
     635                 :          0 :         reg = IXGBE_READ_REG(hw, IXGBE_SECTXMINIFG);
     636                 :          0 :         reg = (reg & 0xFFFFFFF0) | 0x3;
     637                 :          0 :         IXGBE_WRITE_REG(hw, IXGBE_SECTXMINIFG, reg);
     638                 :            : 
     639                 :          0 :         reg  = IXGBE_READ_REG(hw, IXGBE_HLREG0);
     640                 :          0 :         reg |= IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_RXCRCSTRP;
     641                 :          0 :         IXGBE_WRITE_REG(hw, IXGBE_HLREG0, reg);
     642                 :            : 
     643         [ #  # ]:          0 :         if (rx_offloads & RTE_ETH_RX_OFFLOAD_SECURITY) {
     644                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, 0);
     645                 :          0 :                 reg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
     646         [ #  # ]:          0 :                 if (reg != 0) {
     647                 :          0 :                         PMD_DRV_LOG(ERR, "Error enabling Rx Crypto");
     648                 :          0 :                         return -1;
     649                 :            :                 }
     650                 :            :         }
     651         [ #  # ]:          0 :         if (tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY) {
     652                 :          0 :                 IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL,
     653                 :            :                                 IXGBE_SECTXCTRL_STORE_FORWARD);
     654                 :          0 :                 reg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
     655         [ #  # ]:          0 :                 if (reg != IXGBE_SECTXCTRL_STORE_FORWARD) {
     656                 :          0 :                         PMD_DRV_LOG(ERR, "Error enabling Rx Crypto");
     657                 :          0 :                         return -1;
     658                 :            :                 }
     659                 :            :         }
     660                 :            : 
     661                 :          0 :         ixgbe_crypto_clear_ipsec_tables(dev);
     662                 :            : 
     663                 :          0 :         return 0;
     664                 :            : }
     665                 :            : 
     666                 :            : int
     667                 :          0 : ixgbe_crypto_add_ingress_sa_from_flow(const void *sess,
     668                 :            :                                       const void *ip_spec,
     669                 :            :                                       uint8_t is_ipv6)
     670                 :            : {
     671                 :            :         /**
     672                 :            :          * FIXME Updating the session priv data when the session is const.
     673                 :            :          * Typecasting done here is wrong and the implementation need to be corrected.
     674                 :            :          */
     675                 :          0 :         struct ixgbe_crypto_session *ic_session = (void *)(uintptr_t)
     676                 :            :                         ((const struct rte_security_session *)sess)->driver_priv_data;
     677                 :            : 
     678         [ #  # ]:          0 :         if (ic_session->op == IXGBE_OP_AUTHENTICATED_DECRYPTION) {
     679         [ #  # ]:          0 :                 if (is_ipv6) {
     680                 :            :                         const struct rte_flow_item_ipv6 *ipv6 = ip_spec;
     681                 :          0 :                         ic_session->src_ip.type = IPv6;
     682                 :          0 :                         ic_session->dst_ip.type = IPv6;
     683                 :          0 :                         rte_memcpy(ic_session->src_ip.ipv6,
     684         [ #  # ]:          0 :                                    &ipv6->hdr.src_addr, 16);
     685                 :          0 :                         rte_memcpy(ic_session->dst_ip.ipv6,
     686         [ #  # ]:          0 :                                    &ipv6->hdr.dst_addr, 16);
     687                 :            :                 } else {
     688                 :            :                         const struct rte_flow_item_ipv4 *ipv4 = ip_spec;
     689                 :          0 :                         ic_session->src_ip.type = IPv4;
     690                 :          0 :                         ic_session->dst_ip.type = IPv4;
     691                 :          0 :                         ic_session->src_ip.ipv4 = ipv4->hdr.src_addr;
     692                 :          0 :                         ic_session->dst_ip.ipv4 = ipv4->hdr.dst_addr;
     693                 :            :                 }
     694                 :          0 :                 return ixgbe_crypto_add_sa(ic_session);
     695                 :            :         }
     696                 :            : 
     697                 :            :         return 0;
     698                 :            : }
     699                 :            : 
     700                 :            : static struct rte_security_ops ixgbe_security_ops = {
     701                 :            :         .session_create = ixgbe_crypto_create_session,
     702                 :            :         .session_update = NULL,
     703                 :            :         .session_get_size = ixgbe_crypto_session_get_size,
     704                 :            :         .session_stats_get = NULL,
     705                 :            :         .session_destroy = ixgbe_crypto_remove_session,
     706                 :            :         .set_pkt_metadata = ixgbe_crypto_update_mb,
     707                 :            :         .capabilities_get = ixgbe_crypto_capabilities_get
     708                 :            : };
     709                 :            : 
     710                 :            : static int
     711                 :            : ixgbe_crypto_capable(struct rte_eth_dev *dev)
     712                 :            : {
     713                 :          0 :         struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
     714                 :            :         uint32_t reg_i, reg, capable = 1;
     715                 :            :         /* test if rx crypto can be enabled and then write back initial value*/
     716                 :          0 :         reg_i = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
     717                 :          0 :         IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, 0);
     718                 :          0 :         reg = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
     719         [ #  # ]:          0 :         if (reg != 0)
     720                 :            :                 capable = 0;
     721                 :          0 :         IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, reg_i);
     722                 :          0 :         return capable;
     723                 :            : }
     724                 :            : 
     725                 :            : int
     726                 :          0 : ixgbe_ipsec_ctx_create(struct rte_eth_dev *dev)
     727                 :            : {
     728                 :            :         struct rte_security_ctx *ctx = NULL;
     729                 :            : 
     730         [ #  # ]:          0 :         if (ixgbe_crypto_capable(dev)) {
     731                 :          0 :                 ctx = rte_malloc("rte_security_instances_ops",
     732                 :            :                                  sizeof(struct rte_security_ctx), 0);
     733         [ #  # ]:          0 :                 if (ctx) {
     734                 :          0 :                         ctx->device = (void *)dev;
     735                 :          0 :                         ctx->ops = &ixgbe_security_ops;
     736                 :          0 :                         ctx->sess_cnt = 0;
     737                 :          0 :                         dev->security_ctx = ctx;
     738                 :            :                 } else {
     739                 :            :                         return -ENOMEM;
     740                 :            :                 }
     741                 :            :         }
     742         [ #  # ]:          0 :         if (rte_security_dynfield_register() < 0)
     743                 :          0 :                 return -rte_errno;
     744                 :            :         return 0;
     745                 :            : }

Generated by: LCOV version 1.14