dpdk/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: BSD-3-Clause
   2 * Copyright(c) 2019-2021 Broadcom
   3 * All rights reserved.
   4 */
   5
   6#ifndef _BNXT_ULP_H_
   7#define _BNXT_ULP_H_
   8
   9#include <inttypes.h>
  10#include <stdbool.h>
  11#include <sys/queue.h>
  12
  13#include "rte_version.h"
  14#include "rte_ethdev.h"
  15
  16#include "bnxt.h"
  17#include "ulp_template_db_enum.h"
  18#include "ulp_tun.h"
  19#include "bnxt_tf_common.h"
  20
  21/* NAT defines to reuse existing inner L2 SMAC and DMAC */
  22#define BNXT_ULP_NAT_INNER_L2_HEADER_SMAC       0x2000
  23#define BNXT_ULP_NAT_OUTER_MOST_L2_HDR_SMAC     0x6000
  24#define BNXT_ULP_NAT_OUTER_MOST_L2_VLAN_TAGS    0xc00
  25#define BNXT_ULP_NAT_INNER_L2_HEADER_DMAC       0x100
  26#define BNXT_ULP_NAT_OUTER_MOST_L2_HDR_DMAC     0x300
  27#define BNXT_ULP_NAT_OUTER_MOST_FLAGS (BNXT_ULP_NAT_OUTER_MOST_L2_HDR_SMAC |\
  28                                        BNXT_ULP_NAT_OUTER_MOST_L2_VLAN_TAGS |\
  29                                        BNXT_ULP_NAT_OUTER_MOST_L2_HDR_DMAC)
  30
  31/* defines for the ulp_flags */
  32#define BNXT_ULP_VF_REP_ENABLED         0x1
  33#define BNXT_ULP_SHARED_SESSION_ENABLED 0x2
  34#define BNXT_ULP_APP_DEV_UNSUPPORTED    0x4
  35#define BNXT_ULP_HIGH_AVAIL_ENABLED     0x8
  36#define BNXT_ULP_APP_UNICAST_ONLY       0x10
  37#define BNXT_ULP_APP_SOCKET_DIRECT      0x20
  38
  39#define ULP_VF_REP_IS_ENABLED(flag)     ((flag) & BNXT_ULP_VF_REP_ENABLED)
  40#define ULP_SHARED_SESSION_IS_ENABLED(flag) ((flag) &\
  41                                             BNXT_ULP_SHARED_SESSION_ENABLED)
  42#define ULP_APP_DEV_UNSUPPORTED_ENABLED(flag)   ((flag) &\
  43                                                 BNXT_ULP_APP_DEV_UNSUPPORTED)
  44#define ULP_HIGH_AVAIL_IS_ENABLED(flag) ((flag) & BNXT_ULP_HIGH_AVAIL_ENABLED)
  45#define ULP_SOCKET_DIRECT_IS_ENABLED(flag) ((flag) & BNXT_ULP_APP_SOCKET_DIRECT)
  46
  47enum bnxt_ulp_flow_mem_type {
  48        BNXT_ULP_FLOW_MEM_TYPE_INT = 0,
  49        BNXT_ULP_FLOW_MEM_TYPE_EXT = 1,
  50        BNXT_ULP_FLOW_MEM_TYPE_BOTH = 2,
  51        BNXT_ULP_FLOW_MEM_TYPE_LAST = 3
  52};
  53
  54enum bnxt_rte_flow_item_type {
  55        BNXT_RTE_FLOW_ITEM_TYPE_END = (uint32_t)INT_MIN,
  56        BNXT_RTE_FLOW_ITEM_TYPE_VXLAN_DECAP,
  57        BNXT_RTE_FLOW_ITEM_TYPE_LAST
  58};
  59
  60enum bnxt_rte_flow_action_type {
  61        BNXT_RTE_FLOW_ACTION_TYPE_END = (uint32_t)INT_MIN,
  62        BNXT_RTE_FLOW_ACTION_TYPE_VXLAN_DECAP,
  63        BNXT_RTE_FLOW_ACTION_TYPE_LAST
  64};
  65
  66struct bnxt_ulp_df_rule_info {
  67        uint32_t                        def_port_flow_id;
  68        uint8_t                         valid;
  69};
  70
  71struct bnxt_ulp_vfr_rule_info {
  72        uint32_t                        vfr_flow_id;
  73        uint16_t                        parent_port_id;
  74        uint8_t                         valid;
  75};
  76
  77struct bnxt_ulp_data {
  78        uint32_t                        tbl_scope_id;
  79        struct bnxt_ulp_mark_tbl        *mark_tbl;
  80        uint32_t                        dev_id; /* Hardware device id */
  81        uint32_t                        ref_cnt;
  82        struct bnxt_ulp_flow_db         *flow_db;
  83        pthread_mutex_t                 flow_db_lock;
  84        void                            *mapper_data;
  85        struct bnxt_ulp_port_db         *port_db;
  86        struct bnxt_ulp_fc_info         *fc_info;
  87        struct bnxt_ulp_ha_mgr_info     *ha_info;
  88        uint32_t                        ulp_flags;
  89        struct bnxt_ulp_df_rule_info    df_rule_info[RTE_MAX_ETHPORTS];
  90        struct bnxt_ulp_vfr_rule_info   vfr_rule_info[RTE_MAX_ETHPORTS];
  91        enum bnxt_ulp_flow_mem_type     mem_type;
  92#define BNXT_ULP_TUN_ENTRY_INVALID      -1
  93#define BNXT_ULP_MAX_TUN_CACHE_ENTRIES  16
  94        struct bnxt_tun_cache_entry     tun_tbl[BNXT_ULP_MAX_TUN_CACHE_ENTRIES];
  95        uint8_t                         app_id;
  96        uint8_t                         num_shared_clients;
  97        struct bnxt_flow_app_tun_ent    app_tun[BNXT_ULP_MAX_TUN_CACHE_ENTRIES];
  98};
  99
 100struct bnxt_ulp_context {
 101        struct bnxt_ulp_data    *cfg_data;
 102        struct tf               *g_tfp;
 103        struct tf               *g_shared_tfp;
 104};
 105
 106struct bnxt_ulp_pci_info {
 107        uint32_t        domain;
 108        uint8_t         bus;
 109};
 110
 111struct bnxt_ulp_session_state {
 112        STAILQ_ENTRY(bnxt_ulp_session_state)    next;
 113        bool                                    bnxt_ulp_init;
 114        pthread_mutex_t                         bnxt_ulp_mutex;
 115        struct bnxt_ulp_pci_info                pci_info;
 116        struct bnxt_ulp_data                    *cfg_data;
 117        struct tf                               *g_tfp;
 118        struct tf                               g_shared_tfp;
 119        uint32_t                                session_opened;
 120};
 121
 122/* ULP flow id structure */
 123struct rte_tf_flow {
 124        uint32_t        flow_id;
 125};
 126
 127struct ulp_tlv_param {
 128        enum bnxt_ulp_df_param_type type;
 129        uint32_t length;
 130        uint8_t value[16];
 131};
 132
 133struct ulp_context_list_entry {
 134        TAILQ_ENTRY(ulp_context_list_entry)     next;
 135        struct bnxt_ulp_context                 *ulp_ctx;
 136};
 137
 138/*
 139 * Allow the deletion of context only for the bnxt device that
 140 * created the session
 141 */
 142bool
 143ulp_ctx_deinit_allowed(struct bnxt_ulp_context *ulp_ctx);
 144
 145/* Function to set the device id of the hardware. */
 146int32_t
 147bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx, uint32_t dev_id);
 148
 149/* Function to get the device id of the hardware. */
 150int32_t
 151bnxt_ulp_cntxt_dev_id_get(struct bnxt_ulp_context *ulp_ctx, uint32_t *dev_id);
 152
 153/* Function to get whether or not ext mem is used for EM */
 154int32_t
 155bnxt_ulp_cntxt_mem_type_get(struct bnxt_ulp_context *ulp_ctx,
 156                            enum bnxt_ulp_flow_mem_type *mem_type);
 157
 158/* Function to set whether or not ext mem is used for EM */
 159int32_t
 160bnxt_ulp_cntxt_mem_type_set(struct bnxt_ulp_context *ulp_ctx,
 161                            enum bnxt_ulp_flow_mem_type mem_type);
 162
 163/* Function to set the table scope id of the EEM table. */
 164int32_t
 165bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
 166                                uint32_t tbl_scope_id);
 167
 168/* Function to get the table scope id of the EEM table. */
 169int32_t
 170bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
 171                                uint32_t *tbl_scope_id);
 172
 173/* Function to set the tfp session details in the ulp context. */
 174int32_t
 175bnxt_ulp_cntxt_shared_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
 176
 177/* Function to get the tfp session details from ulp context. */
 178struct tf *
 179bnxt_ulp_cntxt_shared_tfp_get(struct bnxt_ulp_context *ulp);
 180
 181/* Function to set the tfp session details in the ulp context. */
 182int32_t
 183bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
 184
 185/* Function to get the tfp session details from ulp context. */
 186struct tf *
 187bnxt_ulp_cntxt_tfp_get(struct bnxt_ulp_context *ulp,
 188                       enum bnxt_ulp_shared_session shared);
 189
 190/* Get the device table entry based on the device id. */
 191struct bnxt_ulp_device_params *
 192bnxt_ulp_device_params_get(uint32_t dev_id);
 193
 194int32_t
 195bnxt_ulp_ctxt_ptr2_mark_db_set(struct bnxt_ulp_context *ulp_ctx,
 196                               struct bnxt_ulp_mark_tbl *mark_tbl);
 197
 198struct bnxt_ulp_mark_tbl *
 199bnxt_ulp_ctxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx);
 200
 201/* Function to set the flow database to the ulp context. */
 202int32_t
 203bnxt_ulp_cntxt_ptr2_flow_db_set(struct bnxt_ulp_context *ulp_ctx,
 204                                struct bnxt_ulp_flow_db *flow_db);
 205
 206/* Function to get the flow database from the ulp context. */
 207struct bnxt_ulp_flow_db *
 208bnxt_ulp_cntxt_ptr2_flow_db_get(struct bnxt_ulp_context *ulp_ctx);
 209
 210/* Function to get the tunnel cache table info from the ulp context. */
 211struct bnxt_tun_cache_entry *
 212bnxt_ulp_cntxt_ptr2_tun_tbl_get(struct bnxt_ulp_context *ulp_ctx);
 213
 214/* Function to get the ulp context from eth device. */
 215struct bnxt_ulp_context *
 216bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev);
 217
 218/* Function to add the ulp mapper data to the ulp context */
 219int32_t
 220bnxt_ulp_cntxt_ptr2_mapper_data_set(struct bnxt_ulp_context *ulp_ctx,
 221                                    void *mapper_data);
 222
 223/* Function to get the ulp mapper data from the ulp context */
 224void *
 225bnxt_ulp_cntxt_ptr2_mapper_data_get(struct bnxt_ulp_context *ulp_ctx);
 226
 227/* Function to set the port database to the ulp context. */
 228int32_t
 229bnxt_ulp_cntxt_ptr2_port_db_set(struct bnxt_ulp_context *ulp_ctx,
 230                                struct bnxt_ulp_port_db *port_db);
 231
 232/* Function to get the port database from the ulp context. */
 233struct bnxt_ulp_port_db *
 234bnxt_ulp_cntxt_ptr2_port_db_get(struct bnxt_ulp_context *ulp_ctx);
 235
 236/* Function to create default flows. */
 237int32_t
 238ulp_default_flow_create(struct rte_eth_dev *eth_dev,
 239                        struct ulp_tlv_param *param_list,
 240                        uint32_t ulp_class_tid,
 241                        uint32_t *flow_id);
 242
 243/* Function to destroy default flows. */
 244int32_t
 245ulp_default_flow_destroy(struct rte_eth_dev *eth_dev,
 246                         uint32_t flow_id);
 247
 248int
 249bnxt_ulp_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow,
 250                      struct rte_flow_error *error);
 251
 252int32_t
 253bnxt_ulp_cntxt_ptr2_fc_info_set(struct bnxt_ulp_context *ulp_ctx,
 254                                struct bnxt_ulp_fc_info *ulp_fc_info);
 255
 256struct bnxt_ulp_fc_info *
 257bnxt_ulp_cntxt_ptr2_fc_info_get(struct bnxt_ulp_context *ulp_ctx);
 258
 259int32_t
 260bnxt_ulp_cntxt_ptr2_ulp_flags_get(struct bnxt_ulp_context *ulp_ctx,
 261                                  uint32_t *flags);
 262
 263int32_t
 264bnxt_ulp_get_df_rule_info(uint16_t port_id, struct bnxt_ulp_context *ulp_ctx,
 265                          struct bnxt_ulp_df_rule_info *info);
 266
 267struct bnxt_ulp_vfr_rule_info*
 268bnxt_ulp_cntxt_ptr2_ulp_vfr_info_get(struct bnxt_ulp_context *ulp_ctx,
 269                                     uint32_t port_id);
 270
 271int32_t
 272bnxt_ulp_cntxt_acquire_fdb_lock(struct bnxt_ulp_context *ulp_ctx);
 273
 274void
 275bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx);
 276
 277struct bnxt_ulp_glb_resource_info *
 278bnxt_ulp_app_glb_resource_info_list_get(uint32_t *num_entries);
 279
 280int32_t
 281bnxt_ulp_cntxt_app_id_set(struct bnxt_ulp_context *ulp_ctx, uint8_t app_id);
 282
 283int32_t
 284bnxt_ulp_cntxt_app_id_get(struct bnxt_ulp_context *ulp_ctx, uint8_t *app_id);
 285
 286bool
 287bnxt_ulp_cntxt_shared_session_enabled(struct bnxt_ulp_context *ulp_ctx);
 288
 289struct bnxt_ulp_app_capabilities_info *
 290bnxt_ulp_app_cap_list_get(uint32_t *num_entries);
 291
 292int32_t
 293bnxt_ulp_cntxt_app_caps_init(struct bnxt *bp,
 294                             uint8_t app_id, uint32_t dev_id);
 295
 296struct bnxt_ulp_resource_resv_info *
 297bnxt_ulp_resource_resv_list_get(uint32_t *num_entries);
 298
 299int32_t
 300bnxt_ulp_cntxt_ptr2_ha_info_set(struct bnxt_ulp_context *ulp_ctx,
 301                                struct bnxt_ulp_ha_mgr_info *ulp_ha_info);
 302
 303struct bnxt_ulp_ha_mgr_info *
 304bnxt_ulp_cntxt_ptr2_ha_info_get(struct bnxt_ulp_context *ulp_ctx);
 305
 306bool
 307bnxt_ulp_cntxt_ha_enabled(struct bnxt_ulp_context *ulp_ctx);
 308
 309struct bnxt_ulp_context *
 310bnxt_ulp_cntxt_entry_acquire(void *arg);
 311
 312void
 313bnxt_ulp_cntxt_entry_release(void);
 314
 315uint8_t
 316bnxt_ulp_cntxt_num_shared_clients_get(struct bnxt_ulp_context *ulp_ctx);
 317
 318struct bnxt_flow_app_tun_ent *
 319bnxt_ulp_cntxt_ptr2_app_tun_list_get(struct bnxt_ulp_context *ulp);
 320
 321#endif /* _BNXT_ULP_H_ */
 322