0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef CNIC_IF_H
0014 #define CNIC_IF_H
0015
0016 #include "bnx2x/bnx2x_mfw_req.h"
0017
0018 #define CNIC_MODULE_VERSION "2.5.22"
0019 #define CNIC_MODULE_RELDATE "July 20, 2015"
0020
0021 #define CNIC_ULP_RDMA 0
0022 #define CNIC_ULP_ISCSI 1
0023 #define CNIC_ULP_FCOE 2
0024 #define CNIC_ULP_L4 3
0025 #define MAX_CNIC_ULP_TYPE_EXT 3
0026 #define MAX_CNIC_ULP_TYPE 4
0027
0028
0029 #if (PAGE_SHIFT > 14)
0030 #define CNIC_PAGE_BITS 14
0031 #else
0032 #define CNIC_PAGE_BITS PAGE_SHIFT
0033 #endif
0034 #define CNIC_PAGE_SIZE (1 << (CNIC_PAGE_BITS))
0035 #define CNIC_PAGE_ALIGN(addr) ALIGN(addr, CNIC_PAGE_SIZE)
0036 #define CNIC_PAGE_MASK (~((CNIC_PAGE_SIZE) - 1))
0037
0038 struct kwqe {
0039 u32 kwqe_op_flag;
0040
0041 #define KWQE_QID_SHIFT 8
0042 #define KWQE_OPCODE_MASK 0x00ff0000
0043 #define KWQE_OPCODE_SHIFT 16
0044 #define KWQE_OPCODE(x) ((x & KWQE_OPCODE_MASK) >> KWQE_OPCODE_SHIFT)
0045 #define KWQE_LAYER_MASK 0x70000000
0046 #define KWQE_LAYER_SHIFT 28
0047 #define KWQE_FLAGS_LAYER_MASK_L2 (2<<28)
0048 #define KWQE_FLAGS_LAYER_MASK_L3 (3<<28)
0049 #define KWQE_FLAGS_LAYER_MASK_L4 (4<<28)
0050 #define KWQE_FLAGS_LAYER_MASK_L5_RDMA (5<<28)
0051 #define KWQE_FLAGS_LAYER_MASK_L5_ISCSI (6<<28)
0052 #define KWQE_FLAGS_LAYER_MASK_L5_FCOE (7<<28)
0053
0054 u32 kwqe_info0;
0055 u32 kwqe_info1;
0056 u32 kwqe_info2;
0057 u32 kwqe_info3;
0058 u32 kwqe_info4;
0059 u32 kwqe_info5;
0060 u32 kwqe_info6;
0061 };
0062
0063 struct kwqe_16 {
0064 u32 kwqe_info0;
0065 u32 kwqe_info1;
0066 u32 kwqe_info2;
0067 u32 kwqe_info3;
0068 };
0069
0070 struct kcqe {
0071 u32 kcqe_info0;
0072 u32 kcqe_info1;
0073 u32 kcqe_info2;
0074 u32 kcqe_info3;
0075 u32 kcqe_info4;
0076 u32 kcqe_info5;
0077 u32 kcqe_info6;
0078 u32 kcqe_op_flag;
0079 #define KCQE_RAMROD_COMPLETION (0x1<<27)
0080 #define KCQE_FLAGS_LAYER_MASK (0x7<<28)
0081 #define KCQE_FLAGS_LAYER_MASK_MISC (0<<28)
0082 #define KCQE_FLAGS_LAYER_MASK_L2 (2<<28)
0083 #define KCQE_FLAGS_LAYER_MASK_L3 (3<<28)
0084 #define KCQE_FLAGS_LAYER_MASK_L4 (4<<28)
0085 #define KCQE_FLAGS_LAYER_MASK_L5_RDMA (5<<28)
0086 #define KCQE_FLAGS_LAYER_MASK_L5_ISCSI (6<<28)
0087 #define KCQE_FLAGS_LAYER_MASK_L5_FCOE (7<<28)
0088 #define KCQE_FLAGS_NEXT (1<<31)
0089 #define KCQE_FLAGS_OPCODE_MASK (0xff<<16)
0090 #define KCQE_FLAGS_OPCODE_SHIFT (16)
0091 #define KCQE_OPCODE(op) \
0092 (((op) & KCQE_FLAGS_OPCODE_MASK) >> KCQE_FLAGS_OPCODE_SHIFT)
0093 };
0094
0095 #define MAX_CNIC_CTL_DATA 64
0096 #define MAX_DRV_CTL_DATA 64
0097
0098 #define CNIC_CTL_STOP_CMD 1
0099 #define CNIC_CTL_START_CMD 2
0100 #define CNIC_CTL_COMPLETION_CMD 3
0101 #define CNIC_CTL_STOP_ISCSI_CMD 4
0102 #define CNIC_CTL_FCOE_STATS_GET_CMD 5
0103 #define CNIC_CTL_ISCSI_STATS_GET_CMD 6
0104
0105 #define DRV_CTL_IO_WR_CMD 0x101
0106 #define DRV_CTL_IO_RD_CMD 0x102
0107 #define DRV_CTL_CTX_WR_CMD 0x103
0108 #define DRV_CTL_CTXTBL_WR_CMD 0x104
0109 #define DRV_CTL_RET_L5_SPQ_CREDIT_CMD 0x105
0110 #define DRV_CTL_START_L2_CMD 0x106
0111 #define DRV_CTL_STOP_L2_CMD 0x107
0112 #define DRV_CTL_RET_L2_SPQ_CREDIT_CMD 0x10c
0113 #define DRV_CTL_ISCSI_STOPPED_CMD 0x10d
0114 #define DRV_CTL_ULP_REGISTER_CMD 0x10e
0115 #define DRV_CTL_ULP_UNREGISTER_CMD 0x10f
0116
0117 struct cnic_ctl_completion {
0118 u32 cid;
0119 u8 opcode;
0120 u8 error;
0121 };
0122
0123 struct cnic_ctl_info {
0124 int cmd;
0125 union {
0126 struct cnic_ctl_completion comp;
0127 char bytes[MAX_CNIC_CTL_DATA];
0128 } data;
0129 };
0130
0131 struct drv_ctl_spq_credit {
0132 u32 credit_count;
0133 };
0134
0135 struct drv_ctl_io {
0136 u32 cid_addr;
0137 u32 offset;
0138 u32 data;
0139 dma_addr_t dma_addr;
0140 };
0141
0142 struct drv_ctl_l2_ring {
0143 u32 client_id;
0144 u32 cid;
0145 };
0146
0147 struct drv_ctl_register_data {
0148 int ulp_type;
0149 struct fcoe_capabilities fcoe_features;
0150 };
0151
0152 struct drv_ctl_info {
0153 int cmd;
0154 int drv_state;
0155 #define DRV_NOP 0
0156 #define DRV_ACTIVE 1
0157 #define DRV_INACTIVE 2
0158 #define DRV_UNLOADED 3
0159 union {
0160 struct drv_ctl_spq_credit credit;
0161 struct drv_ctl_io io;
0162 struct drv_ctl_l2_ring ring;
0163 int ulp_type;
0164 struct drv_ctl_register_data register_data;
0165 char bytes[MAX_DRV_CTL_DATA];
0166 } data;
0167 };
0168
0169 #define MAX_NPIV_ENTRIES 64
0170 #define FC_NPIV_WWN_SIZE 8
0171
0172 struct cnic_fc_npiv_tbl {
0173 u8 wwpn[MAX_NPIV_ENTRIES][FC_NPIV_WWN_SIZE];
0174 u8 wwnn[MAX_NPIV_ENTRIES][FC_NPIV_WWN_SIZE];
0175 u32 count;
0176 };
0177
0178 struct cnic_ops {
0179 struct module *cnic_owner;
0180
0181
0182
0183
0184 int (*cnic_handler)(void *, void *);
0185 int (*cnic_ctl)(void *, struct cnic_ctl_info *);
0186 };
0187
0188 #define MAX_CNIC_VEC 8
0189
0190 struct cnic_irq {
0191 unsigned int vector;
0192 void *status_blk;
0193 u32 status_blk_num;
0194 u32 status_blk_num2;
0195 u32 irq_flags;
0196 #define CNIC_IRQ_FL_MSIX 0x00000001
0197 };
0198
0199 struct cnic_eth_dev {
0200 struct module *drv_owner;
0201 u32 drv_state;
0202 #define CNIC_DRV_STATE_REGD 0x00000001
0203 #define CNIC_DRV_STATE_USING_MSIX 0x00000002
0204 #define CNIC_DRV_STATE_NO_ISCSI_OOO 0x00000004
0205 #define CNIC_DRV_STATE_NO_ISCSI 0x00000008
0206 #define CNIC_DRV_STATE_NO_FCOE 0x00000010
0207 #define CNIC_DRV_STATE_HANDLES_IRQ 0x00000020
0208 u32 chip_id;
0209 u32 max_kwqe_pending;
0210 struct pci_dev *pdev;
0211 void __iomem *io_base;
0212 void __iomem *io_base2;
0213 const void *iro_arr;
0214
0215 u32 ctx_tbl_offset;
0216 u32 ctx_tbl_len;
0217 int ctx_blk_size;
0218 u32 starting_cid;
0219 u32 max_iscsi_conn;
0220 u32 max_fcoe_conn;
0221 u32 max_rdma_conn;
0222 u32 fcoe_init_cid;
0223 u32 max_fcoe_exchanges;
0224 u32 fcoe_wwn_port_name_hi;
0225 u32 fcoe_wwn_port_name_lo;
0226 u32 fcoe_wwn_node_name_hi;
0227 u32 fcoe_wwn_node_name_lo;
0228
0229 u16 iscsi_l2_client_id;
0230 u16 iscsi_l2_cid;
0231 u8 iscsi_mac[ETH_ALEN];
0232
0233 int num_irq;
0234 struct cnic_irq irq_arr[MAX_CNIC_VEC];
0235 int (*drv_register_cnic)(struct net_device *,
0236 struct cnic_ops *, void *);
0237 int (*drv_unregister_cnic)(struct net_device *);
0238 int (*drv_submit_kwqes_32)(struct net_device *,
0239 struct kwqe *[], u32);
0240 int (*drv_submit_kwqes_16)(struct net_device *,
0241 struct kwqe_16 *[], u32);
0242 int (*drv_ctl)(struct net_device *, struct drv_ctl_info *);
0243 int (*drv_get_fc_npiv_tbl)(struct net_device *,
0244 struct cnic_fc_npiv_tbl *);
0245 unsigned long reserved1[2];
0246 union drv_info_to_mcp *addr_drv_info_to_mcp;
0247 };
0248
0249 struct cnic_sockaddr {
0250 union {
0251 struct sockaddr_in v4;
0252 struct sockaddr_in6 v6;
0253 } local;
0254 union {
0255 struct sockaddr_in v4;
0256 struct sockaddr_in6 v6;
0257 } remote;
0258 };
0259
0260 struct cnic_sock {
0261 struct cnic_dev *dev;
0262 void *context;
0263 u32 src_ip[4];
0264 u32 dst_ip[4];
0265 u16 src_port;
0266 u16 dst_port;
0267 u16 vlan_id;
0268 unsigned char old_ha[ETH_ALEN];
0269 unsigned char ha[ETH_ALEN];
0270 u32 mtu;
0271 u32 cid;
0272 u32 l5_cid;
0273 u32 pg_cid;
0274 int ulp_type;
0275
0276 u32 ka_timeout;
0277 u32 ka_interval;
0278 u8 ka_max_probe_count;
0279 u8 tos;
0280 u8 ttl;
0281 u8 snd_seq_scale;
0282 u32 rcv_buf;
0283 u32 snd_buf;
0284 u32 seed;
0285
0286 unsigned long tcp_flags;
0287 #define SK_TCP_NO_DELAY_ACK 0x1
0288 #define SK_TCP_KEEP_ALIVE 0x2
0289 #define SK_TCP_NAGLE 0x4
0290 #define SK_TCP_TIMESTAMP 0x8
0291 #define SK_TCP_SACK 0x10
0292 #define SK_TCP_SEG_SCALING 0x20
0293 unsigned long flags;
0294 #define SK_F_INUSE 0
0295 #define SK_F_OFFLD_COMPLETE 1
0296 #define SK_F_OFFLD_SCHED 2
0297 #define SK_F_PG_OFFLD_COMPLETE 3
0298 #define SK_F_CONNECT_START 4
0299 #define SK_F_IPV6 5
0300 #define SK_F_CLOSING 7
0301 #define SK_F_HW_ERR 8
0302
0303 atomic_t ref_count;
0304 u32 state;
0305 struct kwqe kwqe1;
0306 struct kwqe kwqe2;
0307 struct kwqe kwqe3;
0308 };
0309
0310 struct cnic_dev {
0311 struct net_device *netdev;
0312 struct pci_dev *pcidev;
0313 void __iomem *regview;
0314 struct list_head list;
0315
0316 int (*register_device)(struct cnic_dev *dev, int ulp_type,
0317 void *ulp_ctx);
0318 int (*unregister_device)(struct cnic_dev *dev, int ulp_type);
0319 int (*submit_kwqes)(struct cnic_dev *dev, struct kwqe *wqes[],
0320 u32 num_wqes);
0321 int (*submit_kwqes_16)(struct cnic_dev *dev, struct kwqe_16 *wqes[],
0322 u32 num_wqes);
0323
0324 int (*cm_create)(struct cnic_dev *, int, u32, u32, struct cnic_sock **,
0325 void *);
0326 int (*cm_destroy)(struct cnic_sock *);
0327 int (*cm_connect)(struct cnic_sock *, struct cnic_sockaddr *);
0328 int (*cm_abort)(struct cnic_sock *);
0329 int (*cm_close)(struct cnic_sock *);
0330 struct cnic_dev *(*cm_select_dev)(struct sockaddr_in *, int ulp_type);
0331 int (*iscsi_nl_msg_recv)(struct cnic_dev *dev, u32 msg_type,
0332 char *data, u16 data_size);
0333 int (*get_fc_npiv_tbl)(struct cnic_dev *, struct cnic_fc_npiv_tbl *);
0334 unsigned long flags;
0335 #define CNIC_F_CNIC_UP 1
0336 #define CNIC_F_BNX2_CLASS 3
0337 #define CNIC_F_BNX2X_CLASS 4
0338 atomic_t ref_count;
0339 u8 mac_addr[ETH_ALEN];
0340
0341 int max_iscsi_conn;
0342 int max_fcoe_conn;
0343 int max_rdma_conn;
0344
0345 int max_fcoe_exchanges;
0346
0347 union drv_info_to_mcp *stats_addr;
0348 struct fcoe_capabilities *fcoe_cap;
0349
0350 void *cnic_priv;
0351 };
0352
0353 #define CNIC_WR(dev, off, val) writel(val, dev->regview + off)
0354 #define CNIC_WR16(dev, off, val) writew(val, dev->regview + off)
0355 #define CNIC_WR8(dev, off, val) writeb(val, dev->regview + off)
0356 #define CNIC_RD(dev, off) readl(dev->regview + off)
0357 #define CNIC_RD16(dev, off) readw(dev->regview + off)
0358
0359 struct cnic_ulp_ops {
0360
0361
0362
0363
0364
0365 void (*cnic_init)(struct cnic_dev *dev);
0366 void (*cnic_exit)(struct cnic_dev *dev);
0367 void (*cnic_start)(void *ulp_ctx);
0368 void (*cnic_stop)(void *ulp_ctx);
0369 void (*indicate_kcqes)(void *ulp_ctx, struct kcqe *cqes[],
0370 u32 num_cqes);
0371 void (*indicate_netevent)(void *ulp_ctx, unsigned long event, u16 vid);
0372 void (*cm_connect_complete)(struct cnic_sock *);
0373 void (*cm_close_complete)(struct cnic_sock *);
0374 void (*cm_abort_complete)(struct cnic_sock *);
0375 void (*cm_remote_close)(struct cnic_sock *);
0376 void (*cm_remote_abort)(struct cnic_sock *);
0377 int (*iscsi_nl_send_msg)(void *ulp_ctx, u32 msg_type,
0378 char *data, u16 data_size);
0379 int (*cnic_get_stats)(void *ulp_ctx);
0380 struct module *owner;
0381 atomic_t ref_count;
0382 };
0383
0384 int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops);
0385
0386 int cnic_unregister_driver(int ulp_type);
0387
0388 #endif