Commit fe6d2a38 authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: adding support for Lancer family of CNAs

Key changes are:
- EQ ids are not assigned consecutively in Lancer. So, fix mapping of MSIx
  vector to EQ-id.
- BAR mapping and some req locations different for Lancer.
- TCP,UDP,IP checksum fields must be compulsorily set in TX wrb for TSO in
  Lancer.
- CEV_IST reg not present in Lancer; so, peek into event queue to check for
  new entries
- cq_create and mcc_create cmd interface is different for Lancer; handle
  accordingly
Signed-off-by: default avatarPadmanabh Ratnakar <padmanabh.ratnakar@emulex.com>
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1d24eb48
...@@ -38,14 +38,17 @@ ...@@ -38,14 +38,17 @@
#define BE_NAME "ServerEngines BladeEngine2 10Gbps NIC" #define BE_NAME "ServerEngines BladeEngine2 10Gbps NIC"
#define BE3_NAME "ServerEngines BladeEngine3 10Gbps NIC" #define BE3_NAME "ServerEngines BladeEngine3 10Gbps NIC"
#define OC_NAME "Emulex OneConnect 10Gbps NIC" #define OC_NAME "Emulex OneConnect 10Gbps NIC"
#define OC_NAME1 "Emulex OneConnect 10Gbps NIC (be3)" #define OC_NAME_BE OC_NAME "(be3)"
#define OC_NAME_LANCER OC_NAME "(Lancer)"
#define DRV_DESC "ServerEngines BladeEngine 10Gbps NIC Driver" #define DRV_DESC "ServerEngines BladeEngine 10Gbps NIC Driver"
#define BE_VENDOR_ID 0x19a2 #define BE_VENDOR_ID 0x19a2
#define EMULEX_VENDOR_ID 0x10df
#define BE_DEVICE_ID1 0x211 #define BE_DEVICE_ID1 0x211
#define BE_DEVICE_ID2 0x221 #define BE_DEVICE_ID2 0x221
#define OC_DEVICE_ID1 0x700 #define OC_DEVICE_ID1 0x700 /* Device Id for BE2 cards */
#define OC_DEVICE_ID2 0x710 #define OC_DEVICE_ID2 0x710 /* Device Id for BE3 cards */
#define OC_DEVICE_ID3 0xe220 /* Device id for Lancer cards */
static inline char *nic_name(struct pci_dev *pdev) static inline char *nic_name(struct pci_dev *pdev)
{ {
...@@ -53,7 +56,9 @@ static inline char *nic_name(struct pci_dev *pdev) ...@@ -53,7 +56,9 @@ static inline char *nic_name(struct pci_dev *pdev)
case OC_DEVICE_ID1: case OC_DEVICE_ID1:
return OC_NAME; return OC_NAME;
case OC_DEVICE_ID2: case OC_DEVICE_ID2:
return OC_NAME1; return OC_NAME_BE;
case OC_DEVICE_ID3:
return OC_NAME_LANCER;
case BE_DEVICE_ID2: case BE_DEVICE_ID2:
return BE3_NAME; return BE3_NAME;
default: default:
...@@ -149,6 +154,7 @@ struct be_eq_obj { ...@@ -149,6 +154,7 @@ struct be_eq_obj {
u16 min_eqd; /* in usecs */ u16 min_eqd; /* in usecs */
u16 max_eqd; /* in usecs */ u16 max_eqd; /* in usecs */
u16 cur_eqd; /* in usecs */ u16 cur_eqd; /* in usecs */
u8 msix_vec_idx;
struct napi_struct napi; struct napi_struct napi;
}; };
...@@ -260,6 +266,8 @@ struct be_adapter { ...@@ -260,6 +266,8 @@ struct be_adapter {
u32 num_rx_qs; u32 num_rx_qs;
u32 big_page_size; /* Compounded page size shared by rx wrbs */ u32 big_page_size; /* Compounded page size shared by rx wrbs */
u8 msix_vec_next_idx;
struct vlan_group *vlan_grp; struct vlan_group *vlan_grp;
u16 vlans_added; u16 vlans_added;
u16 max_vlans; /* Number of vlans supported */ u16 max_vlans; /* Number of vlans supported */
...@@ -299,8 +307,8 @@ struct be_adapter { ...@@ -299,8 +307,8 @@ struct be_adapter {
bool sriov_enabled; bool sriov_enabled;
struct be_vf_cfg vf_cfg[BE_MAX_VF]; struct be_vf_cfg vf_cfg[BE_MAX_VF];
u8 base_eq_id;
u8 is_virtfn; u8 is_virtfn;
u32 sli_family;
}; };
#define be_physfn(adapter) (!adapter->is_virtfn) #define be_physfn(adapter) (!adapter->is_virtfn)
...@@ -309,6 +317,8 @@ struct be_adapter { ...@@ -309,6 +317,8 @@ struct be_adapter {
#define BE_GEN2 2 #define BE_GEN2 2
#define BE_GEN3 3 #define BE_GEN3 3
#define lancer_chip(adapter) (adapter->pdev->device == OC_DEVICE_ID3)
extern const struct ethtool_ops be_ethtool_ops; extern const struct ethtool_ops be_ethtool_ops;
#define tx_stats(adapter) (&adapter->tx_stats) #define tx_stats(adapter) (&adapter->tx_stats)
...@@ -416,10 +426,17 @@ static inline u8 is_udp_pkt(struct sk_buff *skb) ...@@ -416,10 +426,17 @@ static inline u8 is_udp_pkt(struct sk_buff *skb)
static inline void be_check_sriov_fn_type(struct be_adapter *adapter) static inline void be_check_sriov_fn_type(struct be_adapter *adapter)
{ {
u8 data; u8 data;
u32 sli_intf;
pci_write_config_byte(adapter->pdev, 0xFE, 0xAA);
pci_read_config_byte(adapter->pdev, 0xFE, &data); if (lancer_chip(adapter)) {
adapter->is_virtfn = (data != 0xAA); pci_read_config_dword(adapter->pdev, SLI_INTF_REG_OFFSET,
&sli_intf);
adapter->is_virtfn = (sli_intf & SLI_INTF_FT_MASK) ? 1 : 0;
} else {
pci_write_config_byte(adapter->pdev, 0xFE, 0xAA);
pci_read_config_byte(adapter->pdev, 0xFE, &data);
adapter->is_virtfn = (data != 0xAA);
}
} }
static inline void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac) static inline void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac)
......
...@@ -323,7 +323,12 @@ static int be_mbox_notify_wait(struct be_adapter *adapter) ...@@ -323,7 +323,12 @@ static int be_mbox_notify_wait(struct be_adapter *adapter)
static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage) static int be_POST_stage_get(struct be_adapter *adapter, u16 *stage)
{ {
u32 sem = ioread32(adapter->csr + MPU_EP_SEMAPHORE_OFFSET); u32 sem;
if (lancer_chip(adapter))
sem = ioread32(adapter->db + MPU_EP_SEMAPHORE_IF_TYPE2_OFFSET);
else
sem = ioread32(adapter->csr + MPU_EP_SEMAPHORE_OFFSET);
*stage = sem & EP_SEMAPHORE_POST_STAGE_MASK; *stage = sem & EP_SEMAPHORE_POST_STAGE_MASK;
if ((sem >> EP_SEMAPHORE_POST_ERR_SHIFT) & EP_SEMAPHORE_POST_ERR_MASK) if ((sem >> EP_SEMAPHORE_POST_ERR_SHIFT) & EP_SEMAPHORE_POST_ERR_MASK)
...@@ -465,14 +470,25 @@ int be_cmd_fw_init(struct be_adapter *adapter) ...@@ -465,14 +470,25 @@ int be_cmd_fw_init(struct be_adapter *adapter)
spin_lock(&adapter->mbox_lock); spin_lock(&adapter->mbox_lock);
wrb = (u8 *)wrb_from_mbox(adapter); wrb = (u8 *)wrb_from_mbox(adapter);
*wrb++ = 0xFF; if (lancer_chip(adapter)) {
*wrb++ = 0x12; *wrb++ = 0xFF;
*wrb++ = 0x34; *wrb++ = 0x34;
*wrb++ = 0xFF; *wrb++ = 0x12;
*wrb++ = 0xFF; *wrb++ = 0xFF;
*wrb++ = 0x56; *wrb++ = 0xFF;
*wrb++ = 0x78; *wrb++ = 0x78;
*wrb = 0xFF; *wrb++ = 0x56;
*wrb = 0xFF;
} else {
*wrb++ = 0xFF;
*wrb++ = 0x12;
*wrb++ = 0x34;
*wrb++ = 0xFF;
*wrb++ = 0xFF;
*wrb++ = 0x56;
*wrb++ = 0x78;
*wrb = 0xFF;
}
status = be_mbox_notify_wait(adapter); status = be_mbox_notify_wait(adapter);
...@@ -680,16 +696,36 @@ int be_cmd_cq_create(struct be_adapter *adapter, ...@@ -680,16 +696,36 @@ int be_cmd_cq_create(struct be_adapter *adapter,
OPCODE_COMMON_CQ_CREATE, sizeof(*req)); OPCODE_COMMON_CQ_CREATE, sizeof(*req));
req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
if (lancer_chip(adapter)) {
req->hdr.version = 1;
req->page_size = 1; /* 1 for 4K */
AMAP_SET_BITS(struct amap_cq_context_lancer, coalescwm, ctxt,
coalesce_wm);
AMAP_SET_BITS(struct amap_cq_context_lancer, nodelay, ctxt,
no_delay);
AMAP_SET_BITS(struct amap_cq_context_lancer, count, ctxt,
__ilog2_u32(cq->len/256));
AMAP_SET_BITS(struct amap_cq_context_lancer, valid, ctxt, 1);
AMAP_SET_BITS(struct amap_cq_context_lancer, eventable,
ctxt, 1);
AMAP_SET_BITS(struct amap_cq_context_lancer, eqid,
ctxt, eq->id);
AMAP_SET_BITS(struct amap_cq_context_lancer, armed, ctxt, 1);
} else {
AMAP_SET_BITS(struct amap_cq_context_be, coalescwm, ctxt,
coalesce_wm);
AMAP_SET_BITS(struct amap_cq_context_be, nodelay,
ctxt, no_delay);
AMAP_SET_BITS(struct amap_cq_context_be, count, ctxt,
__ilog2_u32(cq->len/256));
AMAP_SET_BITS(struct amap_cq_context_be, valid, ctxt, 1);
AMAP_SET_BITS(struct amap_cq_context_be, solevent,
ctxt, sol_evts);
AMAP_SET_BITS(struct amap_cq_context_be, eventable, ctxt, 1);
AMAP_SET_BITS(struct amap_cq_context_be, eqid, ctxt, eq->id);
AMAP_SET_BITS(struct amap_cq_context_be, armed, ctxt, 1);
}
AMAP_SET_BITS(struct amap_cq_context, coalescwm, ctxt, coalesce_wm);
AMAP_SET_BITS(struct amap_cq_context, nodelay, ctxt, no_delay);
AMAP_SET_BITS(struct amap_cq_context, count, ctxt,
__ilog2_u32(cq->len/256));
AMAP_SET_BITS(struct amap_cq_context, valid, ctxt, 1);
AMAP_SET_BITS(struct amap_cq_context, solevent, ctxt, sol_evts);
AMAP_SET_BITS(struct amap_cq_context, eventable, ctxt, 1);
AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id);
AMAP_SET_BITS(struct amap_cq_context, armed, ctxt, 1);
be_dws_cpu_to_le(ctxt, sizeof(req->context)); be_dws_cpu_to_le(ctxt, sizeof(req->context));
be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
...@@ -737,13 +773,27 @@ int be_cmd_mccq_create(struct be_adapter *adapter, ...@@ -737,13 +773,27 @@ int be_cmd_mccq_create(struct be_adapter *adapter,
OPCODE_COMMON_MCC_CREATE_EXT, sizeof(*req)); OPCODE_COMMON_MCC_CREATE_EXT, sizeof(*req));
req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size));
if (lancer_chip(adapter)) {
req->hdr.version = 1;
req->cq_id = cpu_to_le16(cq->id);
AMAP_SET_BITS(struct amap_mcc_context_lancer, ring_size, ctxt,
be_encoded_q_len(mccq->len));
AMAP_SET_BITS(struct amap_mcc_context_lancer, valid, ctxt, 1);
AMAP_SET_BITS(struct amap_mcc_context_lancer, async_cq_id,
ctxt, cq->id);
AMAP_SET_BITS(struct amap_mcc_context_lancer, async_cq_valid,
ctxt, 1);
} else {
AMAP_SET_BITS(struct amap_mcc_context_be, valid, ctxt, 1);
AMAP_SET_BITS(struct amap_mcc_context_be, ring_size, ctxt,
be_encoded_q_len(mccq->len));
AMAP_SET_BITS(struct amap_mcc_context_be, cq_id, ctxt, cq->id);
}
AMAP_SET_BITS(struct amap_mcc_context, valid, ctxt, 1);
AMAP_SET_BITS(struct amap_mcc_context, ring_size, ctxt,
be_encoded_q_len(mccq->len));
AMAP_SET_BITS(struct amap_mcc_context, cq_id, ctxt, cq->id);
/* Subscribe to Link State and Group 5 Events(bits 1 and 5 set) */ /* Subscribe to Link State and Group 5 Events(bits 1 and 5 set) */
req->async_event_bitmap[0] |= 0x00000022; req->async_event_bitmap[0] = cpu_to_le32(0x00000022);
be_dws_cpu_to_le(ctxt, sizeof(req->context)); be_dws_cpu_to_le(ctxt, sizeof(req->context));
be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem);
......
...@@ -309,7 +309,7 @@ struct be_cmd_req_pmac_del { ...@@ -309,7 +309,7 @@ struct be_cmd_req_pmac_del {
/******************** Create CQ ***************************/ /******************** Create CQ ***************************/
/* Pseudo amap definition in which each bit of the actual structure is defined /* Pseudo amap definition in which each bit of the actual structure is defined
* as a byte: used to calculate offset/shift/mask of each field */ * as a byte: used to calculate offset/shift/mask of each field */
struct amap_cq_context { struct amap_cq_context_be {
u8 cidx[11]; /* dword 0*/ u8 cidx[11]; /* dword 0*/
u8 rsvd0; /* dword 0*/ u8 rsvd0; /* dword 0*/
u8 coalescwm[2]; /* dword 0*/ u8 coalescwm[2]; /* dword 0*/
...@@ -332,14 +332,32 @@ struct amap_cq_context { ...@@ -332,14 +332,32 @@ struct amap_cq_context {
u8 rsvd5[32]; /* dword 3*/ u8 rsvd5[32]; /* dword 3*/
} __packed; } __packed;
struct amap_cq_context_lancer {
u8 rsvd0[12]; /* dword 0*/
u8 coalescwm[2]; /* dword 0*/
u8 nodelay; /* dword 0*/
u8 rsvd1[12]; /* dword 0*/
u8 count[2]; /* dword 0*/
u8 valid; /* dword 0*/
u8 rsvd2; /* dword 0*/
u8 eventable; /* dword 0*/
u8 eqid[16]; /* dword 1*/
u8 rsvd3[15]; /* dword 1*/
u8 armed; /* dword 1*/
u8 rsvd4[32]; /* dword 2*/
u8 rsvd5[32]; /* dword 3*/
} __packed;
struct be_cmd_req_cq_create { struct be_cmd_req_cq_create {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u16 num_pages; u16 num_pages;
u16 rsvd0; u8 page_size;
u8 context[sizeof(struct amap_cq_context) / 8]; u8 rsvd0;
u8 context[sizeof(struct amap_cq_context_be) / 8];
struct phys_addr pages[8]; struct phys_addr pages[8];
} __packed; } __packed;
struct be_cmd_resp_cq_create { struct be_cmd_resp_cq_create {
struct be_cmd_resp_hdr hdr; struct be_cmd_resp_hdr hdr;
u16 cq_id; u16 cq_id;
...@@ -349,7 +367,7 @@ struct be_cmd_resp_cq_create { ...@@ -349,7 +367,7 @@ struct be_cmd_resp_cq_create {
/******************** Create MCCQ ***************************/ /******************** Create MCCQ ***************************/
/* Pseudo amap definition in which each bit of the actual structure is defined /* Pseudo amap definition in which each bit of the actual structure is defined
* as a byte: used to calculate offset/shift/mask of each field */ * as a byte: used to calculate offset/shift/mask of each field */
struct amap_mcc_context { struct amap_mcc_context_be {
u8 con_index[14]; u8 con_index[14];
u8 rsvd0[2]; u8 rsvd0[2];
u8 ring_size[4]; u8 ring_size[4];
...@@ -364,12 +382,23 @@ struct amap_mcc_context { ...@@ -364,12 +382,23 @@ struct amap_mcc_context {
u8 rsvd2[32]; u8 rsvd2[32];
} __packed; } __packed;
struct amap_mcc_context_lancer {
u8 async_cq_id[16];
u8 ring_size[4];
u8 rsvd0[12];
u8 rsvd1[31];
u8 valid;
u8 async_cq_valid[1];
u8 rsvd2[31];
u8 rsvd3[32];
} __packed;
struct be_cmd_req_mcc_create { struct be_cmd_req_mcc_create {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u16 num_pages; u16 num_pages;
u16 rsvd0; u16 cq_id;
u32 async_event_bitmap[1]; u32 async_event_bitmap[1];
u8 context[sizeof(struct amap_mcc_context) / 8]; u8 context[sizeof(struct amap_mcc_context_be) / 8];
struct phys_addr pages[8]; struct phys_addr pages[8];
} __packed; } __packed;
...@@ -605,6 +634,7 @@ struct be_hw_stats { ...@@ -605,6 +634,7 @@ struct be_hw_stats {
struct be_rxf_stats rxf; struct be_rxf_stats rxf;
u32 rsvd[48]; u32 rsvd[48];
struct be_erx_stats erx; struct be_erx_stats erx;
u32 rsvd1[6];
}; };
struct be_cmd_req_get_stats { struct be_cmd_req_get_stats {
......
...@@ -32,10 +32,12 @@ ...@@ -32,10 +32,12 @@
#define MPU_EP_CONTROL 0 #define MPU_EP_CONTROL 0
/********** MPU semphore ******************/ /********** MPU semphore ******************/
#define MPU_EP_SEMAPHORE_OFFSET 0xac #define MPU_EP_SEMAPHORE_OFFSET 0xac
#define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF #define MPU_EP_SEMAPHORE_IF_TYPE2_OFFSET 0x400
#define EP_SEMAPHORE_POST_ERR_MASK 0x1 #define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
#define EP_SEMAPHORE_POST_ERR_SHIFT 31 #define EP_SEMAPHORE_POST_ERR_MASK 0x1
#define EP_SEMAPHORE_POST_ERR_SHIFT 31
/* MPU semphore POST stage values */ /* MPU semphore POST stage values */
#define POST_STAGE_AWAITING_HOST_RDY 0x1 /* FW awaiting goahead from host */ #define POST_STAGE_AWAITING_HOST_RDY 0x1 /* FW awaiting goahead from host */
#define POST_STAGE_HOST_RDY 0x2 /* Host has given go-ahed to FW */ #define POST_STAGE_HOST_RDY 0x2 /* Host has given go-ahed to FW */
...@@ -66,6 +68,28 @@ ...@@ -66,6 +68,28 @@
#define PCICFG_UE_STATUS_LOW_MASK 0xA8 #define PCICFG_UE_STATUS_LOW_MASK 0xA8
#define PCICFG_UE_STATUS_HI_MASK 0xAC #define PCICFG_UE_STATUS_HI_MASK 0xAC
/******** SLI_INTF ***********************/
#define SLI_INTF_REG_OFFSET 0x58
#define SLI_INTF_VALID_MASK 0xE0000000
#define SLI_INTF_VALID 0xC0000000
#define SLI_INTF_HINT2_MASK 0x1F000000
#define SLI_INTF_HINT2_SHIFT 24
#define SLI_INTF_HINT1_MASK 0x00FF0000
#define SLI_INTF_HINT1_SHIFT 16
#define SLI_INTF_FAMILY_MASK 0x00000F00
#define SLI_INTF_FAMILY_SHIFT 8
#define SLI_INTF_IF_TYPE_MASK 0x0000F000
#define SLI_INTF_IF_TYPE_SHIFT 12
#define SLI_INTF_REV_MASK 0x000000F0
#define SLI_INTF_REV_SHIFT 4
#define SLI_INTF_FT_MASK 0x00000001
/* SLI family */
#define BE_SLI_FAMILY 0x0
#define LANCER_A0_SLI_FAMILY 0xA
/********* ISR0 Register offset **********/ /********* ISR0 Register offset **********/
#define CEV_ISR0_OFFSET 0xC18 #define CEV_ISR0_OFFSET 0xC18
#define CEV_ISR_SIZE 4 #define CEV_ISR_SIZE 4
...@@ -73,6 +97,9 @@ ...@@ -73,6 +97,9 @@
/********* Event Q door bell *************/ /********* Event Q door bell *************/
#define DB_EQ_OFFSET DB_CQ_OFFSET #define DB_EQ_OFFSET DB_CQ_OFFSET
#define DB_EQ_RING_ID_MASK 0x1FF /* bits 0 - 8 */ #define DB_EQ_RING_ID_MASK 0x1FF /* bits 0 - 8 */
#define DB_EQ_RING_ID_EXT_MASK 0x3e00 /* bits 9-13 */
#define DB_EQ_RING_ID_EXT_MASK_SHIFT (2) /* qid bits 9-13 placing at 11-15 */
/* Clear the interrupt for this eq */ /* Clear the interrupt for this eq */
#define DB_EQ_CLR_SHIFT (9) /* bit 9 */ #define DB_EQ_CLR_SHIFT (9) /* bit 9 */
/* Must be 1 */ /* Must be 1 */
...@@ -85,6 +112,10 @@ ...@@ -85,6 +112,10 @@
/********* Compl Q door bell *************/ /********* Compl Q door bell *************/
#define DB_CQ_OFFSET 0x120 #define DB_CQ_OFFSET 0x120
#define DB_CQ_RING_ID_MASK 0x3FF /* bits 0 - 9 */ #define DB_CQ_RING_ID_MASK 0x3FF /* bits 0 - 9 */
#define DB_CQ_RING_ID_EXT_MASK 0x7C00 /* bits 10-14 */
#define DB_CQ_RING_ID_EXT_MASK_SHIFT (1) /* qid bits 10-14
placing at 11-15 */
/* Number of event entries processed */ /* Number of event entries processed */
#define DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */ #define DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */
/* Rearm bit */ /* Rearm bit */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment