1*4863dea3SSunil Goutham /* 2*4863dea3SSunil Goutham * Copyright (C) 2015 Cavium, Inc. 3*4863dea3SSunil Goutham * 4*4863dea3SSunil Goutham * This program is free software; you can redistribute it and/or modify it 5*4863dea3SSunil Goutham * under the terms of version 2 of the GNU General Public License 6*4863dea3SSunil Goutham * as published by the Free Software Foundation. 7*4863dea3SSunil Goutham */ 8*4863dea3SSunil Goutham 9*4863dea3SSunil Goutham #ifndef NIC_H 10*4863dea3SSunil Goutham #define NIC_H 11*4863dea3SSunil Goutham 12*4863dea3SSunil Goutham #include <linux/netdevice.h> 13*4863dea3SSunil Goutham #include <linux/interrupt.h> 14*4863dea3SSunil Goutham #include "thunder_bgx.h" 15*4863dea3SSunil Goutham 16*4863dea3SSunil Goutham /* PCI device IDs */ 17*4863dea3SSunil Goutham #define PCI_DEVICE_ID_THUNDER_NIC_PF 0xA01E 18*4863dea3SSunil Goutham #define PCI_DEVICE_ID_THUNDER_PASS1_NIC_VF 0x0011 19*4863dea3SSunil Goutham #define PCI_DEVICE_ID_THUNDER_NIC_VF 0xA034 20*4863dea3SSunil Goutham #define PCI_DEVICE_ID_THUNDER_BGX 0xA026 21*4863dea3SSunil Goutham 22*4863dea3SSunil Goutham /* PCI BAR nos */ 23*4863dea3SSunil Goutham #define PCI_CFG_REG_BAR_NUM 0 24*4863dea3SSunil Goutham #define PCI_MSIX_REG_BAR_NUM 4 25*4863dea3SSunil Goutham 26*4863dea3SSunil Goutham /* NIC SRIOV VF count */ 27*4863dea3SSunil Goutham #define MAX_NUM_VFS_SUPPORTED 128 28*4863dea3SSunil Goutham #define DEFAULT_NUM_VF_ENABLED 8 29*4863dea3SSunil Goutham 30*4863dea3SSunil Goutham #define NIC_TNS_BYPASS_MODE 0 31*4863dea3SSunil Goutham #define NIC_TNS_MODE 1 32*4863dea3SSunil Goutham 33*4863dea3SSunil Goutham /* NIC priv flags */ 34*4863dea3SSunil Goutham #define NIC_SRIOV_ENABLED BIT(0) 35*4863dea3SSunil Goutham 36*4863dea3SSunil Goutham /* Min/Max packet size */ 37*4863dea3SSunil Goutham #define NIC_HW_MIN_FRS 64 38*4863dea3SSunil Goutham #define NIC_HW_MAX_FRS 9200 /* 9216 max packet including FCS */ 39*4863dea3SSunil Goutham 40*4863dea3SSunil Goutham /* Max pkinds */ 41*4863dea3SSunil Goutham #define NIC_MAX_PKIND 16 42*4863dea3SSunil Goutham 43*4863dea3SSunil Goutham /* Rx Channels */ 44*4863dea3SSunil Goutham /* Receive channel configuration in TNS bypass mode 45*4863dea3SSunil Goutham * Below is configuration in TNS bypass mode 46*4863dea3SSunil Goutham * BGX0-LMAC0-CHAN0 - VNIC CHAN0 47*4863dea3SSunil Goutham * BGX0-LMAC1-CHAN0 - VNIC CHAN16 48*4863dea3SSunil Goutham * ... 49*4863dea3SSunil Goutham * BGX1-LMAC0-CHAN0 - VNIC CHAN128 50*4863dea3SSunil Goutham * ... 51*4863dea3SSunil Goutham * BGX1-LMAC3-CHAN0 - VNIC CHAN174 52*4863dea3SSunil Goutham */ 53*4863dea3SSunil Goutham #define NIC_INTF_COUNT 2 /* Interfaces btw VNIC and TNS/BGX */ 54*4863dea3SSunil Goutham #define NIC_CHANS_PER_INF 128 55*4863dea3SSunil Goutham #define NIC_MAX_CHANS (NIC_INTF_COUNT * NIC_CHANS_PER_INF) 56*4863dea3SSunil Goutham #define NIC_CPI_COUNT 2048 /* No of channel parse indices */ 57*4863dea3SSunil Goutham 58*4863dea3SSunil Goutham /* TNS bypass mode: 1-1 mapping between VNIC and BGX:LMAC */ 59*4863dea3SSunil Goutham #define NIC_MAX_BGX MAX_BGX_PER_CN88XX 60*4863dea3SSunil Goutham #define NIC_CPI_PER_BGX (NIC_CPI_COUNT / NIC_MAX_BGX) 61*4863dea3SSunil Goutham #define NIC_MAX_CPI_PER_LMAC 64 /* Max when CPI_ALG is IP diffserv */ 62*4863dea3SSunil Goutham #define NIC_RSSI_PER_BGX (NIC_RSSI_COUNT / NIC_MAX_BGX) 63*4863dea3SSunil Goutham 64*4863dea3SSunil Goutham /* Tx scheduling */ 65*4863dea3SSunil Goutham #define NIC_MAX_TL4 1024 66*4863dea3SSunil Goutham #define NIC_MAX_TL4_SHAPERS 256 /* 1 shaper for 4 TL4s */ 67*4863dea3SSunil Goutham #define NIC_MAX_TL3 256 68*4863dea3SSunil Goutham #define NIC_MAX_TL3_SHAPERS 64 /* 1 shaper for 4 TL3s */ 69*4863dea3SSunil Goutham #define NIC_MAX_TL2 64 70*4863dea3SSunil Goutham #define NIC_MAX_TL2_SHAPERS 2 /* 1 shaper for 32 TL2s */ 71*4863dea3SSunil Goutham #define NIC_MAX_TL1 2 72*4863dea3SSunil Goutham 73*4863dea3SSunil Goutham /* TNS bypass mode */ 74*4863dea3SSunil Goutham #define NIC_TL2_PER_BGX 32 75*4863dea3SSunil Goutham #define NIC_TL4_PER_BGX (NIC_MAX_TL4 / NIC_MAX_BGX) 76*4863dea3SSunil Goutham #define NIC_TL4_PER_LMAC (NIC_MAX_TL4 / NIC_CHANS_PER_INF) 77*4863dea3SSunil Goutham 78*4863dea3SSunil Goutham /* NIC VF Interrupts */ 79*4863dea3SSunil Goutham #define NICVF_INTR_CQ 0 80*4863dea3SSunil Goutham #define NICVF_INTR_SQ 1 81*4863dea3SSunil Goutham #define NICVF_INTR_RBDR 2 82*4863dea3SSunil Goutham #define NICVF_INTR_PKT_DROP 3 83*4863dea3SSunil Goutham #define NICVF_INTR_TCP_TIMER 4 84*4863dea3SSunil Goutham #define NICVF_INTR_MBOX 5 85*4863dea3SSunil Goutham #define NICVF_INTR_QS_ERR 6 86*4863dea3SSunil Goutham 87*4863dea3SSunil Goutham #define NICVF_INTR_CQ_SHIFT 0 88*4863dea3SSunil Goutham #define NICVF_INTR_SQ_SHIFT 8 89*4863dea3SSunil Goutham #define NICVF_INTR_RBDR_SHIFT 16 90*4863dea3SSunil Goutham #define NICVF_INTR_PKT_DROP_SHIFT 20 91*4863dea3SSunil Goutham #define NICVF_INTR_TCP_TIMER_SHIFT 21 92*4863dea3SSunil Goutham #define NICVF_INTR_MBOX_SHIFT 22 93*4863dea3SSunil Goutham #define NICVF_INTR_QS_ERR_SHIFT 23 94*4863dea3SSunil Goutham 95*4863dea3SSunil Goutham #define NICVF_INTR_CQ_MASK (0xFF << NICVF_INTR_CQ_SHIFT) 96*4863dea3SSunil Goutham #define NICVF_INTR_SQ_MASK (0xFF << NICVF_INTR_SQ_SHIFT) 97*4863dea3SSunil Goutham #define NICVF_INTR_RBDR_MASK (0x03 << NICVF_INTR_RBDR_SHIFT) 98*4863dea3SSunil Goutham #define NICVF_INTR_PKT_DROP_MASK BIT(NICVF_INTR_PKT_DROP_SHIFT) 99*4863dea3SSunil Goutham #define NICVF_INTR_TCP_TIMER_MASK BIT(NICVF_INTR_TCP_TIMER_SHIFT) 100*4863dea3SSunil Goutham #define NICVF_INTR_MBOX_MASK BIT(NICVF_INTR_MBOX_SHIFT) 101*4863dea3SSunil Goutham #define NICVF_INTR_QS_ERR_MASK BIT(NICVF_INTR_QS_ERR_SHIFT) 102*4863dea3SSunil Goutham 103*4863dea3SSunil Goutham /* MSI-X interrupts */ 104*4863dea3SSunil Goutham #define NIC_PF_MSIX_VECTORS 10 105*4863dea3SSunil Goutham #define NIC_VF_MSIX_VECTORS 20 106*4863dea3SSunil Goutham 107*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC0_SBE 0 108*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC0_DBE 1 109*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC1_SBE 2 110*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC1_DBE 3 111*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC2_SBE 4 112*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC2_DBE 5 113*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC3_SBE 6 114*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_ECC3_DBE 7 115*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_MBOX0 8 116*4863dea3SSunil Goutham #define NIC_PF_INTR_ID_MBOX1 9 117*4863dea3SSunil Goutham 118*4863dea3SSunil Goutham /* Global timer for CQ timer thresh interrupts 119*4863dea3SSunil Goutham * Calculated for SCLK of 700Mhz 120*4863dea3SSunil Goutham * value written should be a 1/16th of what is expected 121*4863dea3SSunil Goutham * 122*4863dea3SSunil Goutham * 1 tick per 0.05usec = value of 2.2 123*4863dea3SSunil Goutham * This 10% would be covered in CQ timer thresh value 124*4863dea3SSunil Goutham */ 125*4863dea3SSunil Goutham #define NICPF_CLK_PER_INT_TICK 2 126*4863dea3SSunil Goutham 127*4863dea3SSunil Goutham struct nicvf_cq_poll { 128*4863dea3SSunil Goutham u8 cq_idx; /* Completion queue index */ 129*4863dea3SSunil Goutham struct napi_struct napi; 130*4863dea3SSunil Goutham }; 131*4863dea3SSunil Goutham 132*4863dea3SSunil Goutham #define NIC_RSSI_COUNT 4096 /* Total no of RSS indices */ 133*4863dea3SSunil Goutham #define NIC_MAX_RSS_HASH_BITS 8 134*4863dea3SSunil Goutham #define NIC_MAX_RSS_IDR_TBL_SIZE (1 << NIC_MAX_RSS_HASH_BITS) 135*4863dea3SSunil Goutham #define RSS_HASH_KEY_SIZE 5 /* 320 bit key */ 136*4863dea3SSunil Goutham 137*4863dea3SSunil Goutham struct nicvf_rss_info { 138*4863dea3SSunil Goutham bool enable; 139*4863dea3SSunil Goutham #define RSS_L2_EXTENDED_HASH_ENA BIT(0) 140*4863dea3SSunil Goutham #define RSS_IP_HASH_ENA BIT(1) 141*4863dea3SSunil Goutham #define RSS_TCP_HASH_ENA BIT(2) 142*4863dea3SSunil Goutham #define RSS_TCP_SYN_DIS BIT(3) 143*4863dea3SSunil Goutham #define RSS_UDP_HASH_ENA BIT(4) 144*4863dea3SSunil Goutham #define RSS_L4_EXTENDED_HASH_ENA BIT(5) 145*4863dea3SSunil Goutham #define RSS_ROCE_ENA BIT(6) 146*4863dea3SSunil Goutham #define RSS_L3_BI_DIRECTION_ENA BIT(7) 147*4863dea3SSunil Goutham #define RSS_L4_BI_DIRECTION_ENA BIT(8) 148*4863dea3SSunil Goutham u64 cfg; 149*4863dea3SSunil Goutham u8 hash_bits; 150*4863dea3SSunil Goutham u16 rss_size; 151*4863dea3SSunil Goutham u8 ind_tbl[NIC_MAX_RSS_IDR_TBL_SIZE]; 152*4863dea3SSunil Goutham u64 key[RSS_HASH_KEY_SIZE]; 153*4863dea3SSunil Goutham } ____cacheline_aligned_in_smp; 154*4863dea3SSunil Goutham 155*4863dea3SSunil Goutham enum rx_stats_reg_offset { 156*4863dea3SSunil Goutham RX_OCTS = 0x0, 157*4863dea3SSunil Goutham RX_UCAST = 0x1, 158*4863dea3SSunil Goutham RX_BCAST = 0x2, 159*4863dea3SSunil Goutham RX_MCAST = 0x3, 160*4863dea3SSunil Goutham RX_RED = 0x4, 161*4863dea3SSunil Goutham RX_RED_OCTS = 0x5, 162*4863dea3SSunil Goutham RX_ORUN = 0x6, 163*4863dea3SSunil Goutham RX_ORUN_OCTS = 0x7, 164*4863dea3SSunil Goutham RX_FCS = 0x8, 165*4863dea3SSunil Goutham RX_L2ERR = 0x9, 166*4863dea3SSunil Goutham RX_DRP_BCAST = 0xa, 167*4863dea3SSunil Goutham RX_DRP_MCAST = 0xb, 168*4863dea3SSunil Goutham RX_DRP_L3BCAST = 0xc, 169*4863dea3SSunil Goutham RX_DRP_L3MCAST = 0xd, 170*4863dea3SSunil Goutham RX_STATS_ENUM_LAST, 171*4863dea3SSunil Goutham }; 172*4863dea3SSunil Goutham 173*4863dea3SSunil Goutham enum tx_stats_reg_offset { 174*4863dea3SSunil Goutham TX_OCTS = 0x0, 175*4863dea3SSunil Goutham TX_UCAST = 0x1, 176*4863dea3SSunil Goutham TX_BCAST = 0x2, 177*4863dea3SSunil Goutham TX_MCAST = 0x3, 178*4863dea3SSunil Goutham TX_DROP = 0x4, 179*4863dea3SSunil Goutham TX_STATS_ENUM_LAST, 180*4863dea3SSunil Goutham }; 181*4863dea3SSunil Goutham 182*4863dea3SSunil Goutham struct nicvf_hw_stats { 183*4863dea3SSunil Goutham u64 rx_bytes_ok; 184*4863dea3SSunil Goutham u64 rx_ucast_frames_ok; 185*4863dea3SSunil Goutham u64 rx_bcast_frames_ok; 186*4863dea3SSunil Goutham u64 rx_mcast_frames_ok; 187*4863dea3SSunil Goutham u64 rx_fcs_errors; 188*4863dea3SSunil Goutham u64 rx_l2_errors; 189*4863dea3SSunil Goutham u64 rx_drop_red; 190*4863dea3SSunil Goutham u64 rx_drop_red_bytes; 191*4863dea3SSunil Goutham u64 rx_drop_overrun; 192*4863dea3SSunil Goutham u64 rx_drop_overrun_bytes; 193*4863dea3SSunil Goutham u64 rx_drop_bcast; 194*4863dea3SSunil Goutham u64 rx_drop_mcast; 195*4863dea3SSunil Goutham u64 rx_drop_l3_bcast; 196*4863dea3SSunil Goutham u64 rx_drop_l3_mcast; 197*4863dea3SSunil Goutham u64 tx_bytes_ok; 198*4863dea3SSunil Goutham u64 tx_ucast_frames_ok; 199*4863dea3SSunil Goutham u64 tx_bcast_frames_ok; 200*4863dea3SSunil Goutham u64 tx_mcast_frames_ok; 201*4863dea3SSunil Goutham u64 tx_drops; 202*4863dea3SSunil Goutham }; 203*4863dea3SSunil Goutham 204*4863dea3SSunil Goutham struct nicvf_drv_stats { 205*4863dea3SSunil Goutham /* Rx */ 206*4863dea3SSunil Goutham u64 rx_frames_ok; 207*4863dea3SSunil Goutham u64 rx_frames_64; 208*4863dea3SSunil Goutham u64 rx_frames_127; 209*4863dea3SSunil Goutham u64 rx_frames_255; 210*4863dea3SSunil Goutham u64 rx_frames_511; 211*4863dea3SSunil Goutham u64 rx_frames_1023; 212*4863dea3SSunil Goutham u64 rx_frames_1518; 213*4863dea3SSunil Goutham u64 rx_frames_jumbo; 214*4863dea3SSunil Goutham u64 rx_drops; 215*4863dea3SSunil Goutham /* Tx */ 216*4863dea3SSunil Goutham u64 tx_frames_ok; 217*4863dea3SSunil Goutham u64 tx_drops; 218*4863dea3SSunil Goutham u64 tx_busy; 219*4863dea3SSunil Goutham u64 tx_tso; 220*4863dea3SSunil Goutham }; 221*4863dea3SSunil Goutham 222*4863dea3SSunil Goutham struct nicvf { 223*4863dea3SSunil Goutham struct net_device *netdev; 224*4863dea3SSunil Goutham struct pci_dev *pdev; 225*4863dea3SSunil Goutham u8 vf_id; 226*4863dea3SSunil Goutham u8 node; 227*4863dea3SSunil Goutham u8 tns_mode; 228*4863dea3SSunil Goutham u16 mtu; 229*4863dea3SSunil Goutham struct queue_set *qs; 230*4863dea3SSunil Goutham void __iomem *reg_base; 231*4863dea3SSunil Goutham bool link_up; 232*4863dea3SSunil Goutham u8 duplex; 233*4863dea3SSunil Goutham u32 speed; 234*4863dea3SSunil Goutham struct page *rb_page; 235*4863dea3SSunil Goutham u32 rb_page_offset; 236*4863dea3SSunil Goutham bool rb_alloc_fail; 237*4863dea3SSunil Goutham bool rb_work_scheduled; 238*4863dea3SSunil Goutham struct delayed_work rbdr_work; 239*4863dea3SSunil Goutham struct tasklet_struct rbdr_task; 240*4863dea3SSunil Goutham struct tasklet_struct qs_err_task; 241*4863dea3SSunil Goutham struct tasklet_struct cq_task; 242*4863dea3SSunil Goutham struct nicvf_cq_poll *napi[8]; 243*4863dea3SSunil Goutham struct nicvf_rss_info rss_info; 244*4863dea3SSunil Goutham u8 cpi_alg; 245*4863dea3SSunil Goutham /* Interrupt coalescing settings */ 246*4863dea3SSunil Goutham u32 cq_coalesce_usecs; 247*4863dea3SSunil Goutham 248*4863dea3SSunil Goutham u32 msg_enable; 249*4863dea3SSunil Goutham struct nicvf_hw_stats stats; 250*4863dea3SSunil Goutham struct nicvf_drv_stats drv_stats; 251*4863dea3SSunil Goutham struct bgx_stats bgx_stats; 252*4863dea3SSunil Goutham struct work_struct reset_task; 253*4863dea3SSunil Goutham 254*4863dea3SSunil Goutham /* MSI-X */ 255*4863dea3SSunil Goutham bool msix_enabled; 256*4863dea3SSunil Goutham u8 num_vec; 257*4863dea3SSunil Goutham struct msix_entry msix_entries[NIC_VF_MSIX_VECTORS]; 258*4863dea3SSunil Goutham char irq_name[NIC_VF_MSIX_VECTORS][20]; 259*4863dea3SSunil Goutham bool irq_allocated[NIC_VF_MSIX_VECTORS]; 260*4863dea3SSunil Goutham 261*4863dea3SSunil Goutham bool pf_ready_to_rcv_msg; 262*4863dea3SSunil Goutham bool pf_acked; 263*4863dea3SSunil Goutham bool pf_nacked; 264*4863dea3SSunil Goutham bool bgx_stats_acked; 265*4863dea3SSunil Goutham } ____cacheline_aligned_in_smp; 266*4863dea3SSunil Goutham 267*4863dea3SSunil Goutham /* PF <--> VF Mailbox communication 268*4863dea3SSunil Goutham * Eight 64bit registers are shared between PF and VF. 269*4863dea3SSunil Goutham * Separate set for each VF. 270*4863dea3SSunil Goutham * Writing '1' into last register mbx7 means end of message. 271*4863dea3SSunil Goutham */ 272*4863dea3SSunil Goutham 273*4863dea3SSunil Goutham /* PF <--> VF mailbox communication */ 274*4863dea3SSunil Goutham #define NIC_PF_VF_MAILBOX_SIZE 2 275*4863dea3SSunil Goutham #define NIC_MBOX_MSG_TIMEOUT 2000 /* ms */ 276*4863dea3SSunil Goutham 277*4863dea3SSunil Goutham /* Mailbox message types */ 278*4863dea3SSunil Goutham #define NIC_MBOX_MSG_READY 0x01 /* Is PF ready to rcv msgs */ 279*4863dea3SSunil Goutham #define NIC_MBOX_MSG_ACK 0x02 /* ACK the message received */ 280*4863dea3SSunil Goutham #define NIC_MBOX_MSG_NACK 0x03 /* NACK the message received */ 281*4863dea3SSunil Goutham #define NIC_MBOX_MSG_QS_CFG 0x04 /* Configure Qset */ 282*4863dea3SSunil Goutham #define NIC_MBOX_MSG_RQ_CFG 0x05 /* Configure receive queue */ 283*4863dea3SSunil Goutham #define NIC_MBOX_MSG_SQ_CFG 0x06 /* Configure Send queue */ 284*4863dea3SSunil Goutham #define NIC_MBOX_MSG_RQ_DROP_CFG 0x07 /* Configure receive queue */ 285*4863dea3SSunil Goutham #define NIC_MBOX_MSG_SET_MAC 0x08 /* Add MAC ID to DMAC filter */ 286*4863dea3SSunil Goutham #define NIC_MBOX_MSG_SET_MAX_FRS 0x09 /* Set max frame size */ 287*4863dea3SSunil Goutham #define NIC_MBOX_MSG_CPI_CFG 0x0A /* Config CPI, RSSI */ 288*4863dea3SSunil Goutham #define NIC_MBOX_MSG_RSS_SIZE 0x0B /* Get RSS indir_tbl size */ 289*4863dea3SSunil Goutham #define NIC_MBOX_MSG_RSS_CFG 0x0C /* Config RSS table */ 290*4863dea3SSunil Goutham #define NIC_MBOX_MSG_RSS_CFG_CONT 0x0D /* RSS config continuation */ 291*4863dea3SSunil Goutham #define NIC_MBOX_MSG_RQ_BP_CFG 0x0E /* RQ backpressure config */ 292*4863dea3SSunil Goutham #define NIC_MBOX_MSG_RQ_SW_SYNC 0x0F /* Flush inflight pkts to RQ */ 293*4863dea3SSunil Goutham #define NIC_MBOX_MSG_BGX_STATS 0x10 /* Get stats from BGX */ 294*4863dea3SSunil Goutham #define NIC_MBOX_MSG_BGX_LINK_CHANGE 0x11 /* BGX:LMAC link status */ 295*4863dea3SSunil Goutham #define NIC_MBOX_MSG_CFG_DONE 0x12 /* VF configuration done */ 296*4863dea3SSunil Goutham #define NIC_MBOX_MSG_SHUTDOWN 0x13 /* VF is being shutdown */ 297*4863dea3SSunil Goutham 298*4863dea3SSunil Goutham struct nic_cfg_msg { 299*4863dea3SSunil Goutham u8 msg; 300*4863dea3SSunil Goutham u8 vf_id; 301*4863dea3SSunil Goutham u8 tns_mode; 302*4863dea3SSunil Goutham u8 node_id; 303*4863dea3SSunil Goutham u64 mac_addr; 304*4863dea3SSunil Goutham }; 305*4863dea3SSunil Goutham 306*4863dea3SSunil Goutham /* Qset configuration */ 307*4863dea3SSunil Goutham struct qs_cfg_msg { 308*4863dea3SSunil Goutham u8 msg; 309*4863dea3SSunil Goutham u8 num; 310*4863dea3SSunil Goutham u64 cfg; 311*4863dea3SSunil Goutham }; 312*4863dea3SSunil Goutham 313*4863dea3SSunil Goutham /* Receive queue configuration */ 314*4863dea3SSunil Goutham struct rq_cfg_msg { 315*4863dea3SSunil Goutham u8 msg; 316*4863dea3SSunil Goutham u8 qs_num; 317*4863dea3SSunil Goutham u8 rq_num; 318*4863dea3SSunil Goutham u64 cfg; 319*4863dea3SSunil Goutham }; 320*4863dea3SSunil Goutham 321*4863dea3SSunil Goutham /* Send queue configuration */ 322*4863dea3SSunil Goutham struct sq_cfg_msg { 323*4863dea3SSunil Goutham u8 msg; 324*4863dea3SSunil Goutham u8 qs_num; 325*4863dea3SSunil Goutham u8 sq_num; 326*4863dea3SSunil Goutham u64 cfg; 327*4863dea3SSunil Goutham }; 328*4863dea3SSunil Goutham 329*4863dea3SSunil Goutham /* Set VF's MAC address */ 330*4863dea3SSunil Goutham struct set_mac_msg { 331*4863dea3SSunil Goutham u8 msg; 332*4863dea3SSunil Goutham u8 vf_id; 333*4863dea3SSunil Goutham u64 addr; 334*4863dea3SSunil Goutham }; 335*4863dea3SSunil Goutham 336*4863dea3SSunil Goutham /* Set Maximum frame size */ 337*4863dea3SSunil Goutham struct set_frs_msg { 338*4863dea3SSunil Goutham u8 msg; 339*4863dea3SSunil Goutham u8 vf_id; 340*4863dea3SSunil Goutham u16 max_frs; 341*4863dea3SSunil Goutham }; 342*4863dea3SSunil Goutham 343*4863dea3SSunil Goutham /* Set CPI algorithm type */ 344*4863dea3SSunil Goutham struct cpi_cfg_msg { 345*4863dea3SSunil Goutham u8 msg; 346*4863dea3SSunil Goutham u8 vf_id; 347*4863dea3SSunil Goutham u8 rq_cnt; 348*4863dea3SSunil Goutham u8 cpi_alg; 349*4863dea3SSunil Goutham }; 350*4863dea3SSunil Goutham 351*4863dea3SSunil Goutham /* Get RSS table size */ 352*4863dea3SSunil Goutham struct rss_sz_msg { 353*4863dea3SSunil Goutham u8 msg; 354*4863dea3SSunil Goutham u8 vf_id; 355*4863dea3SSunil Goutham u16 ind_tbl_size; 356*4863dea3SSunil Goutham }; 357*4863dea3SSunil Goutham 358*4863dea3SSunil Goutham /* Set RSS configuration */ 359*4863dea3SSunil Goutham struct rss_cfg_msg { 360*4863dea3SSunil Goutham u8 msg; 361*4863dea3SSunil Goutham u8 vf_id; 362*4863dea3SSunil Goutham u8 hash_bits; 363*4863dea3SSunil Goutham u8 tbl_len; 364*4863dea3SSunil Goutham u8 tbl_offset; 365*4863dea3SSunil Goutham #define RSS_IND_TBL_LEN_PER_MBX_MSG 8 366*4863dea3SSunil Goutham u8 ind_tbl[RSS_IND_TBL_LEN_PER_MBX_MSG]; 367*4863dea3SSunil Goutham }; 368*4863dea3SSunil Goutham 369*4863dea3SSunil Goutham struct bgx_stats_msg { 370*4863dea3SSunil Goutham u8 msg; 371*4863dea3SSunil Goutham u8 vf_id; 372*4863dea3SSunil Goutham u8 rx; 373*4863dea3SSunil Goutham u8 idx; 374*4863dea3SSunil Goutham u64 stats; 375*4863dea3SSunil Goutham }; 376*4863dea3SSunil Goutham 377*4863dea3SSunil Goutham /* Physical interface link status */ 378*4863dea3SSunil Goutham struct bgx_link_status { 379*4863dea3SSunil Goutham u8 msg; 380*4863dea3SSunil Goutham u8 link_up; 381*4863dea3SSunil Goutham u8 duplex; 382*4863dea3SSunil Goutham u32 speed; 383*4863dea3SSunil Goutham }; 384*4863dea3SSunil Goutham 385*4863dea3SSunil Goutham /* 128 bit shared memory between PF and each VF */ 386*4863dea3SSunil Goutham union nic_mbx { 387*4863dea3SSunil Goutham struct { u8 msg; } msg; 388*4863dea3SSunil Goutham struct nic_cfg_msg nic_cfg; 389*4863dea3SSunil Goutham struct qs_cfg_msg qs; 390*4863dea3SSunil Goutham struct rq_cfg_msg rq; 391*4863dea3SSunil Goutham struct sq_cfg_msg sq; 392*4863dea3SSunil Goutham struct set_mac_msg mac; 393*4863dea3SSunil Goutham struct set_frs_msg frs; 394*4863dea3SSunil Goutham struct cpi_cfg_msg cpi_cfg; 395*4863dea3SSunil Goutham struct rss_sz_msg rss_size; 396*4863dea3SSunil Goutham struct rss_cfg_msg rss_cfg; 397*4863dea3SSunil Goutham struct bgx_stats_msg bgx_stats; 398*4863dea3SSunil Goutham struct bgx_link_status link_status; 399*4863dea3SSunil Goutham }; 400*4863dea3SSunil Goutham 401*4863dea3SSunil Goutham int nicvf_set_real_num_queues(struct net_device *netdev, 402*4863dea3SSunil Goutham int tx_queues, int rx_queues); 403*4863dea3SSunil Goutham int nicvf_open(struct net_device *netdev); 404*4863dea3SSunil Goutham int nicvf_stop(struct net_device *netdev); 405*4863dea3SSunil Goutham int nicvf_send_msg_to_pf(struct nicvf *vf, union nic_mbx *mbx); 406*4863dea3SSunil Goutham void nicvf_config_cpi(struct nicvf *nic); 407*4863dea3SSunil Goutham void nicvf_config_rss(struct nicvf *nic); 408*4863dea3SSunil Goutham void nicvf_set_rss_key(struct nicvf *nic); 409*4863dea3SSunil Goutham void nicvf_free_skb(struct nicvf *nic, struct sk_buff *skb); 410*4863dea3SSunil Goutham void nicvf_set_ethtool_ops(struct net_device *netdev); 411*4863dea3SSunil Goutham void nicvf_update_stats(struct nicvf *nic); 412*4863dea3SSunil Goutham void nicvf_update_lmac_stats(struct nicvf *nic); 413*4863dea3SSunil Goutham 414*4863dea3SSunil Goutham #endif /* NIC_H */ 415