dpdk/drivers/net/dpaa2/mc/fsl_dpdmux.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
   2 *
   3 * Copyright 2013-2016 Freescale Semiconductor Inc.
   4 * Copyright 2018-2019 NXP
   5 *
   6 */
   7#ifndef __FSL_DPDMUX_H
   8#define __FSL_DPDMUX_H
   9
  10#include <fsl_net.h>
  11
  12struct fsl_mc_io;
  13
  14/** @addtogroup dpdmux Data Path Demux API
  15 * Contains API for handling DPDMUX topology and functionality
  16 * @{
  17 */
  18
  19int dpdmux_open(struct fsl_mc_io *mc_io,
  20                uint32_t  cmd_flags,
  21                int  dpdmux_id,
  22                uint16_t  *token);
  23
  24int dpdmux_close(struct fsl_mc_io *mc_io,
  25                 uint32_t cmd_flags,
  26                 uint16_t token);
  27
  28/**
  29 * DPDMUX general options
  30 */
  31
  32/**
  33 * Enable bridging between internal interfaces
  34 */
  35#define DPDMUX_OPT_BRIDGE_EN    0x0000000000000002ULL
  36
  37/**
  38 * Mask support for classification
  39 */
  40#define DPDMUX_OPT_CLS_MASK_SUPPORT             0x0000000000000020ULL
  41
  42#define DPDMUX_IRQ_INDEX_IF     0x0000
  43#define DPDMUX_IRQ_INDEX        0x0001
  44
  45/**
  46 * IRQ event - Indicates that the link state changed
  47 */
  48#define DPDMUX_IRQ_EVENT_LINK_CHANGED   0x0001
  49
  50/**
  51 * enum dpdmux_manip - DPDMUX manipulation operations
  52 * @DPDMUX_MANIP_NONE:  No manipulation on frames
  53 * @DPDMUX_MANIP_ADD_REMOVE_S_VLAN: Add S-VLAN on egress, remove it on ingress
  54 */
  55enum dpdmux_manip {
  56        DPDMUX_MANIP_NONE = 0x0,
  57        DPDMUX_MANIP_ADD_REMOVE_S_VLAN = 0x1
  58};
  59
  60/**
  61 * enum dpdmux_method - DPDMUX method options
  62 * @DPDMUX_METHOD_NONE: no DPDMUX method
  63 * @DPDMUX_METHOD_C_VLAN_MAC: DPDMUX based on C-VLAN and MAC address
  64 * @DPDMUX_METHOD_MAC: DPDMUX based on MAC address
  65 * @DPDMUX_METHOD_C_VLAN: DPDMUX based on C-VLAN
  66 * @DPDMUX_METHOD_S_VLAN: DPDMUX based on S-VLAN
  67 */
  68enum dpdmux_method {
  69        DPDMUX_METHOD_NONE = 0x0,
  70        DPDMUX_METHOD_C_VLAN_MAC = 0x1,
  71        DPDMUX_METHOD_MAC = 0x2,
  72        DPDMUX_METHOD_C_VLAN = 0x3,
  73        DPDMUX_METHOD_S_VLAN = 0x4,
  74        DPDMUX_METHOD_CUSTOM = 0x5,
  75};
  76
  77/**
  78 * struct dpdmux_cfg - DPDMUX configuration parameters
  79 * @method: Defines the operation method for the DPDMUX address table
  80 * @manip: Required manipulation operation
  81 * @num_ifs: Number of interfaces (excluding the uplink interface)
  82 * @adv: Advanced parameters; default is all zeros;
  83 *      use this structure to change default settings
  84 * @adv.options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags.
  85 * @adv.max_dmat_entries: Maximum entries in DPDMUX address table
  86 *      0 - indicates default: 64 entries per interface.
  87 * @adv.max_mc_groups: Number of multicast groups in DPDMUX table
  88 *      0 - indicates default: 32 multicast groups.
  89 * @adv.max_vlan_ids: Maximum vlan ids allowed in the system -
  90 *      relevant only case of working in mac+vlan method.
  91 *      0 - indicates default 16 vlan ids.
  92 */
  93struct dpdmux_cfg {
  94        enum dpdmux_method method;
  95        enum dpdmux_manip manip;
  96        uint16_t num_ifs;
  97        struct {
  98                uint64_t options;
  99                uint16_t max_dmat_entries;
 100                uint16_t max_mc_groups;
 101                uint16_t max_vlan_ids;
 102        } adv;
 103};
 104
 105int dpdmux_create(struct fsl_mc_io *mc_io,
 106                  uint16_t dprc_token,
 107                  uint32_t cmd_flags,
 108                  const struct dpdmux_cfg *cfg,
 109                  uint32_t *obj_id);
 110
 111int dpdmux_destroy(struct fsl_mc_io *mc_io,
 112                   uint16_t dprc_token,
 113                   uint32_t cmd_flags,
 114                   uint32_t object_id);
 115
 116int dpdmux_enable(struct fsl_mc_io *mc_io,
 117                  uint32_t cmd_flags,
 118                  uint16_t token);
 119
 120int dpdmux_disable(struct fsl_mc_io *mc_io,
 121                   uint32_t cmd_flags,
 122                   uint16_t token);
 123
 124int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
 125                      uint32_t cmd_flags,
 126                      uint16_t token,
 127                      int *en);
 128
 129int dpdmux_reset(struct fsl_mc_io *mc_io,
 130                 uint32_t cmd_flags,
 131                 uint16_t token);
 132
 133/**
 134 * struct dpdmux_attr - Structure representing DPDMUX attributes
 135 * @id: DPDMUX object ID
 136 * @options: Configuration options (bitmap)
 137 * @method: DPDMUX address table method
 138 * @manip: DPDMUX manipulation type
 139 * @num_ifs: Number of interfaces (excluding the uplink interface)
 140 * @mem_size: DPDMUX frame storage memory size
 141 */
 142struct dpdmux_attr {
 143        int id;
 144        uint64_t options;
 145        enum dpdmux_method method;
 146        enum dpdmux_manip manip;
 147        uint16_t num_ifs;
 148        uint16_t mem_size;
 149};
 150
 151int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
 152                          uint32_t cmd_flags,
 153                          uint16_t token,
 154                          struct dpdmux_attr *attr);
 155
 156int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
 157                                uint32_t cmd_flags,
 158                                uint16_t token,
 159                                uint16_t max_frame_length);
 160
 161/**
 162 * enum dpdmux_counter_type - Counter types
 163 * @DPDMUX_CNT_ING_FRAME: Counts ingress frames
 164 * @DPDMUX_CNT_ING_BYTE: Counts ingress bytes
 165 * @DPDMUX_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
 166 * @DPDMUX_CNT_ING_FRAME_DISCARD: Counts discarded ingress frames
 167 * @DPDMUX_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
 168 * @DPDMUX_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
 169 * @DPDMUX_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
 170 * @DPDMUX_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
 171 * @DPDMUX_CNT_EGR_FRAME: Counts egress frames
 172 * @DPDMUX_CNT_EGR_BYTE: Counts egress bytes
 173 * @DPDMUX_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
 174 */
 175enum dpdmux_counter_type {
 176        DPDMUX_CNT_ING_FRAME = 0x0,
 177        DPDMUX_CNT_ING_BYTE = 0x1,
 178        DPDMUX_CNT_ING_FLTR_FRAME = 0x2,
 179        DPDMUX_CNT_ING_FRAME_DISCARD = 0x3,
 180        DPDMUX_CNT_ING_MCAST_FRAME = 0x4,
 181        DPDMUX_CNT_ING_MCAST_BYTE = 0x5,
 182        DPDMUX_CNT_ING_BCAST_FRAME = 0x6,
 183        DPDMUX_CNT_ING_BCAST_BYTES = 0x7,
 184        DPDMUX_CNT_EGR_FRAME = 0x8,
 185        DPDMUX_CNT_EGR_BYTE = 0x9,
 186        DPDMUX_CNT_EGR_FRAME_DISCARD = 0xa
 187};
 188
 189/**
 190 * enum dpdmux_accepted_frames_type - DPDMUX frame types
 191 * @DPDMUX_ADMIT_ALL: The device accepts VLAN tagged, untagged and
 192 *                      priority-tagged frames
 193 * @DPDMUX_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
 194 *                              priority-tagged frames that are received on this
 195 *                              interface
 196 * @DPDMUX_ADMIT_ONLY_UNTAGGED: Untagged frames or priority-tagged frames
 197 *                              received on this interface are accepted
 198 */
 199enum dpdmux_accepted_frames_type {
 200        DPDMUX_ADMIT_ALL = 0,
 201        DPDMUX_ADMIT_ONLY_VLAN_TAGGED = 1,
 202        DPDMUX_ADMIT_ONLY_UNTAGGED = 2
 203};
 204
 205/**
 206 * enum dpdmux_action - DPDMUX action for un-accepted frames
 207 * @DPDMUX_ACTION_DROP: Drop un-accepted frames
 208 * @DPDMUX_ACTION_REDIRECT_TO_CTRL: Redirect un-accepted frames to the
 209 *                                      control interface
 210 */
 211enum dpdmux_action {
 212        DPDMUX_ACTION_DROP = 0,
 213        DPDMUX_ACTION_REDIRECT_TO_CTRL = 1
 214};
 215
 216/**
 217 * struct dpdmux_accepted_frames - Frame types configuration
 218 * @type: Defines ingress accepted frames
 219 * @unaccept_act: Defines action on frames not accepted
 220 */
 221struct dpdmux_accepted_frames {
 222        enum dpdmux_accepted_frames_type type;
 223        enum dpdmux_action unaccept_act;
 224};
 225
 226int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
 227                                  uint32_t cmd_flags,
 228                                  uint16_t token,
 229                                  uint16_t if_id,
 230                                  const struct dpdmux_accepted_frames *cfg);
 231
 232/**
 233 * struct dpdmux_if_attr - Structure representing frame types configuration
 234 * @rate: Configured interface rate (in bits per second)
 235 * @enabled: Indicates if interface is enabled
 236 * @accept_frame_type: Indicates type of accepted frames for the interface
 237 */
 238struct dpdmux_if_attr {
 239        uint32_t rate;
 240        int enabled;
 241        int is_default;
 242        enum dpdmux_accepted_frames_type accept_frame_type;
 243};
 244
 245int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
 246                             uint32_t cmd_flags,
 247                             uint16_t token,
 248                             uint16_t if_id,
 249                             struct dpdmux_if_attr *attr);
 250
 251int dpdmux_if_enable(struct fsl_mc_io *mc_io,
 252                     uint32_t cmd_flags,
 253                     uint16_t token,
 254                     uint16_t if_id);
 255
 256int dpdmux_if_disable(struct fsl_mc_io *mc_io,
 257                      uint32_t cmd_flags,
 258                      uint16_t token,
 259                      uint16_t if_id);
 260
 261/**
 262 * struct dpdmux_l2_rule - Structure representing L2 rule
 263 * @mac_addr: MAC address
 264 * @vlan_id: VLAN ID
 265 */
 266struct dpdmux_l2_rule {
 267        uint8_t mac_addr[6];
 268        uint16_t vlan_id;
 269};
 270
 271int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
 272                             uint32_t cmd_flags,
 273                             uint16_t token,
 274                             uint16_t if_id,
 275                             const struct dpdmux_l2_rule *rule);
 276
 277int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
 278                          uint32_t cmd_flags,
 279                          uint16_t token,
 280                          uint16_t if_id,
 281                          const struct dpdmux_l2_rule *rule);
 282
 283int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
 284                          uint32_t cmd_flags,
 285                          uint16_t token,
 286                          uint16_t if_id,
 287                          enum dpdmux_counter_type counter_type,
 288                          uint64_t *counter);
 289
 290int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
 291                             uint32_t cmd_flags,
 292                             uint16_t token);
 293
 294/**
 295 * Enable auto-negotiation
 296 */
 297#define DPDMUX_LINK_OPT_AUTONEG         0x0000000000000001ULL
 298/**
 299 * Enable half-duplex mode
 300 */
 301#define DPDMUX_LINK_OPT_HALF_DUPLEX     0x0000000000000002ULL
 302/**
 303 * Enable pause frames
 304 */
 305#define DPDMUX_LINK_OPT_PAUSE           0x0000000000000004ULL
 306/**
 307 * Enable a-symmetric pause frames
 308 */
 309#define DPDMUX_LINK_OPT_ASYM_PAUSE      0x0000000000000008ULL
 310
 311/**
 312 * struct dpdmux_link_cfg - Structure representing DPDMUX link configuration
 313 * @rate: Rate
 314 * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
 315 */
 316struct dpdmux_link_cfg {
 317        uint32_t rate;
 318        uint64_t options;
 319        uint64_t advertising;
 320};
 321
 322int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
 323                           uint32_t cmd_flags,
 324                           uint16_t token,
 325                           uint16_t if_id,
 326                           struct dpdmux_link_cfg *cfg);
 327/**
 328 * struct dpdmux_link_state - Structure representing DPDMUX link state
 329 * @rate: Rate
 330 * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
 331 * @up: 0 - down, 1 - up
 332 * @state_valid: Ignore/Update the state of the link
 333 * @supported: Speeds capability of the phy (bitmap)
 334 * @advertising: Speeds that are advertised for autoneg (bitmap)
 335 */
 336struct dpdmux_link_state {
 337        uint32_t rate;
 338        uint64_t options;
 339        int      up;
 340        int      state_valid;
 341        uint64_t supported;
 342        uint64_t advertising;
 343};
 344
 345int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
 346                             uint32_t cmd_flags,
 347                             uint16_t token,
 348                             uint16_t if_id,
 349                             struct dpdmux_link_state *state);
 350
 351int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
 352                uint32_t cmd_flags,
 353                uint16_t token,
 354                uint16_t if_id);
 355
 356int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
 357                uint32_t cmd_flags,
 358                uint16_t token,
 359                uint16_t *if_id);
 360
 361int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
 362                        uint32_t cmd_flags,
 363                        uint16_t token,
 364                        uint64_t key_cfg_iova);
 365
 366/**
 367 * struct dpdmux_rule_cfg - Custom classification rule.
 368 *
 369 * @key_iova: DMA address of buffer storing the look-up value
 370 * @mask_iova: DMA address of the mask used for TCAM classification
 371 * @key_size: size, in bytes, of the look-up value. This must match the size
 372 *      of the look-up key defined using dpdmux_set_custom_key, otherwise the
 373 *      entry will never be hit
 374 */
 375struct dpdmux_rule_cfg {
 376        uint64_t key_iova;
 377        uint64_t mask_iova;
 378        uint8_t key_size;
 379};
 380
 381/**
 382 * struct dpdmux_cls_action - Action to execute for frames matching the
 383 *      classification entry
 384 *
 385 * @dest_if: Interface to forward the frames to. Port numbering is similar to
 386 *      the one used to connect interfaces:
 387 *      - 0 is the uplink port,
 388 *      - all others are downlink ports.
 389 */
 390struct dpdmux_cls_action {
 391        uint16_t dest_if;
 392};
 393
 394int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
 395                uint32_t cmd_flags,
 396                uint16_t token,
 397                struct dpdmux_rule_cfg *rule,
 398                struct dpdmux_cls_action *action);
 399
 400int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
 401                uint32_t cmd_flags,
 402                uint16_t token,
 403                struct dpdmux_rule_cfg *rule);
 404
 405int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
 406                           uint32_t cmd_flags,
 407                           uint16_t *major_ver,
 408                           uint16_t *minor_ver);
 409
 410#endif /* __FSL_DPDMUX_H */
 411