dpdk/drivers/net/thunderx/base/nicvf_mbox.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: BSD-3-Clause
   2 * Copyright(c) 2016 Cavium, Inc
   3 */
   4
   5#ifndef __THUNDERX_NICVF_MBOX__
   6#define __THUNDERX_NICVF_MBOX__
   7
   8#include <stdint.h>
   9
  10#include "nicvf_plat.h"
  11#include "../nicvf_struct.h"
  12
  13/* PF <--> VF Mailbox communication
  14 * Two 64bit registers are shared between PF and VF for each VF
  15 * Writing into second register means end of message.
  16 */
  17
  18/* PF <--> VF mailbox communication */
  19#define NIC_PF_VF_MAILBOX_SIZE          2
  20#define NIC_MBOX_MSG_TIMEOUT            2000    /* ms */
  21
  22/* Mailbox message types */
  23#define NIC_MBOX_MSG_INVALID            0x00    /* Invalid message */
  24#define NIC_MBOX_MSG_READY              0x01    /* Is PF ready to rcv msgs */
  25#define NIC_MBOX_MSG_ACK                0x02    /* ACK the message received */
  26#define NIC_MBOX_MSG_NACK               0x03    /* NACK the message received */
  27#define NIC_MBOX_MSG_QS_CFG             0x04    /* Configure Qset */
  28#define NIC_MBOX_MSG_RQ_CFG             0x05    /* Configure receive queue */
  29#define NIC_MBOX_MSG_SQ_CFG             0x06    /* Configure Send queue */
  30#define NIC_MBOX_MSG_RQ_DROP_CFG        0x07    /* Configure receive queue */
  31#define NIC_MBOX_MSG_SET_MAC            0x08    /* Add MAC ID to DMAC filter */
  32#define NIC_MBOX_MSG_SET_MAX_FRS        0x09    /* Set max frame size */
  33#define NIC_MBOX_MSG_CPI_CFG            0x0A    /* Config CPI, RSSI */
  34#define NIC_MBOX_MSG_RSS_SIZE           0x0B    /* Get RSS indir_tbl size */
  35#define NIC_MBOX_MSG_RSS_CFG            0x0C    /* Config RSS table */
  36#define NIC_MBOX_MSG_RSS_CFG_CONT       0x0D    /* RSS config continuation */
  37#define NIC_MBOX_MSG_RQ_BP_CFG          0x0E    /* RQ backpressure config */
  38#define NIC_MBOX_MSG_RQ_SW_SYNC         0x0F    /* Flush inflight pkts to RQ */
  39#define NIC_MBOX_MSG_BGX_LINK_CHANGE    0x11    /* BGX:LMAC link status */
  40#define NIC_MBOX_MSG_ALLOC_SQS          0x12    /* Allocate secondary Qset */
  41#define NIC_MBOX_MSG_LOOPBACK           0x16    /* Set interface in loopback */
  42#define NIC_MBOX_MSG_RESET_STAT_COUNTER 0x17    /* Reset statistics counters */
  43#define NIC_MBOX_MSG_SET_LINK           0x21    /* Set link up/down */
  44#define NIC_MBOX_MSG_CHANGE_MODE        0x22    /* Change mode */
  45#define NIC_MBOX_MSG_CFG_DONE           0xF0    /* VF configuration done */
  46#define NIC_MBOX_MSG_SHUTDOWN           0xF1    /* VF is being shutdown */
  47#define NIC_MBOX_MSG_RESET_XCAST        0xF2    /* Reset DCAM filtering mode */
  48#define NIC_MBOX_MSG_MAX                0x100   /* Maximum number of messages */
  49
  50/* Get vNIC VF configuration */
  51struct nic_cfg_msg {
  52        uint8_t    msg;
  53        uint8_t    vf_id;
  54        uint8_t    node_id;
  55        bool       tns_mode:1;
  56        bool       sqs_mode:1;
  57        bool       loopback_supported:1;
  58        uint8_t    mac_addr[NICVF_MAC_ADDR_SIZE];
  59};
  60
  61/* Qset configuration */
  62struct qs_cfg_msg {
  63        uint8_t    msg;
  64        uint8_t    num;
  65        uint8_t    sqs_count;
  66        uint64_t   cfg;
  67};
  68
  69/* Receive queue configuration */
  70struct rq_cfg_msg {
  71        uint8_t    msg;
  72        uint8_t    qs_num;
  73        uint8_t    rq_num;
  74        uint64_t   cfg;
  75};
  76
  77/* Send queue configuration */
  78struct sq_cfg_msg {
  79        uint8_t    msg;
  80        uint8_t    qs_num;
  81        uint8_t    sq_num;
  82        bool       sqs_mode;
  83        uint64_t   cfg;
  84};
  85
  86/* Set VF's MAC address */
  87struct set_mac_msg {
  88        uint8_t    msg;
  89        uint8_t    vf_id;
  90        uint8_t    mac_addr[NICVF_MAC_ADDR_SIZE];
  91};
  92
  93/* Set Maximum frame size */
  94struct set_frs_msg {
  95        uint8_t    msg;
  96        uint8_t    vf_id;
  97        uint16_t   max_frs;
  98};
  99
 100/* Set CPI algorithm type */
 101struct cpi_cfg_msg {
 102        uint8_t    msg;
 103        uint8_t    vf_id;
 104        uint8_t    rq_cnt;
 105        uint8_t    cpi_alg;
 106};
 107
 108/* Get RSS table size */
 109struct rss_sz_msg {
 110        uint8_t    msg;
 111        uint8_t    vf_id;
 112        uint16_t   ind_tbl_size;
 113};
 114
 115/* Set RSS configuration */
 116struct rss_cfg_msg {
 117        uint8_t    msg;
 118        uint8_t    vf_id;
 119        uint8_t    hash_bits;
 120        uint8_t    tbl_len;
 121        uint8_t    tbl_offset;
 122#define RSS_IND_TBL_LEN_PER_MBX_MSG     8
 123        uint8_t    ind_tbl[RSS_IND_TBL_LEN_PER_MBX_MSG];
 124};
 125
 126/* Physical interface link status */
 127struct bgx_link_status {
 128        uint8_t    msg;
 129        uint8_t    mac_type;
 130        uint8_t    link_up;
 131        uint8_t    duplex;
 132        uint32_t   speed;
 133};
 134
 135/* Allocate additional SQS to VF */
 136struct sqs_alloc {
 137        uint8_t    msg;
 138        uint8_t    spec;
 139        uint8_t    qs_count;
 140        uint8_t    svf[MAX_SQS_PER_VF];
 141};
 142
 143/* Set interface in loopback mode */
 144struct set_loopback {
 145        uint8_t    msg;
 146        uint8_t    vf_id;
 147        bool       enable;
 148};
 149
 150/* Reset statistics counters */
 151struct reset_stat_cfg {
 152        uint8_t    msg;
 153        /* Bitmap to select NIC_PF_VNIC(vf_id)_RX_STAT(0..13) */
 154        uint16_t   rx_stat_mask;
 155        /* Bitmap to select NIC_PF_VNIC(vf_id)_TX_STAT(0..4) */
 156        uint8_t    tx_stat_mask;
 157        /* Bitmap to select NIC_PF_QS(0..127)_RQ(0..7)_STAT(0..1)
 158         * bit14, bit15 NIC_PF_QS(vf_id)_RQ7_STAT(0..1)
 159         * bit12, bit13 NIC_PF_QS(vf_id)_RQ6_STAT(0..1)
 160         * ..
 161         * bit2, bit3 NIC_PF_QS(vf_id)_RQ1_STAT(0..1)
 162         * bit0, bit1 NIC_PF_QS(vf_id)_RQ0_STAT(0..1)
 163         */
 164        uint16_t   rq_stat_mask;
 165        /* Bitmap to select NIC_PF_QS(0..127)_SQ(0..7)_STAT(0..1)
 166         * bit14, bit15 NIC_PF_QS(vf_id)_SQ7_STAT(0..1)
 167         * bit12, bit13 NIC_PF_QS(vf_id)_SQ6_STAT(0..1)
 168         * ..
 169         * bit2, bit3 NIC_PF_QS(vf_id)_SQ1_STAT(0..1)
 170         * bit0, bit1 NIC_PF_QS(vf_id)_SQ0_STAT(0..1)
 171         */
 172        uint16_t   sq_stat_mask;
 173};
 174
 175/* Set link up/down */
 176struct set_link_state {
 177        uint8_t    msg;
 178        uint8_t    vf_id;
 179        bool       enable;
 180};
 181
 182/* Change link mode */
 183struct change_link_mode_msg {
 184        uint8_t    msg;
 185        uint8_t    vf_id;
 186        uint8_t    qlm_mode;
 187        bool       autoneg;
 188        uint8_t    duplex;
 189        uint32_t   speed;
 190
 191};
 192
 193struct nic_mbx {
 194/* 128 bit shared memory between PF and each VF */
 195union {
 196        struct { uint8_t msg; } msg;
 197        struct nic_cfg_msg      nic_cfg;
 198        struct qs_cfg_msg       qs;
 199        struct rq_cfg_msg       rq;
 200        struct sq_cfg_msg       sq;
 201        struct set_mac_msg      mac;
 202        struct set_frs_msg      frs;
 203        struct cpi_cfg_msg      cpi_cfg;
 204        struct rss_sz_msg       rss_size;
 205        struct rss_cfg_msg      rss_cfg;
 206        struct bgx_link_status  link_status;
 207        struct sqs_alloc        sqs_alloc;
 208        struct set_loopback     lbk;
 209        struct reset_stat_cfg   reset_stat;
 210        struct set_link_state   set_link;
 211        struct change_link_mode_msg mode;
 212};
 213};
 214
 215NICVF_STATIC_ASSERT(sizeof(struct nic_mbx) <= 16);
 216
 217int nicvf_handle_mbx_intr(struct nicvf *nic);
 218int nicvf_mbox_check_pf_ready(struct nicvf *nic);
 219int nicvf_mbox_qset_config(struct nicvf *nic, struct pf_qs_cfg *qs_cfg);
 220int nicvf_mbox_request_sqs(struct nicvf *nic);
 221int nicvf_mbox_rq_config(struct nicvf *nic, uint16_t qidx,
 222                         struct pf_rq_cfg *pf_rq_cfg);
 223int nicvf_mbox_sq_config(struct nicvf *nic, uint16_t qidx);
 224int nicvf_mbox_rq_drop_config(struct nicvf *nic, uint16_t qidx, bool enable);
 225int nicvf_mbox_rq_bp_config(struct nicvf *nic, uint16_t qidx, bool enable);
 226int nicvf_mbox_set_mac_addr(struct nicvf *nic,
 227                            const uint8_t mac[NICVF_MAC_ADDR_SIZE]);
 228int nicvf_mbox_config_cpi(struct nicvf *nic, uint32_t qcnt);
 229int nicvf_mbox_get_rss_size(struct nicvf *nic);
 230int nicvf_mbox_config_rss(struct nicvf *nic);
 231int nicvf_mbox_update_hw_max_frs(struct nicvf *nic, uint16_t mtu);
 232int nicvf_mbox_rq_sync(struct nicvf *nic);
 233int nicvf_mbox_loopback_config(struct nicvf *nic, bool enable);
 234int nicvf_mbox_reset_stat_counters(struct nicvf *nic, uint16_t rx_stat_mask,
 235        uint8_t tx_stat_mask, uint16_t rq_stat_mask, uint16_t sq_stat_mask);
 236int nicvf_mbox_set_link_up_down(struct nicvf *nic, bool enable);
 237void nicvf_mbox_shutdown(struct nicvf *nic);
 238void nicvf_mbox_cfg_done(struct nicvf *nic);
 239void nicvf_mbox_link_change(struct nicvf *nic);
 240void nicvf_mbox_reset_xcast(struct nicvf *nic);
 241int nicvf_mbox_change_mode(struct nicvf *nic, struct change_link_mode *cfg);
 242
 243#endif /* __THUNDERX_NICVF_MBOX__ */
 244