linux/include/linux/qed/qed_eth_if.h
<<
>>
Prefs
   1/* QLogic qed NIC Driver
   2 * Copyright (c) 2015-2017  QLogic Corporation
   3 *
   4 * This software is available to you under a choice of one of two
   5 * licenses.  You may choose to be licensed under the terms of the GNU
   6 * General Public License (GPL) Version 2, available from the file
   7 * COPYING in the main directory of this source tree, or the
   8 * OpenIB.org BSD license below:
   9 *
  10 *     Redistribution and use in source and binary forms, with or
  11 *     without modification, are permitted provided that the following
  12 *     conditions are met:
  13 *
  14 *      - Redistributions of source code must retain the above
  15 *        copyright notice, this list of conditions and the following
  16 *        disclaimer.
  17 *
  18 *      - Redistributions in binary form must reproduce the above
  19 *        copyright notice, this list of conditions and the following
  20 *        disclaimer in the documentation and /or other materials
  21 *        provided with the distribution.
  22 *
  23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30 * SOFTWARE.
  31 */
  32
  33#ifndef _QED_ETH_IF_H
  34#define _QED_ETH_IF_H
  35
  36#include <linux/list.h>
  37#include <linux/if_link.h>
  38#include <linux/qed/eth_common.h>
  39#include <linux/qed/qed_if.h>
  40#include <linux/qed/qed_iov_if.h>
  41
  42struct qed_queue_start_common_params {
  43        /* Should always be relative to entity sending this. */
  44        u8 vport_id;
  45        u16 queue_id;
  46
  47        /* Relative, but relevant only for PFs */
  48        u8 stats_id;
  49
  50        struct qed_sb_info *p_sb;
  51        u8 sb_idx;
  52};
  53
  54struct qed_rxq_start_ret_params {
  55        void __iomem *p_prod;
  56        void *p_handle;
  57};
  58
  59struct qed_txq_start_ret_params {
  60        void __iomem *p_doorbell;
  61        void *p_handle;
  62};
  63
  64enum qed_filter_config_mode {
  65        QED_FILTER_CONFIG_MODE_DISABLE,
  66        QED_FILTER_CONFIG_MODE_5_TUPLE,
  67        QED_FILTER_CONFIG_MODE_L4_PORT,
  68        QED_FILTER_CONFIG_MODE_IP_DEST,
  69};
  70
  71struct qed_ntuple_filter_params {
  72        /* Physically mapped address containing header of buffer to be used
  73         * as filter.
  74         */
  75        dma_addr_t addr;
  76
  77        /* Length of header in bytes */
  78        u16 length;
  79
  80        /* Relative queue-id to receive classified packet */
  81#define QED_RFS_NTUPLE_QID_RSS ((u16)-1)
  82        u16 qid;
  83
  84        /* Identifier can either be according to vport-id or vfid */
  85        bool b_is_vf;
  86        u8 vport_id;
  87        u8 vf_id;
  88
  89        /* true iff this filter is to be added. Else to be removed */
  90        bool b_is_add;
  91};
  92
  93struct qed_dev_eth_info {
  94        struct qed_dev_info common;
  95
  96        u8      num_queues;
  97        u8      num_tc;
  98
  99        u8      port_mac[ETH_ALEN];
 100        u16     num_vlan_filters;
 101        u16     num_mac_filters;
 102
 103        /* Legacy VF - this affects the datapath, so qede has to know */
 104        bool is_legacy;
 105};
 106
 107struct qed_update_vport_rss_params {
 108        void    *rss_ind_table[128];
 109        u32     rss_key[10];
 110        u8      rss_caps;
 111};
 112
 113struct qed_update_vport_params {
 114        u8 vport_id;
 115        u8 update_vport_active_flg;
 116        u8 vport_active_flg;
 117        u8 update_tx_switching_flg;
 118        u8 tx_switching_flg;
 119        u8 update_accept_any_vlan_flg;
 120        u8 accept_any_vlan;
 121        u8 update_rss_flg;
 122        struct qed_update_vport_rss_params rss_params;
 123};
 124
 125struct qed_start_vport_params {
 126        bool remove_inner_vlan;
 127        bool handle_ptp_pkts;
 128        bool gro_enable;
 129        bool drop_ttl0;
 130        u8 vport_id;
 131        u16 mtu;
 132        bool clear_stats;
 133};
 134
 135enum qed_filter_rx_mode_type {
 136        QED_FILTER_RX_MODE_TYPE_REGULAR,
 137        QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC,
 138        QED_FILTER_RX_MODE_TYPE_PROMISC,
 139};
 140
 141enum qed_filter_xcast_params_type {
 142        QED_FILTER_XCAST_TYPE_ADD,
 143        QED_FILTER_XCAST_TYPE_DEL,
 144        QED_FILTER_XCAST_TYPE_REPLACE,
 145};
 146
 147struct qed_filter_ucast_params {
 148        enum qed_filter_xcast_params_type type;
 149        u8 vlan_valid;
 150        u16 vlan;
 151        u8 mac_valid;
 152        unsigned char mac[ETH_ALEN];
 153};
 154
 155struct qed_filter_mcast_params {
 156        enum qed_filter_xcast_params_type type;
 157        u8 num;
 158        unsigned char mac[64][ETH_ALEN];
 159};
 160
 161union qed_filter_type_params {
 162        enum qed_filter_rx_mode_type accept_flags;
 163        struct qed_filter_ucast_params ucast;
 164        struct qed_filter_mcast_params mcast;
 165};
 166
 167enum qed_filter_type {
 168        QED_FILTER_TYPE_UCAST,
 169        QED_FILTER_TYPE_MCAST,
 170        QED_FILTER_TYPE_RX_MODE,
 171        QED_MAX_FILTER_TYPES,
 172};
 173
 174struct qed_filter_params {
 175        enum qed_filter_type type;
 176        union qed_filter_type_params filter;
 177};
 178
 179struct qed_tunn_params {
 180        u16 vxlan_port;
 181        u8 update_vxlan_port;
 182        u16 geneve_port;
 183        u8 update_geneve_port;
 184};
 185
 186struct qed_eth_cb_ops {
 187        struct qed_common_cb_ops common;
 188        void (*force_mac) (void *dev, u8 *mac, bool forced);
 189        void (*ports_update)(void *dev, u16 vxlan_port, u16 geneve_port);
 190};
 191
 192#define QED_MAX_PHC_DRIFT_PPB   291666666
 193
 194enum qed_ptp_filter_type {
 195        QED_PTP_FILTER_NONE,
 196        QED_PTP_FILTER_ALL,
 197        QED_PTP_FILTER_V1_L4_EVENT,
 198        QED_PTP_FILTER_V1_L4_GEN,
 199        QED_PTP_FILTER_V2_L4_EVENT,
 200        QED_PTP_FILTER_V2_L4_GEN,
 201        QED_PTP_FILTER_V2_L2_EVENT,
 202        QED_PTP_FILTER_V2_L2_GEN,
 203        QED_PTP_FILTER_V2_EVENT,
 204        QED_PTP_FILTER_V2_GEN
 205};
 206
 207enum qed_ptp_hwtstamp_tx_type {
 208        QED_PTP_HWTSTAMP_TX_OFF,
 209        QED_PTP_HWTSTAMP_TX_ON,
 210};
 211
 212#ifdef CONFIG_DCB
 213/* Prototype declaration of qed_eth_dcbnl_ops should match with the declaration
 214 * of dcbnl_rtnl_ops structure.
 215 */
 216struct qed_eth_dcbnl_ops {
 217        /* IEEE 802.1Qaz std */
 218        int (*ieee_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
 219        int (*ieee_setpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
 220        int (*ieee_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
 221        int (*ieee_setets)(struct qed_dev *cdev, struct ieee_ets *ets);
 222        int (*ieee_peer_getets)(struct qed_dev *cdev, struct ieee_ets *ets);
 223        int (*ieee_peer_getpfc)(struct qed_dev *cdev, struct ieee_pfc *pfc);
 224        int (*ieee_getapp)(struct qed_dev *cdev, struct dcb_app *app);
 225        int (*ieee_setapp)(struct qed_dev *cdev, struct dcb_app *app);
 226
 227        /* CEE std */
 228        u8 (*getstate)(struct qed_dev *cdev);
 229        u8 (*setstate)(struct qed_dev *cdev, u8 state);
 230        void (*getpgtccfgtx)(struct qed_dev *cdev, int prio, u8 *prio_type,
 231                             u8 *pgid, u8 *bw_pct, u8 *up_map);
 232        void (*getpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
 233        void (*getpgtccfgrx)(struct qed_dev *cdev, int prio, u8 *prio_type,
 234                             u8 *pgid, u8 *bw_pct, u8 *up_map);
 235        void (*getpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 *bw_pct);
 236        void (*getpfccfg)(struct qed_dev *cdev, int prio, u8 *setting);
 237        void (*setpfccfg)(struct qed_dev *cdev, int prio, u8 setting);
 238        u8 (*getcap)(struct qed_dev *cdev, int capid, u8 *cap);
 239        int (*getnumtcs)(struct qed_dev *cdev, int tcid, u8 *num);
 240        u8 (*getpfcstate)(struct qed_dev *cdev);
 241        int (*getapp)(struct qed_dev *cdev, u8 idtype, u16 id);
 242        u8 (*getfeatcfg)(struct qed_dev *cdev, int featid, u8 *flags);
 243
 244        /* DCBX configuration */
 245        u8 (*getdcbx)(struct qed_dev *cdev);
 246        void (*setpgtccfgtx)(struct qed_dev *cdev, int prio,
 247                             u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
 248        void (*setpgtccfgrx)(struct qed_dev *cdev, int prio,
 249                             u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map);
 250        void (*setpgbwgcfgtx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
 251        void (*setpgbwgcfgrx)(struct qed_dev *cdev, int pgid, u8 bw_pct);
 252        u8 (*setall)(struct qed_dev *cdev);
 253        int (*setnumtcs)(struct qed_dev *cdev, int tcid, u8 num);
 254        void (*setpfcstate)(struct qed_dev *cdev, u8 state);
 255        int (*setapp)(struct qed_dev *cdev, u8 idtype, u16 idval, u8 up);
 256        u8 (*setdcbx)(struct qed_dev *cdev, u8 state);
 257        u8 (*setfeatcfg)(struct qed_dev *cdev, int featid, u8 flags);
 258
 259        /* Peer apps */
 260        int (*peer_getappinfo)(struct qed_dev *cdev,
 261                               struct dcb_peer_app_info *info,
 262                               u16 *app_count);
 263        int (*peer_getapptable)(struct qed_dev *cdev, struct dcb_app *table);
 264
 265        /* CEE peer */
 266        int (*cee_peer_getpfc)(struct qed_dev *cdev, struct cee_pfc *pfc);
 267        int (*cee_peer_getpg)(struct qed_dev *cdev, struct cee_pg *pg);
 268};
 269#endif
 270
 271struct qed_eth_ptp_ops {
 272        int (*cfg_filters)(struct qed_dev *, enum qed_ptp_filter_type,
 273                           enum qed_ptp_hwtstamp_tx_type);
 274        int (*read_rx_ts)(struct qed_dev *, u64 *);
 275        int (*read_tx_ts)(struct qed_dev *, u64 *);
 276        int (*read_cc)(struct qed_dev *, u64 *);
 277        int (*disable)(struct qed_dev *);
 278        int (*adjfreq)(struct qed_dev *, s32);
 279        int (*enable)(struct qed_dev *);
 280};
 281
 282struct qed_eth_ops {
 283        const struct qed_common_ops *common;
 284#ifdef CONFIG_QED_SRIOV
 285        const struct qed_iov_hv_ops *iov;
 286#endif
 287#ifdef CONFIG_DCB
 288        const struct qed_eth_dcbnl_ops *dcb;
 289#endif
 290        const struct qed_eth_ptp_ops *ptp;
 291
 292        int (*fill_dev_info)(struct qed_dev *cdev,
 293                             struct qed_dev_eth_info *info);
 294
 295        void (*register_ops)(struct qed_dev *cdev,
 296                             struct qed_eth_cb_ops *ops,
 297                             void *cookie);
 298
 299         bool(*check_mac) (struct qed_dev *cdev, u8 *mac);
 300
 301        int (*vport_start)(struct qed_dev *cdev,
 302                           struct qed_start_vport_params *params);
 303
 304        int (*vport_stop)(struct qed_dev *cdev,
 305                          u8 vport_id);
 306
 307        int (*vport_update)(struct qed_dev *cdev,
 308                            struct qed_update_vport_params *params);
 309
 310        int (*q_rx_start)(struct qed_dev *cdev,
 311                          u8 rss_num,
 312                          struct qed_queue_start_common_params *params,
 313                          u16 bd_max_bytes,
 314                          dma_addr_t bd_chain_phys_addr,
 315                          dma_addr_t cqe_pbl_addr,
 316                          u16 cqe_pbl_size,
 317                          struct qed_rxq_start_ret_params *ret_params);
 318
 319        int (*q_rx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
 320
 321        int (*q_tx_start)(struct qed_dev *cdev,
 322                          u8 rss_num,
 323                          struct qed_queue_start_common_params *params,
 324                          dma_addr_t pbl_addr,
 325                          u16 pbl_size,
 326                          struct qed_txq_start_ret_params *ret_params);
 327
 328        int (*q_tx_stop)(struct qed_dev *cdev, u8 rss_id, void *handle);
 329
 330        int (*filter_config)(struct qed_dev *cdev,
 331                             struct qed_filter_params *params);
 332
 333        int (*fastpath_stop)(struct qed_dev *cdev);
 334
 335        int (*eth_cqe_completion)(struct qed_dev *cdev,
 336                                  u8 rss_id,
 337                                  struct eth_slow_path_rx_cqe *cqe);
 338
 339        void (*get_vport_stats)(struct qed_dev *cdev,
 340                                struct qed_eth_stats *stats);
 341
 342        int (*tunn_config)(struct qed_dev *cdev,
 343                           struct qed_tunn_params *params);
 344
 345        int (*ntuple_filter_config)(struct qed_dev *cdev,
 346                                    void *cookie,
 347                                    struct qed_ntuple_filter_params *params);
 348
 349        int (*configure_arfs_searcher)(struct qed_dev *cdev,
 350                                       enum qed_filter_config_mode mode);
 351        int (*get_coalesce)(struct qed_dev *cdev, u16 *coal, void *handle);
 352        int (*req_bulletin_update_mac)(struct qed_dev *cdev, u8 *mac);
 353};
 354
 355const struct qed_eth_ops *qed_get_eth_ops(void);
 356void qed_put_eth_ops(void);
 357
 358#endif
 359