csiostor: Chelsio FCoE offload driver submission
Subsystems (5)
v5 cover csiostor: Chelsio FCoE offload driver submission
This is the initial submission of the Chelsio FCoE offload driver (csiostor) to the upstream kernel. This driver currently supports FCoE offload functionality over Chelsio T4-based 10Gb Converged Network Adapters.
The following patches contain the driver sources for csiostor driver and updates to firmware/hardware header files shared between csiostor, cxgb4 (Chelsio T4-based NIC driver) and cxgb4vf (Chelsio T4-based Virtual Function NIC driver). The csiostor driver is dependent on these header updates. These patches have been generated against scsi 'misc' branch.
csiostor is a low level SCSI driver that interfaces with PCI, SCSI midlayer and FC transport subsystems. This driver claims the FCoE PCIe function on Chelsio Converged Network Adapters. It relies on firmware events for slow path operations like discovery, thereby offloading session management. The driver programs firmware via Work Request interfaces for fast path I/O offload features.
Version V5 of the patches addresses James's comment, primary among them being moving to the lockless version of queuecommand(). Rest of the V5 changes are listed in the individual patches.
Here is the brief description of patches:
[V5 PATCH 1/8]: Updates to header files shared between cxgb4, cxgb4vf and
csiostor.
[V5 PATCH 2/8]: Header files part 1.
[V5 PATCH 3/8]: Header files part 2.
[V5 PATCH 4/8]: Driver initialization and Work Request services. [V5 PATCH 5/8]: FC transport interfaces and mailbox services. [V5 PATCH 6/8]: Local and remote port state tracking functionality. [V5 PATCH 7/8]: Interrupt handling and fast path I/O functionality. [V5 PATCH 8/8]: Hardware interface, Makefile and Kconfig changes.
Naresh Kumar Inna (8):
cxgb4/cxgb4vf: Chelsio FCoE offload driver submission (common header
updates).
csiostor: Chelsio FCoE offload driver submission (headers part 1).
csiostor: Chelsio FCoE offload driver submission (headers part 2).
csiostor: Chelsio FCoE offload driver submission (sources part 1).
csiostor: Chelsio FCoE offload driver submission (sources part 2).
csiostor: Chelsio FCoE offload driver submission (sources part 3).
csiostor: Chelsio FCoE offload driver submission (sources part 4).
csiostor: Chelsio FCoE offload driver submission (sources part 5).
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 10 +- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 16 +- drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 69 +- drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 104 +- drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 11 +- drivers/scsi/Kconfig | 1 + drivers/scsi/Makefile | 1 + drivers/scsi/csiostor/Kconfig | 19 + drivers/scsi/csiostor/Makefile | 11 + drivers/scsi/csiostor/csio_attr.c | 804 +++++ drivers/scsi/csiostor/csio_defs.h | 121 + drivers/scsi/csiostor/csio_hw.c | 4395 +++++++++++++++++++++++ drivers/scsi/csiostor/csio_hw.h | 666 ++++ drivers/scsi/csiostor/csio_init.c | 1274 +++++++ drivers/scsi/csiostor/csio_init.h | 158 + drivers/scsi/csiostor/csio_isr.c | 624 ++++ drivers/scsi/csiostor/csio_lnode.c | 2133 +++++++++++ drivers/scsi/csiostor/csio_lnode.h | 255 ++ drivers/scsi/csiostor/csio_mb.c | 1769 +++++++++ drivers/scsi/csiostor/csio_mb.h | 278 ++ drivers/scsi/csiostor/csio_rnode.c | 889 +++++ drivers/scsi/csiostor/csio_rnode.h | 141 + drivers/scsi/csiostor/csio_scsi.c | 2554 +++++++++++++ drivers/scsi/csiostor/csio_scsi.h | 342 ++ drivers/scsi/csiostor/csio_wr.c | 1632 +++++++++ drivers/scsi/csiostor/csio_wr.h | 512 +++ drivers/scsi/csiostor/t4fw_api_stor.h | 578 +++ 29 files changed, 19333 insertions(+), 37 deletions(-) create mode 100644 drivers/scsi/csiostor/Kconfig create mode 100644 drivers/scsi/csiostor/Makefile create mode 100644 drivers/scsi/csiostor/csio_attr.c create mode 100644 drivers/scsi/csiostor/csio_defs.h create mode 100644 drivers/scsi/csiostor/csio_hw.c create mode 100644 drivers/scsi/csiostor/csio_hw.h create mode 100644 drivers/scsi/csiostor/csio_init.c create mode 100644 drivers/scsi/csiostor/csio_init.h create mode 100644 drivers/scsi/csiostor/csio_isr.c create mode 100644 drivers/scsi/csiostor/csio_lnode.c create mode 100644 drivers/scsi/csiostor/csio_lnode.h create mode 100644 drivers/scsi/csiostor/csio_mb.c create mode 100644 drivers/scsi/csiostor/csio_mb.h create mode 100644 drivers/scsi/csiostor/csio_rnode.c create mode 100644 drivers/scsi/csiostor/csio_rnode.h create mode 100644 drivers/scsi/csiostor/csio_scsi.c create mode 100644 drivers/scsi/csiostor/csio_scsi.h create mode 100644 drivers/scsi/csiostor/csio_wr.c create mode 100644 drivers/scsi/csiostor/csio_wr.h create mode 100644 drivers/scsi/csiostor/t4fw_api_stor.h
PATCH v5 1/8 cxgb4/cxgb4vf: Chelsio FCoE offload driver submission (common header updates).
This patch contains updates to firmware/hardware header files shared between csiostor and cxgb4/cxgb4vf, and the resulting changes to the cxgb4/cxgb4vf source files.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 10 +- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 16 ++-- drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 69 ++++++++++++++- drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 104 +++++++++++++++++++--- drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 11 ++- 7 files changed, 176 insertions(+), 37 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1 -1
@@ -3102,7 +3102,7 @@ static int adap_init1(struct adapter *adap, struct fw_caps_config_cmd *c)memset (c,0 ,sizeof (*c)); c->op_to_write =htonl (FW_CMD_OP (FW_CAPS_CONFIG_CMD ) |FW_CMD_REQUEST |FW_CMD_READ ); - c->retval_len16 =htonl (FW_LEN16 (*c)); + c->cfvalid_to_len16 =htonl (FW_LEN16 (*c)); ret =t4_wr_mbox (adap, adap->fn, c,sizeof (*c), c);if (ret <0 )return ret;
drivers/net/ethernet/chelsio/cxgb4/sge.c +5 -5
@@ -455,7 +455,7 @@ static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q) {if (q->pend_cred >=8 ) {wmb (); -t4_write_reg (adap,MYPF_REG (SGE_PF_KDOORBELL ),DBPRIO | +t4_write_reg (adap,MYPF_REG (SGE_PF_KDOORBELL ),DBPRIO (1 ) |QID (q->cntxt_id) |PIDX (q->pend_cred /8 )); q->pend_cred &=7 ; }
@@ -2020,10 +2020,10 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, goto fl_nomem; flsz = fl->size /8 +STAT_LEN /sizeof (struct tx_desc ); - c.iqns_to_fl0congen =htonl (FW_IQ_CMD_FL0PACKEN | + c.iqns_to_fl0congen =htonl (FW_IQ_CMD_FL0PACKEN (1 ) |FW_IQ_CMD_FL0FETCHRO (1 ) |FW_IQ_CMD_FL0DATARO (1 ) | -FW_IQ_CMD_FL0PADEN ); +FW_IQ_CMD_FL0PADEN (1 )); c.fl0dcaen_to_fl0cidxfthresh =htons (FW_IQ_CMD_FL0FBMIN (2 ) |FW_IQ_CMD_FL0FBMAX (3 )); c.fl0size =htons (flsz);
@@ -2416,10 +2416,10 @@ void t4_sge_init(struct adapter *adap)unsigned int fl_align_log =ilog2 (FL_ALIGN );t4_set_reg_field (adap,SGE_CONTROL ,PKTSHIFT_MASK | -INGPADBOUNDARY_MASK |EGRSTATUSPAGESIZE , +INGPADBOUNDARY_MASK |EGRSTATUSPAGESIZE (1 ),INGPADBOUNDARY (fl_align_log -5 ) |PKTSHIFT (2 ) |RXPKTCPLMODE | - (STAT_LEN ==128 ?EGRSTATUSPAGESIZE :0 )); + (STAT_LEN ==128 ?EGRSTATUSPAGESIZE (1 ) :0 ));/* * Set up to drop DOORBELL writes when the DOORBELL FIFO overflows
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +8 -8
@@ -456,12 +456,12 @@ static int sf1_read(struct adapter *adapter, unsigned int byte_cnt, int cont,if (!byte_cnt || byte_cnt >4 )return -EINVAL ; -if (t4_read_reg (adapter,SF_OP ) &BUSY ) +if (t4_read_reg (adapter,SF_OP ) &SF_BUSY )return -EBUSY ; cont = cont ?SF_CONT :0 ; lock = lock ?SF_LOCK :0 ;t4_write_reg (adapter,SF_OP , lock | cont |BYTECNT (byte_cnt -1 )); - ret =t4_wait_op_done (adapter,SF_OP ,BUSY ,0 ,SF_ATTEMPTS ,5 ); + ret =t4_wait_op_done (adapter,SF_OP ,SF_BUSY ,0 ,SF_ATTEMPTS ,5 );if (!ret) *valp =t4_read_reg (adapter,SF_DATA );return ret;
@@ -484,14 +484,14 @@ static int sf1_write(struct adapter *adapter, unsigned int byte_cnt, int cont, {if (!byte_cnt || byte_cnt >4 )return -EINVAL ; -if (t4_read_reg (adapter,SF_OP ) &BUSY ) +if (t4_read_reg (adapter,SF_OP ) &SF_BUSY )return -EBUSY ; cont = cont ?SF_CONT :0 ; lock = lock ?SF_LOCK :0 ;t4_write_reg (adapter,SF_DATA , val);t4_write_reg (adapter,SF_OP , lock | cont |BYTECNT (byte_cnt -1 ) |OP_WR ); -return t4_wait_op_done (adapter,SF_OP ,BUSY ,0 ,SF_ATTEMPTS ,5 ); +return t4_wait_op_done (adapter,SF_OP ,SF_BUSY ,0 ,SF_ATTEMPTS ,5 ); }/**
@@ -1972,14 +1972,14 @@ int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,t4_write_reg (adap,EPIO_REG (DATA0 ), mask0);t4_write_reg (adap,EPIO_REG (OP ),ADDRESS (i) |EPIOWR );t4_read_reg (adap,EPIO_REG (OP ));/* flush */ -if (t4_read_reg (adap,EPIO_REG (OP )) &BUSY ) +if (t4_read_reg (adap,EPIO_REG (OP )) &SF_BUSY )return -ETIMEDOUT ;/* write CRC */ t4_write_reg (adap,EPIO_REG (DATA0 ), crc);t4_write_reg (adap,EPIO_REG (OP ),ADDRESS (i +32 ) |EPIOWR );t4_read_reg (adap,EPIO_REG (OP ));/* flush */ -if (t4_read_reg (adap,EPIO_REG (OP )) &BUSY ) +if (t4_read_reg (adap,EPIO_REG (OP )) &SF_BUSY )return -ETIMEDOUT ; }#undef EPIO_REG
@@ -2118,7 +2118,7 @@ int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox,struct fw_hello_cmd c;INIT_CMD (c,HELLO ,WRITE ); - c.err_to_mbasyncnot = htonl( + c.err_to_clearinit = htonl( FW_HELLO_CMD_MASTERDIS(master == MASTER_CANT) | FW_HELLO_CMD_MASTERFORCE(master == MASTER_MUST) | FW_HELLO_CMD_MBMASTER(master == MASTER_MUST ? mbox : 0xff) |
@@ -2126,7 +2126,7 @@ int t4_fw_hello(struct adapter *adap, unsigned int mbox, unsigned int evt_mbox, ret =t4_wr_mbox (adap, mbox, &c,sizeof (c), &c);if (ret ==0 && state) { -u32 v =ntohl (c.err_to_mbasyncnot); +u32 v =ntohl (c.err_to_clearinit);if (v &FW_HELLO_CMD_INIT ) *state =DEV_STATE_INIT ;else if (v &FW_HELLO_CMD_ERR )
drivers/net/ethernet/chelsio/cxgb4/t4_msg.h +1 -0
@@ -658,6 +658,7 @@ struct ulptx_sgl {__be32 cmd_nsge;#define ULPTX_CMD (x) ((x) << 24)#define ULPTX_NSGE (x) ((x) << 0) +#define ULPTX_MORE (1U << 23)__be32 len0;__be64 addr0;struct ulptx_sge_pair sge[0 ];
drivers/net/ethernet/chelsio/cxgb4/t4_regs.h +66 -3
142 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +89 -15
222 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4vf/sge.c +6 -5
@@ -536,7 +536,7 @@ static inline void ring_fl_db(struct adapter *adapter, struct sge_fl *fl)if (fl->pend_cred >=FL_PER_EQ_UNIT ) {wmb ();t4_write_reg (adapter,T4VF_SGE_BASE_ADDR +SGE_VF_KDOORBELL , -DBPRIO | +DBPRIO (1 ) |QID (fl->cntxt_id) |PIDX (fl->pend_cred /FL_PER_EQ_UNIT )); fl->pend_cred %=FL_PER_EQ_UNIT ;
@@ -952,7 +952,7 @@ static inline void ring_tx_db(struct adapter *adapter, struct sge_txq *tq,* Warn if we write doorbells with the wrong priority and write * descriptors before telling HW. */ -WARN_ON ((QID (tq->cntxt_id) |PIDX (n)) &DBPRIO ); +WARN_ON ((QID (tq->cntxt_id) |PIDX (n)) &DBPRIO (1 ));wmb ();t4_write_reg (adapter,T4VF_SGE_BASE_ADDR +SGE_VF_KDOORBELL ,QID (tq->cntxt_id) |PIDX (n));
@@ -2126,8 +2126,8 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq, cmd.iqns_to_fl0congen =cpu_to_be32 (FW_IQ_CMD_FL0HOSTFCMODE (SGE_HOSTFCMODE_NONE ) | -FW_IQ_CMD_FL0PACKEN | -FW_IQ_CMD_FL0PADEN ); +FW_IQ_CMD_FL0PACKEN (1 ) | +FW_IQ_CMD_FL0PADEN (1 )); cmd.fl0dcaen_to_fl0cidxfthresh = cpu_to_be16( FW_IQ_CMD_FL0FBMIN(SGE_FETCHBURSTMIN_64B) |
@@ -2431,7 +2431,8 @@ int t4vf_sge_init(struct adapter *adapter)*/ if (fl1)FL_PG_ORDER =ilog2 (fl1) -PAGE_SHIFT ; -STAT_LEN = ((sge_params->sge_control &EGRSTATUSPAGESIZE ) ?128 :64 ); +STAT_LEN = ((sge_params->sge_control &EGRSTATUSPAGESIZE (1 )) ? +128 :64 );PKTSHIFT =PKTSHIFT_GET (sge_params->sge_control);FL_ALIGN =1 << (INGPADBOUNDARY_GET (sge_params->sge_control) +SGE_INGPADBOUNDARY_SHIFT );
Signature · 1 line
1.7.1
PATCH v5 2/8 csiostor: Chelsio FCoE offload driver submission (headers part 1).
In reply to Naresh Kumar InnaThis patch contains the first set of the header files for csiostor driver.
---
V2:
- Removed csio_fcoe_proto.h, using defines from include/scsi/fc instead.
- Removed driver-specific return values, using errno values instead.
- Retained CSIO_INC_STATS, since it is useful in multiple places and the name of the structure has been standardized to make use of this macro.
- Removed csio_deq_from_head(), replaced it inline with calls from list.h.
- Removed csio_deq_from_tail().
- Replaced state machine macros with static functions.
- Capitalizing macros with CPP keys.
V3:
- Replaced CSIO_ROUNDUP with DIV_ROUND_UP.
- Use BUG_ON in CSIO_ASSERT macro.
V5: readq/writeq definitions for 32-bit platforms.
drivers/scsi/csiostor/csio_defs.h | 121 ++++++ drivers/scsi/csiostor/csio_hw.h | 666 +++++++++++++++++++++++++++++++++ drivers/scsi/csiostor/csio_init.h | 158 ++++++++ drivers/scsi/csiostor/t4fw_api_stor.h | 578 ++++++++++++++++++++++++++++ 4 files changed, 1523 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/csiostor/csio_defs.h create mode 100644 drivers/scsi/csiostor/csio_hw.h create mode 100644 drivers/scsi/csiostor/csio_init.h create mode 100644 drivers/scsi/csiostor/t4fw_api_stor.h
drivers/scsi/csiostor/csio_defs.h new file +121 -0
@@ -0,0 +1,121 @@ +/* +* This file is part of the Chelsio FCoE driver for Linux. +* +* Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. +* +* This software is available to you under a choice of one of two +* licenses. You may choose to be licensed under the terms of the GNU +* General Public License (GPL) Version 2, available from the file +* COPYING in the main directory of this source tree, or the +* OpenIB.org BSD license below: +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* +* - Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. +* +* - Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#ifndef __CSIO_DEFS_H__ +#define __CSIO_DEFS_H__ + +#include <linux/kernel.h> +#include <linux/stddef.h> +#include <linux/timer.h> +#include <linux/list.h> +#include <linux/bug.h> +#include <linux/pci.h> +#include <linux/jiffies.h> + +#define CSIO_INVALID_IDX 0xFFFFFFFF +#define CSIO_INC_STATS (elem, val) ((elem)->stats.val++) +#define CSIO_DEC_STATS (elem, val) ((elem)->stats.val--) +#define CSIO_VALID_WWN (__n) ((*__n >> 4) == 0x5 ? true : false) +#define CSIO_DID_MASK 0xFFFFFF +#define CSIO_WORD_TO_BYTE 4 + +#ifndef readq +static inline u64 readq (void __iomem *addr) +{ +return readl (addr) + ((u64 )readl (addr +4 ) <<32 ); +} + +static inline void writeq (u64 val,void __iomem *addr) +{ +writel (val, addr); +writel (val >>32 , addr +4 ); +} +#endif + +static inline int +csio_list_deleted (struct list_head *list) +{ +return ((list->next == list) && (list->prev == list)); +} + +#define csio_list_next (elem) (((struct list_head *)(elem))->next) +#define csio_list_prev (elem) (((struct list_head *)(elem))->prev) + +/* State machine */ +typedef void (*csio_sm_state_t )(void *,uint32_t ); + +struct csio_sm { +struct list_head sm_list; +csio_sm_state_t sm_state; +}; + +static inline void +csio_set_state (void *smp,void *state) +{ + ((struct csio_sm *)smp)->sm_state = (csio_sm_state_t )state; +} + +static inline void +csio_init_state (struct csio_sm *smp,void *state) +{ +csio_set_state (smp, state); +} + +static inline void +csio_post_event (void *smp,uint32_t evt) +{ + ((struct csio_sm *)smp)->sm_state (smp, evt); +} + +static inline csio_sm_state_t +csio_get_state (void *smp) +{ +return ((struct csio_sm *)smp)->sm_state; +} + +static inline bool +csio_match_state (void *smp,void *state) +{ +return (csio_get_state (smp) == (csio_sm_state_t )state); +} + +#define CSIO_ASSERT (cond) BUG_ON(!(cond)) + +#ifdef __CSIO_DEBUG__ +#define CSIO_DB_ASSERT (__c) CSIO_ASSERT((__c)) +#else +#define CSIO_DB_ASSERT (__c) +#endif + +#endif /* ifndef __CSIO_DEFS_H__ */
drivers/scsi/csiostor/csio_hw.h new file +666 -0
666 lines not on this page · raw message
drivers/scsi/csiostor/csio_init.h new file +158 -0
158 lines not on this page · raw message
drivers/scsi/csiostor/t4fw_api_stor.h new file +578 -0
578 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v5 3/8 csiostor: Chelsio FCoE offload driver submission (headers part 2).
In reply to Naresh Kumar InnaThis patch contains the second set of the header files for csiostor driver.
--- drivers/scsi/csiostor/csio_lnode.h | 255 ++++++++++++++++++ drivers/scsi/csiostor/csio_mb.h | 278 +++++++++++++++++++ drivers/scsi/csiostor/csio_rnode.h | 141 ++++++++++ drivers/scsi/csiostor/csio_scsi.h | 342 ++++++++++++++++++++++++ drivers/scsi/csiostor/csio_wr.h | 512 ++++++++++++++++++++++++++++++++++++ 5 files changed, 1528 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/csiostor/csio_lnode.h create mode 100644 drivers/scsi/csiostor/csio_mb.h create mode 100644 drivers/scsi/csiostor/csio_rnode.h create mode 100644 drivers/scsi/csiostor/csio_scsi.h create mode 100644 drivers/scsi/csiostor/csio_wr.h
drivers/scsi/csiostor/csio_lnode.h new file +255 -0
@@ -0,0 +1,255 @@ +/* +* This file is part of the Chelsio FCoE driver for Linux. +* +* Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. +* +* This software is available to you under a choice of one of two +* licenses. You may choose to be licensed under the terms of the GNU +* General Public License (GPL) Version 2, available from the file +* COPYING in the main directory of this source tree, or the +* OpenIB.org BSD license below: +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* +* - Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. +* +* - Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#ifndef __CSIO_LNODE_H__ +#define __CSIO_LNODE_H__ + +#include <linux/kref.h> +#include <linux/timer.h> +#include <linux/workqueue.h> +#include <scsi/fc/fc_els.h> + + +#include "csio_defs.h" +#include "csio_hw.h" + +#define CSIO_FCOE_MAX_NPIV 128 +#define CSIO_FCOE_MAX_RNODES 2048 + +/* FDMI port attribute unknown speed */ +#define CSIO_HBA_PORTSPEED_UNKNOWN 0x8000 + +extern int csio_fcoe_rnodes; +extern int csio_fdmi_enable; + +/* State machine evets */ +enum csio_ln_ev { +CSIO_LNE_NONE = (uint32_t )0 , +CSIO_LNE_LINKUP , +CSIO_LNE_FAB_INIT_DONE , +CSIO_LNE_LINK_DOWN , +CSIO_LNE_DOWN_LINK , +CSIO_LNE_LOGO , +CSIO_LNE_CLOSE , +CSIO_LNE_MAX_EVENT , +}; + + +struct csio_fcf_info { +struct list_head list; +uint8_t priority; +uint8_t mac[6 ]; +uint8_t name_id[8 ]; +uint8_t fabric[8 ]; +uint16_t vf_id; +uint8_t vlan_id; +uint16_t max_fcoe_size; +uint8_t fc_map[3 ]; +uint32_t fka_adv; +uint32_t fcfi; +uint8_t get_next:1 ; +uint8_t link_aff:1 ; +uint8_t fpma:1 ; +uint8_t spma:1 ; +uint8_t login:1 ; +uint8_t portid; +uint8_t spma_mac[6 ]; +struct kref kref; +}; + +/* Defines for flags */ +#define CSIO_LNF_FIPSUPP 0x00000001/* Fip Supported */ +#define CSIO_LNF_NPIVSUPP 0x00000002/* NPIV supported */ +#define CSIO_LNF_LINK_ENABLE 0x00000004/* Link enabled */ +#define CSIO_LNF_FDMI_ENABLE 0x00000008/* FDMI support */ + +/* Transport events */ +enum csio_ln_fc_evt { +CSIO_LN_FC_LINKUP =1 , +CSIO_LN_FC_LINKDOWN , +CSIO_LN_FC_RSCN , +CSIO_LN_FC_ATTRIB_UPDATE , +}; + +/* Lnode stats */ +struct csio_lnode_stats { +uint32_t n_link_up;/* Link down */ +uint32_t n_link_down;/* Link up */ +uint32_t n_err;/* error */ +uint32_t n_err_nomem;/* memory not available */ +uint32_t n_inval_parm;/* Invalid parameters */ +uint32_t n_evt_unexp;/* unexpected event */ +uint32_t n_evt_drop;/* dropped event */ +uint32_t n_rnode_match;/* matched rnode */ +uint32_t n_dev_loss_tmo;/* Device loss timeout */ +uint32_t n_fdmi_err;/* fdmi err */ +uint32_t n_evt_fw[RSCN_DEV_LOST ];/* fw events */ +enum csio_ln_ev n_evt_sm[CSIO_LNE_MAX_EVENT ];/* State m/c events */ +uint32_t n_rnode_alloc;/* rnode allocated */ +uint32_t n_rnode_free;/* rnode freed */ +uint32_t n_rnode_nomem;/* rnode alloc failure */ +uint32_t n_input_requests;/* Input Requests */ +uint32_t n_output_requests;/* Output Requests */ +uint32_t n_control_requests;/* Control Requests */ +uint32_t n_input_bytes;/* Input Bytes */ +uint32_t n_output_bytes;/* Output Bytes */ +uint32_t rsvd1; +}; + +/* Common Lnode params */ +struct csio_lnode_params { +uint32_t ra_tov; +uint32_t fcfi; +uint32_t log_level;/* Module level for debugging */ +}; + +struct csio_service_parms { +struct fc_els_csp csp;/* Common service parms */ +uint8_t wwpn[8 ];/* WWPN */ +uint8_t wwnn[8 ];/* WWNN */ +struct fc_els_cssp clsp[4 ];/* Class service params */ +uint8_t vvl[16 ];/* Vendor version level */ +}; + +/* Lnode */ +struct csio_lnode { +struct csio_sm sm;/* State machine + sibling +* lnode list. +*/ +struct csio_hw *hwp;/* Pointer to the HW module */ +uint8_t portid;/* Port ID */ +uint8_t rsvd1; +uint16_t rsvd2; +uint32_t dev_num;/* Device number */ +uint32_t flags;/* Flags */ +struct list_head fcf_lsthead;/* FCF entries */ +struct csio_fcf_info *fcfinfo;/* FCF in use */ +struct csio_ioreq *mgmt_req;/* MGMT request */ + +/* FCoE identifiers */ +uint8_t mac[6 ]; +uint32_t nport_id; +struct csio_service_parms ln_sparm;/* Service parms */ + +/* Firmware identifiers */ +uint32_t fcf_flowid;/*fcf flowid */ +uint32_t vnp_flowid; +uint16_t ssn_cnt;/* Registered Session */ +uint8_t cur_evt;/* Current event */ +uint8_t prev_evt;/* Previous event */ + +/* Children */ +struct list_head cln_head;/* Head of the children lnode +* list. +*/ +uint32_t num_vports;/* Total NPIV/children LNodes*/ +struct csio_lnode *pln;/* Parent lnode of child +* lnodes. +*/ +struct list_head cmpl_q;/* Pending I/Os on this lnode */ + +/* Remote node information */ +struct list_head rnhead;/* Head of rnode list */ +uint32_t num_reg_rnodes;/* Number of rnodes registered +* with the host. +*/ +uint32_t n_scsi_tgts;/* Number of scsi targets +* found +*/ +uint32_t last_scan_ntgts;/* Number of scsi targets +* found per last scan. +*/ +uint32_t tgt_scan_tick;/* timer started after +* new tgt found +*/ +/* FC transport data */ +struct fc_vport *fc_vport; +struct fc_host_statistics fch_stats; + +struct csio_lnode_stats stats;/* Common lnode stats */ +struct csio_lnode_params params;/* Common lnode params */ +}; + +#define csio_lnode_to_hw (ln) ((ln)->hwp) +#define csio_root_lnode (ln) (csio_lnode_to_hw((ln))->rln) +#define csio_parent_lnode (ln) ((ln)->pln) +#define csio_ln_flowid (ln) ((ln)->vnp_flowid) +#define csio_ln_wwpn (ln) ((ln)->ln_sparm.wwpn) +#define csio_ln_wwnn (ln) ((ln)->ln_sparm.wwnn) + +#define csio_is_root_ln (ln) (((ln) == csio_root_lnode((ln))) ? 1 : 0) +#define csio_is_phys_ln (ln) (((ln)->pln == NULL) ? 1 : 0) +#define csio_is_npiv_ln (ln) (((ln)->pln != NULL) ? 1 : 0) + + +#define csio_ln_dbg (_ln, _fmt, ...) \ + csio_dbg(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \ + CSIO_DEVID_LO(_ln), ##__VA_ARGS__); + +#define csio_ln_err (_ln, _fmt, ...) \ + csio_err(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \ + CSIO_DEVID_LO(_ln), ##__VA_ARGS__); + +#define csio_ln_warn (_ln, _fmt, ...) \ + csio_warn(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \ + CSIO_DEVID_LO(_ln), ##__VA_ARGS__); + +/* HW->Lnode notifications */ +enum csio_ln_notify { +CSIO_LN_NOTIFY_HWREADY =1 , +CSIO_LN_NOTIFY_HWSTOP , +CSIO_LN_NOTIFY_HWREMOVE , +CSIO_LN_NOTIFY_HWRESET , +}; + +void csio_fcoe_fwevt_handler (struct csio_hw *,__u8 cpl_op,__be64 *); +int csio_is_lnode_ready (struct csio_lnode *); +void csio_lnode_state_to_str (struct csio_lnode *ln,int8_t *str); +struct csio_lnode *csio_lnode_lookup_by_wwpn (struct csio_hw *,uint8_t *); +int csio_get_phy_port_stats (struct csio_hw *,uint8_t , +struct fw_fcoe_port_stats *); +int csio_scan_done (struct csio_lnode *,unsigned long ,unsigned long , +unsigned long ,unsigned long ); +void csio_notify_lnodes (struct csio_hw *,enum csio_ln_notify ); +void csio_disable_lnodes (struct csio_hw *,uint8_t ,bool ); +void csio_lnode_async_event (struct csio_lnode *,enum csio_ln_fc_evt ); +int csio_ln_fdmi_start (struct csio_lnode *,void *); +int csio_lnode_start (struct csio_lnode *); +void csio_lnode_stop (struct csio_lnode *); +void csio_lnode_close (struct csio_lnode *); +int csio_lnode_init (struct csio_lnode *,struct csio_hw *, +struct csio_lnode *); +void csio_lnode_exit (struct csio_lnode *); + +#endif /* ifndef __CSIO_LNODE_H__ */
drivers/scsi/csiostor/csio_mb.h new file +278 -0
278 lines not on this page · raw message
drivers/scsi/csiostor/csio_rnode.h new file +141 -0
141 lines not on this page · raw message
drivers/scsi/csiostor/csio_scsi.h new file +342 -0
342 lines not on this page · raw message
drivers/scsi/csiostor/csio_wr.h new file +512 -0
512 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v5 4/8 csiostor: Chelsio FCoE offload driver submission (sources part 1).
In reply to Naresh Kumar InnaThis patch contains code for driver initialization, driver resource allocation and the Work Request module functionality. Driver initialization includes module entry/exit points, registration with PCI, FC transport and SCSI mid layer subsystems. The Work Request module provides services for allocation of DMA queues, posting Work Requests on them and processing completions.
---
V2: Removed module parameters.
V3: Corrected comment.
V5:
- Removed needless header inclusion.
- Re-wrote error paths to reduce lock/unlock ambiguity.
drivers/scsi/csiostor/csio_init.c | 1274 +++++++++++++++++++++++++++++ drivers/scsi/csiostor/csio_wr.c | 1632 +++++++++++++++++++++++++++++++++++++ 2 files changed, 2906 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/csiostor/csio_init.c create mode 100644 drivers/scsi/csiostor/csio_wr.c
drivers/scsi/csiostor/csio_init.c new file +1274 -0
@@ -0,0 +1,1274 @@ +/* +* This file is part of the Chelsio FCoE driver for Linux. +* +* Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. +* +* This software is available to you under a choice of one of two +* licenses. You may choose to be licensed under the terms of the GNU +* General Public License (GPL) Version 2, available from the file +* COPYING in the main directory of this source tree, or the +* OpenIB.org BSD license below: +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* +* - Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. +* +* - Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/pci.h> +#include <linux/aer.h> +#include <linux/mm.h> +#include <linux/notifier.h> +#include <linux/kdebug.h> +#include <linux/seq_file.h> +#include <linux/debugfs.h> +#include <linux/string.h> +#include <linux/export.h> + +#include "csio_init.h" +#include "csio_defs.h" + +#define CSIO_MIN_MEMPOOL_SZ 64 + +static struct dentry *csio_debugfs_root; + +static struct scsi_transport_template *csio_fcoe_transport; +static struct scsi_transport_template *csio_fcoe_transport_vport; + +/* +* debugfs support +*/ +static int +csio_mem_open (struct inode *inode,struct file *file) +{ + file->private_data = inode->i_private; +return 0 ; +} + +static ssize_t +csio_mem_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) +{ +loff_t pos = *ppos; +loff_t avail = file->f_path.dentry->d_inode->i_size; +unsigned int mem = (uintptr_t )file->private_data &3 ; +struct csio_hw *hw = file->private_data - mem; + +if (pos <0 ) +return -EINVAL ; +if (pos >= avail) +return 0 ; +if (count > avail - pos) + count = avail - pos; + +while (count) { +size_t len; +int ret, ofst; +__be32 data[16 ]; + +if (mem ==MEM_MC ) + ret =csio_hw_mc_read (hw, pos, data,NULL ); +else + ret =csio_hw_edc_read (hw, mem, pos, data,NULL ); +if (ret) +return ret; + + ofst = pos %sizeof (data); + len =min (count,sizeof (data) - ofst); +if (copy_to_user (buf, (u8 *)data + ofst, len)) +return -EFAULT ; + + buf += len; + pos += len; + count -= len; + } + count = pos - *ppos; + *ppos = pos; +return count; +} + +static const struct file_operations csio_mem_debugfs_fops = { + .owner =THIS_MODULE , + .open = csio_mem_open, + .read = csio_mem_read, + .llseek = default_llseek, +}; + +static void __devinit +csio_add_debugfs_mem (struct csio_hw *hw,const char *name, +unsigned int idx,unsigned int size_mb) +{ +struct dentry *de; + + de =debugfs_create_file (name,S_IRUSR , hw->debugfs_root, + (void *)hw + idx, &csio_mem_debugfs_fops); +if (de && de->d_inode) + de->d_inode->i_size = size_mb <<20 ; +} + +static int __devinit +csio_setup_debugfs (struct csio_hw *hw) +{ +int i; + +if (IS_ERR_OR_NULL (hw->debugfs_root)) +return -1 ; + + i =csio_rd_reg32 (hw,MA_TARGET_MEM_ENABLE ); +if (i &EDRAM0_ENABLE ) +csio_add_debugfs_mem (hw,"edc0" ,MEM_EDC0 ,5 ); +if (i &EDRAM1_ENABLE ) +csio_add_debugfs_mem (hw,"edc1" ,MEM_EDC1 ,5 ); +if (i &EXT_MEM_ENABLE ) +csio_add_debugfs_mem (hw,"mc" ,MEM_MC , +EXT_MEM_SIZE_GET (csio_rd_reg32 (hw,MA_EXT_MEMORY_BAR ))); +return 0 ; +} + +/* +* csio_dfs_create - Creates and sets up per-hw debugfs. +* +*/ +static int +csio_dfs_create (struct csio_hw *hw) +{ +if (csio_debugfs_root) { + hw->debugfs_root =debugfs_create_dir (pci_name (hw->pdev), + csio_debugfs_root); +csio_setup_debugfs (hw); + } + +return 0 ; +} + +/* +* csio_dfs_destroy - Destroys per-hw debugfs. +*/ +static int +csio_dfs_destroy (struct csio_hw *hw) +{ +if (hw->debugfs_root) +debugfs_remove_recursive (hw->debugfs_root); + +return 0 ; +} + +/* +* csio_dfs_init - Debug filesystem initialization for the module. +* +*/ +static int +csio_dfs_init (void ) +{ + csio_debugfs_root =debugfs_create_dir (KBUILD_MODNAME ,NULL ); +if (!csio_debugfs_root) +pr_warn ("Could not create debugfs entry, continuing\n" ); + +return 0 ; +} + +/* +* csio_dfs_exit - debugfs cleanup for the module. +*/ +static void +csio_dfs_exit (void ) +{ +debugfs_remove (csio_debugfs_root); +} + +/* +* csio_pci_init - PCI initialization. +* @pdev: PCI device. +* @bars: Bitmask of bars to be requested. +* +* Initializes the PCI function by enabling MMIO, setting bus +* mastership and setting DMA mask. +*/ +static int +csio_pci_init (struct pci_dev *pdev,int *bars) +{ +int rv = -ENODEV ; + + *bars =pci_select_bars (pdev,IORESOURCE_MEM ); + +if (pci_enable_device_mem (pdev)) + goto err; + +if (pci_request_selected_regions (pdev, *bars,KBUILD_MODNAME )) + goto err_disable_device; + +pci_set_master (pdev); +pci_try_set_mwi (pdev); + +if (!pci_set_dma_mask (pdev,DMA_BIT_MASK (64 ))) { +pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (64 )); + }else if (!pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ))) { +pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (32 )); + }else { +dev_err (&pdev->dev,"No suitable DMA available.\n" ); + goto err_release_regions; + } + +return 0 ; + +err_release_regions: +pci_release_selected_regions (pdev, *bars); +err_disable_device: +pci_disable_device (pdev); +err: +return rv; + +} + +/* +* csio_pci_exit - PCI unitialization. +* @pdev: PCI device. +* @bars: Bars to be released. +* +*/ +static void +csio_pci_exit (struct pci_dev *pdev,int *bars) +{ +pci_release_selected_regions (pdev, *bars); +pci_disable_device (pdev); +} + +/* +* csio_hw_init_workers - Initialize the HW module's worker threads. +* @hw: HW module. +* +*/ +static void +csio_hw_init_workers (struct csio_hw *hw) +{ +INIT_WORK (&hw->evtq_work, csio_evtq_worker); +} + +static void +csio_hw_exit_workers (struct csio_hw *hw) +{ +cancel_work_sync (&hw->evtq_work); +flush_scheduled_work (); +} + +static int +csio_create_queues (struct csio_hw *hw) +{ +int i, j; +struct csio_mgmtm *mgmtm =csio_hw_to_mgmtm (hw); +int rv; +struct csio_scsi_cpu_info *info; + +if (hw->flags &CSIO_HWF_Q_FW_ALLOCED ) +return 0 ; + +if (hw->intr_mode !=CSIO_IM_MSIX ) { + rv =csio_wr_iq_create (hw,NULL , hw->intr_iq_idx, +0 , hw->pport[0 ].portid, false,NULL ); +if (rv !=0 ) { +csio_err (hw," Forward Interrupt IQ failed!: %d\n" , rv); +return rv; + } + } + +/* FW event queue */ + rv =csio_wr_iq_create (hw,NULL , hw->fwevt_iq_idx, +csio_get_fwevt_intr_idx (hw), + hw->pport[0 ].portid, true,NULL ); +if (rv !=0 ) { +csio_err (hw,"FW event IQ config failed!: %d\n" , rv); +return rv; + } + +/* Create mgmt queue */ + rv =csio_wr_eq_create (hw,NULL , mgmtm->eq_idx, + mgmtm->iq_idx, hw->pport[0 ].portid,NULL ); + +if (rv !=0 ) { +csio_err (hw,"Mgmt EQ create failed!: %d\n" , rv); + goto err; + } + +/* Create SCSI queues */ +for (i =0 ; i < hw->num_pports; i++) { + info = &hw->scsi_cpu_info[i]; + +for (j =0 ; j < info->max_cpus; j++) { +struct csio_scsi_qset *sqset = &hw->sqset[i][j]; + + rv =csio_wr_iq_create (hw,NULL , sqset->iq_idx, + sqset->intr_idx, i, false,NULL ); +if (rv !=0 ) { +csio_err (hw, +"SCSI module IQ config failed [%d][%d]:%d\n" , + i, j, rv); + goto err; + } + rv =csio_wr_eq_create (hw,NULL , sqset->eq_idx, + sqset->iq_idx, i,NULL ); +if (rv !=0 ) { +csio_err (hw, +"SCSI module EQ config failed [%d][%d]:%d\n" , + i, j, rv); + goto err; + } + }/* for all CPUs */ + }/* For all ports */ + + hw->flags |=CSIO_HWF_Q_FW_ALLOCED ; +return 0 ; +err: +csio_wr_destroy_queues (hw, true); +return -EINVAL ; +} + +/* +* csio_config_queues - Configure the DMA queues. +* @hw: HW module. +* +* Allocates memory for queues are registers them with FW. +*/ +int +csio_config_queues (struct csio_hw *hw) +{ +int i, j, idx, k =0 ; +int rv; +struct csio_scsi_qset *sqset; +struct csio_mgmtm *mgmtm =csio_hw_to_mgmtm (hw); +struct csio_scsi_qset *orig; +struct csio_scsi_cpu_info *info; + +if (hw->flags &CSIO_HWF_Q_MEM_ALLOCED ) +return csio_create_queues (hw); + +/* Calculate number of SCSI queues for MSIX we would like */ + hw->num_scsi_msix_cpus =num_online_cpus (); + hw->num_sqsets =num_online_cpus () * hw->num_pports; + +if (hw->num_sqsets >CSIO_MAX_SCSI_QSETS ) { + hw->num_sqsets =CSIO_MAX_SCSI_QSETS ; + hw->num_scsi_msix_cpus =CSIO_MAX_SCSI_CPU ; + } + +/* Initialize max_cpus, may get reduced during msix allocations */ +for (i =0 ; i < hw->num_pports; i++) + hw->scsi_cpu_info[i].max_cpus = hw->num_scsi_msix_cpus; + +csio_dbg (hw,"nsqsets:%d scpus:%d\n" , + hw->num_sqsets, hw->num_scsi_msix_cpus); + +csio_intr_enable (hw); + +if (hw->intr_mode !=CSIO_IM_MSIX ) { + +/* Allocate Forward interrupt iq. */ + hw->intr_iq_idx =csio_wr_alloc_q (hw,CSIO_INTR_IQSIZE , +CSIO_INTR_WRSIZE ,CSIO_INGRESS , + (void *)hw,0 ,0 ,NULL ); +if (hw->intr_iq_idx ==-1 ) { +csio_err (hw, +"Forward interrupt queue creation failed\n" ); + goto intr_disable; + } + } + +/* Allocate the FW evt queue */ + hw->fwevt_iq_idx =csio_wr_alloc_q (hw,CSIO_FWEVT_IQSIZE , +CSIO_FWEVT_WRSIZE , +CSIO_INGRESS , (void *)hw, +CSIO_FWEVT_FLBUFS ,0 , + csio_fwevt_intx_handler); +if (hw->fwevt_iq_idx ==-1 ) { +csio_err (hw,"FW evt queue creation failed\n" ); + goto intr_disable; + } + +/* Allocate the mgmt queue */ + mgmtm->eq_idx =csio_wr_alloc_q (hw,CSIO_MGMT_EQSIZE , +CSIO_MGMT_EQ_WRSIZE , +CSIO_EGRESS , (void *)hw,0 ,0 ,NULL ); +if (mgmtm->eq_idx ==-1 ) { +csio_err (hw,"Failed to alloc egress queue for mgmt module\n" ); + goto intr_disable; + } + +/* Use FW IQ for MGMT req completion */ + mgmtm->iq_idx = hw->fwevt_iq_idx; + +/* Allocate SCSI queues */ +for (i =0 ; i < hw->num_pports; i++) { + info = &hw->scsi_cpu_info[i]; + +for (j =0 ; j < hw->num_scsi_msix_cpus; j++) { + sqset = &hw->sqset[i][j]; + +if (j >= info->max_cpus) { + k = j % info->max_cpus; + orig = &hw->sqset[i][k]; + sqset->eq_idx = orig->eq_idx; + sqset->iq_idx = orig->iq_idx; +continue ; + } + + idx =csio_wr_alloc_q (hw, csio_scsi_eqsize,0 , +CSIO_EGRESS , (void *)hw,0 ,0 , +NULL ); +if (idx ==-1 ) { +csio_err (hw,"EQ creation failed for idx:%d\n" , + idx); + goto intr_disable; + } + + sqset->eq_idx = idx; + + idx =csio_wr_alloc_q (hw,CSIO_SCSI_IQSIZE , +CSIO_SCSI_IQ_WRSZ ,CSIO_INGRESS , + (void *)hw,0 ,0 , + csio_scsi_intx_handler); +if (idx ==-1 ) { +csio_err (hw,"IQ creation failed for idx:%d\n" , + idx); + goto intr_disable; + } + sqset->iq_idx = idx; + }/* for all CPUs */ + }/* For all ports */ + + hw->flags |=CSIO_HWF_Q_MEM_ALLOCED ; + + rv =csio_create_queues (hw); +if (rv !=0 ) + goto intr_disable; + +/* +* Now request IRQs for the vectors. In the event of a failure, +* cleanup is handled internally by this function. +*/ + rv =csio_request_irqs (hw); +if (rv !=0 ) +return -EINVAL ; + +return 0 ; + +intr_disable: +csio_intr_disable (hw, false); + +return -EINVAL ; +} + +static int +csio_resource_alloc (struct csio_hw *hw) +{ +struct csio_wrm *wrm =csio_hw_to_wrm (hw); +int rv = -ENOMEM ; + + wrm->num_q = ((CSIO_MAX_SCSI_QSETS *2 ) +CSIO_HW_NIQ + +CSIO_HW_NEQ +CSIO_HW_NFLQ +CSIO_HW_NINTXQ ); + + hw->mb_mempool =mempool_create_kmalloc_pool (CSIO_MIN_MEMPOOL_SZ , +sizeof (struct csio_mb )); +if (!hw->mb_mempool) + goto err; + + hw->rnode_mempool =mempool_create_kmalloc_pool (CSIO_MIN_MEMPOOL_SZ , +sizeof (struct csio_rnode )); +if (!hw->rnode_mempool) + goto err_free_mb_mempool; + + hw->scsi_pci_pool =pci_pool_create ("csio_scsi_pci_pool" , hw->pdev, +CSIO_SCSI_RSP_LEN ,8 ,0 ); +if (!hw->scsi_pci_pool) + goto err_free_rn_pool; + +return 0 ; + +err_free_rn_pool: +mempool_destroy (hw->rnode_mempool); + hw->rnode_mempool =NULL ; +err_free_mb_mempool: +mempool_destroy (hw->mb_mempool); + hw->mb_mempool =NULL ; +err: +return rv; +} + +static void +csio_resource_free (struct csio_hw *hw) +{ +pci_pool_destroy (hw->scsi_pci_pool); + hw->scsi_pci_pool =NULL ; +mempool_destroy (hw->rnode_mempool); + hw->rnode_mempool =NULL ; +mempool_destroy (hw->mb_mempool); + hw->mb_mempool =NULL ; +} + +/* +* csio_hw_alloc - Allocate and initialize the HW module. +* @pdev: PCI device. +* +* Allocates HW structure, DMA, memory resources, maps BARS to +* host memory and initializes HW module. +*/ +static struct csio_hw *__devinit +csio_hw_alloc (struct pci_dev *pdev) +{ +struct csio_hw *hw; + + hw =kzalloc (sizeof (struct csio_hw ),GFP_KERNEL ); +if (!hw) + goto err; + + hw->pdev = pdev; +strncpy (hw->drv_version,CSIO_DRV_VERSION ,32 ); + +/* memory pool/DMA pool allocation */ +if (csio_resource_alloc (hw)) + goto err_free_hw; + +/* Get the start address of registers from BAR 0 */ + hw->regstart =ioremap_nocache (pci_resource_start (pdev,0 ), +pci_resource_len (pdev,0 )); +if (!hw->regstart) { +csio_err (hw,"Could not map BAR 0, regstart = %p\n" , + hw->regstart); + goto err_resource_free; + } + +csio_hw_init_workers (hw); + +if (csio_hw_init (hw)) + goto err_unmap_bar; + +csio_dfs_create (hw); + +csio_dbg (hw,"hw:%p\n" , hw); + +return hw; + +err_unmap_bar: +csio_hw_exit_workers (hw); +iounmap (hw->regstart); +err_resource_free: +csio_resource_free (hw); +err_free_hw: +kfree (hw); +err: +return NULL ; +} + +/* +* csio_hw_free - Uninitialize and free the HW module. +* @hw: The HW module +* +* Disable interrupts, uninit the HW module, free resources, free hw. +*/ +static void +csio_hw_free (struct csio_hw *hw) +{ +csio_intr_disable (hw, true); +csio_hw_exit_workers (hw); +csio_hw_exit (hw); +iounmap (hw->regstart); +csio_dfs_destroy (hw); +csio_resource_free (hw); +kfree (hw); +} + +/** +* csio_shost_init - Create and initialize the lnode module. +* @hw: The HW module. +* @dev: The device associated with this invocation. +* @probe: Called from probe context or not? +* @os_pln: Parent lnode if any. +* +* Allocates lnode structure via scsi_host_alloc, initializes +* shost, initializes lnode module and registers with SCSI ML +* via scsi_host_add. This function is shared between physical and +* virtual node ports. +*/ +struct csio_lnode * +csio_shost_init (struct csio_hw *hw,struct device *dev, +bool probe,struct csio_lnode *pln) +{ +struct Scsi_Host *shost =NULL ; +struct csio_lnode *ln; + + csio_fcoe_shost_template.cmd_per_lun = csio_lun_qdepth; + csio_fcoe_shost_vport_template.cmd_per_lun = csio_lun_qdepth; + +/* +* hw->pdev is the physical port's PCI dev structure, +* which will be different from the NPIV dev structure. +*/ +if (dev == &hw->pdev->dev) + shost =scsi_host_alloc ( + &csio_fcoe_shost_template, +sizeof (struct csio_lnode )); +else + shost =scsi_host_alloc ( + &csio_fcoe_shost_vport_template, +sizeof (struct csio_lnode )); + +if (!shost) + goto err; + + ln =shost_priv (shost); +memset (ln,0 ,sizeof (struct csio_lnode )); + +/* Link common lnode to this lnode */ + ln->dev_num = (shost->host_no <<16 ); + + shost->can_queue =CSIO_MAX_QUEUE ; + shost->this_id =-1 ; + shost->unique_id = shost->host_no; + shost->max_cmd_len =16 ;/* Max CDB length supported */ + shost->max_id =min_t (uint32_t, csio_fcoe_rnodes, + hw->fres_info.max_ssns); + shost->max_lun =CSIO_MAX_LUN ; +if (dev == &hw->pdev->dev) + shost->transportt = csio_fcoe_transport; +else + shost->transportt = csio_fcoe_transport_vport; + +/* root lnode */ +if (!hw->rln) + hw->rln = ln; + +/* Other initialization here: Common, Transport specific */ +if (csio_lnode_init (ln, hw, pln)) + goto err_shost_put; + +if (scsi_add_host (shost, dev)) + goto err_lnode_exit; + +return ln; + +err_lnode_exit: +csio_lnode_exit (ln); +err_shost_put: +scsi_host_put (shost); +err: +return NULL ; +} + +/** +* csio_shost_exit - De-instantiate the shost. +* @ln: The lnode module corresponding to the shost. +* +*/ +void +csio_shost_exit (struct csio_lnode *ln) +{ +struct Scsi_Host *shost =csio_ln_to_shost (ln); +struct csio_hw *hw =csio_lnode_to_hw (ln); + +/* Inform transport */ +fc_remove_host (shost); + +/* Inform SCSI ML */ +scsi_remove_host (shost); + +/* Flush all the events, so that any rnode removal events +* already queued are all handled, before we remove the lnode. +*/ +spin_lock_irq (&hw->lock); +csio_evtq_flush (hw); +spin_unlock_irq (&hw->lock); + +csio_lnode_exit (ln); +scsi_host_put (shost); +} + +struct csio_lnode * +csio_lnode_alloc (struct csio_hw *hw) +{ +return csio_shost_init (hw, &hw->pdev->dev, false,NULL ); +} + +void +csio_lnodes_block_request (struct csio_hw *hw) +{ +struct Scsi_Host *shost; +struct csio_lnode *sln; +struct csio_lnode *ln; +struct list_head *cur_ln, *cur_cln; +struct csio_lnode **lnode_list; +int cur_cnt =0 , ii; + + lnode_list =kzalloc ((sizeof (struct csio_lnode *) * hw->num_lns), +GFP_KERNEL ); +if (!lnode_list) { +csio_err (hw,"Failed to allocate lnodes_list" ); +return ; + } + +spin_lock_irq (&hw->lock); +/* Traverse sibling lnodes */ +list_for_each (cur_ln, &hw->sln_head) { + sln = (struct csio_lnode *) cur_ln; + lnode_list[cur_cnt++] = sln; + +/* Traverse children lnodes */ +list_for_each (cur_cln, &sln->cln_head) + lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln; + } +spin_unlock_irq (&hw->lock); + +for (ii =0 ; ii < cur_cnt; ii++) { +csio_dbg (hw,"Blocking IOs on lnode: %p\n" , lnode_list[ii]); + ln = lnode_list[ii]; + shost =csio_ln_to_shost (ln); +scsi_block_requests (shost); + + } +kfree (lnode_list); +} + +void +csio_lnodes_unblock_request (struct csio_hw *hw) +{ +struct csio_lnode *ln; +struct Scsi_Host *shost; +struct csio_lnode *sln; +struct list_head *cur_ln, *cur_cln; +struct csio_lnode **lnode_list; +int cur_cnt =0 , ii; + + lnode_list =kzalloc ((sizeof (struct csio_lnode *) * hw->num_lns), +GFP_KERNEL ); +if (!lnode_list) { +csio_err (hw,"Failed to allocate lnodes_list" ); +return ; + } + +spin_lock_irq (&hw->lock); +/* Traverse sibling lnodes */ +list_for_each (cur_ln, &hw->sln_head) { + sln = (struct csio_lnode *) cur_ln; + lnode_list[cur_cnt++] = sln; + +/* Traverse children lnodes */ +list_for_each (cur_cln, &sln->cln_head) + lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln; + } +spin_unlock_irq (&hw->lock); + +for (ii =0 ; ii < cur_cnt; ii++) { +csio_dbg (hw,"unblocking IOs on lnode: %p\n" , lnode_list[ii]); + ln = lnode_list[ii]; + shost =csio_ln_to_shost (ln); +scsi_unblock_requests (shost); + } +kfree (lnode_list); +} + +void +csio_lnodes_block_by_port (struct csio_hw *hw,uint8_t portid) +{ +struct csio_lnode *ln; +struct Scsi_Host *shost; +struct csio_lnode *sln; +struct list_head *cur_ln, *cur_cln; +struct csio_lnode **lnode_list; +int cur_cnt =0 , ii; + + lnode_list =kzalloc ((sizeof (struct csio_lnode *) * hw->num_lns), +GFP_KERNEL ); +if (!lnode_list) { +csio_err (hw,"Failed to allocate lnodes_list" ); +return ; + } + +spin_lock_irq (&hw->lock); +/* Traverse sibling lnodes */ +list_for_each (cur_ln, &hw->sln_head) { + sln = (struct csio_lnode *) cur_ln; +if (sln->portid != portid) +continue ; + + lnode_list[cur_cnt++] = sln; + +/* Traverse children lnodes */ +list_for_each (cur_cln, &sln->cln_head) + lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln; + } +spin_unlock_irq (&hw->lock); + +for (ii =0 ; ii < cur_cnt; ii++) { +csio_dbg (hw,"Blocking IOs on lnode: %p\n" , lnode_list[ii]); + ln = lnode_list[ii]; + shost =csio_ln_to_shost (ln); +scsi_block_requests (shost); + } +kfree (lnode_list); +} + +void +csio_lnodes_unblock_by_port (struct csio_hw *hw,uint8_t portid) +{ +struct csio_lnode *ln; +struct Scsi_Host *shost; +struct csio_lnode *sln; +struct list_head *cur_ln, *cur_cln; +struct csio_lnode **lnode_list; +int cur_cnt =0 , ii; + + lnode_list =kzalloc ((sizeof (struct csio_lnode *) * hw->num_lns), +GFP_KERNEL ); +if (!lnode_list) { +csio_err (hw,"Failed to allocate lnodes_list" ); +return ; + } + +spin_lock_irq (&hw->lock); +/* Traverse sibling lnodes */ +list_for_each (cur_ln, &hw->sln_head) { + sln = (struct csio_lnode *) cur_ln; +if (sln->portid != portid) +continue ; + lnode_list[cur_cnt++] = sln; + +/* Traverse children lnodes */ +list_for_each (cur_cln, &sln->cln_head) + lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln; + } +spin_unlock_irq (&hw->lock); + +for (ii =0 ; ii < cur_cnt; ii++) { +csio_dbg (hw,"unblocking IOs on lnode: %p\n" , lnode_list[ii]); + ln = lnode_list[ii]; + shost =csio_ln_to_shost (ln); +scsi_unblock_requests (shost); + } +kfree (lnode_list); +} + +void +csio_lnodes_exit (struct csio_hw *hw,bool npiv) +{ +struct csio_lnode *sln; +struct csio_lnode *ln; +struct list_head *cur_ln, *cur_cln; +struct csio_lnode **lnode_list; +int cur_cnt =0 , ii; + + lnode_list =kzalloc ((sizeof (struct csio_lnode *) * hw->num_lns), +GFP_KERNEL ); +if (!lnode_list) { +csio_err (hw,"lnodes_exit: Failed to allocate lnodes_list.\n" ); +return ; + } + +/* Get all child lnodes(NPIV ports) */ +spin_lock_irq (&hw->lock); +list_for_each (cur_ln, &hw->sln_head) { + sln = (struct csio_lnode *) cur_ln; + +/* Traverse children lnodes */ +list_for_each (cur_cln, &sln->cln_head) + lnode_list[cur_cnt++] = (struct csio_lnode *) cur_cln; + } +spin_unlock_irq (&hw->lock); + +/* Delete NPIV lnodes */ +for (ii =0 ; ii < cur_cnt; ii++) { +csio_dbg (hw,"Deleting child lnode: %p\n" , lnode_list[ii]); + ln = lnode_list[ii]; +fc_vport_terminate (ln->fc_vport); + } + +/* Delete only npiv lnodes */ +if (npiv) + goto free_lnodes; + + cur_cnt =0 ; +/* Get all physical lnodes */ +spin_lock_irq (&hw->lock); +/* Traverse sibling lnodes */ +list_for_each (cur_ln, &hw->sln_head) { + sln = (struct csio_lnode *) cur_ln; + lnode_list[cur_cnt++] = sln; + } +spin_unlock_irq (&hw->lock); + +/* Delete physical lnodes */ +for (ii =0 ; ii < cur_cnt; ii++) { +csio_dbg (hw,"Deleting parent lnode: %p\n" , lnode_list[ii]); +csio_shost_exit (lnode_list[ii]); + } + +free_lnodes: +kfree (lnode_list); +} + +/* +* csio_lnode_init_post: Set lnode attributes after starting HW. +* @ln: lnode. +* +*/ +static void +csio_lnode_init_post (struct csio_lnode *ln) +{ +struct Scsi_Host *shost =csio_ln_to_shost (ln); + +csio_fchost_attr_init (ln); + +scsi_scan_host (shost); +} + +/* +* csio_probe_one - Instantiate this function. +* @pdev: PCI device +* @id: Device ID +* +* This is the .probe() callback of the driver. This function: +* - Initializes the PCI function by enabling MMIO, setting bus +* mastership and setting DMA mask. +* - Allocates HW structure, DMA, memory resources, maps BARS to +* host memory and initializes HW module. +* - Allocates lnode structure via scsi_host_alloc, initializes +* shost, initialized lnode module and registers with SCSI ML +* via scsi_host_add. +* - Enables interrupts, and starts the chip by kicking off the +* HW state machine. +* - Once hardware is ready, initiated scan of the host via +* scsi_scan_host. +*/ +static int __devinit +csio_probe_one (struct pci_dev *pdev,const struct pci_device_id *id) +{ +int rv; +int bars; +int i; +struct csio_hw *hw; +struct csio_lnode *ln; + + rv =csio_pci_init (pdev, &bars); +if (rv) + goto err; + + hw =csio_hw_alloc (pdev); +if (!hw) { + rv = -ENODEV ; + goto err_pci_exit; + } + +pci_set_drvdata (pdev, hw); + +if (csio_hw_start (hw) !=0 ) { +dev_err (&pdev->dev, +"Failed to start FW, continuing in debug mode.\n" ); +return 0 ; + } + +sprintf (hw->fwrev_str,"%u.%u.%u.%u\n" , +FW_HDR_FW_VER_MAJOR_GET (hw->fwrev), +FW_HDR_FW_VER_MINOR_GET (hw->fwrev), +FW_HDR_FW_VER_MICRO_GET (hw->fwrev), +FW_HDR_FW_VER_BUILD_GET (hw->fwrev)); + +for (i =0 ; i < hw->num_pports; i++) { + ln =csio_shost_init (hw, &pdev->dev, true,NULL ); +if (!ln) { + rv = -ENODEV ; +break ; + } +/* Initialize portid */ + ln->portid = hw->pport[i].portid; + +spin_lock_irq (&hw->lock); +if (csio_lnode_start (ln) !=0 ) + rv = -ENODEV ; +spin_unlock_irq (&hw->lock); + +if (rv) +break ; + +csio_lnode_init_post (ln); + } + +if (rv) + goto err_lnode_exit; + +return 0 ; + +err_lnode_exit: +csio_lnodes_block_request (hw); +spin_lock_irq (&hw->lock); +csio_hw_stop (hw); +spin_unlock_irq (&hw->lock); +csio_lnodes_unblock_request (hw); +pci_set_drvdata (hw->pdev,NULL ); +csio_lnodes_exit (hw,0 ); +csio_hw_free (hw); +err_pci_exit: +csio_pci_exit (pdev, &bars); +err: +dev_err (&pdev->dev,"probe of device failed: %d\n" , rv); +return rv; +} + +/* +* csio_remove_one - Remove one instance of the driver at this PCI function. +* @pdev: PCI device +* +* Used during hotplug operation. +*/ +static void __devexit +csio_remove_one (struct pci_dev *pdev) +{ +struct csio_hw *hw =pci_get_drvdata (pdev); +int bars =pci_select_bars (pdev,IORESOURCE_MEM ); + +csio_lnodes_block_request (hw); +spin_lock_irq (&hw->lock); + +/* Stops lnode, Rnode s/m +* Quiesce IOs. +* All sessions with remote ports are unregistered. +*/ +csio_hw_stop (hw); +spin_unlock_irq (&hw->lock); +csio_lnodes_unblock_request (hw); + +csio_lnodes_exit (hw,0 ); +csio_hw_free (hw); +pci_set_drvdata (pdev,NULL ); +csio_pci_exit (pdev, &bars); +} + +/* +* csio_pci_error_detected - PCI error was detected +* @pdev: PCI device +* +*/ +static pci_ers_result_t +csio_pci_error_detected (struct pci_dev *pdev,pci_channel_state_t state) +{ +struct csio_hw *hw =pci_get_drvdata (pdev); + +csio_lnodes_block_request (hw); +spin_lock_irq (&hw->lock); + +/* Post PCI error detected evt to HW s/m +* HW s/m handles this evt by quiescing IOs, unregisters rports +* and finally takes the device to offline. +*/ +csio_post_event (&hw->sm,CSIO_HWE_PCIERR_DETECTED ); +spin_unlock_irq (&hw->lock); +csio_lnodes_unblock_request (hw); +csio_lnodes_exit (hw,0 ); +csio_intr_disable (hw, true); +pci_disable_device (pdev); +return state == pci_channel_io_perm_failure ? +PCI_ERS_RESULT_DISCONNECT :PCI_ERS_RESULT_NEED_RESET ; +} + +/* +* csio_pci_slot_reset - PCI slot has been reset. +* @pdev: PCI device +* +*/ +static pci_ers_result_t +csio_pci_slot_reset (struct pci_dev *pdev) +{ +struct csio_hw *hw =pci_get_drvdata (pdev); +int ready; + +if (pci_enable_device (pdev)) { +dev_err (&pdev->dev,"cannot re-enable device in slot reset\n" ); +return PCI_ERS_RESULT_DISCONNECT ; + } + +pci_set_master (pdev); +pci_restore_state (pdev); +pci_save_state (pdev); +pci_cleanup_aer_uncorrect_error_status (pdev); + +/* Bring HW s/m to ready state. +* but don't resume IOs. +*/ +spin_lock_irq (&hw->lock); +csio_post_event (&hw->sm,CSIO_HWE_PCIERR_SLOT_RESET ); + ready =csio_is_hw_ready (hw); +spin_unlock_irq (&hw->lock); + +if (ready) { +return PCI_ERS_RESULT_RECOVERED ; + }else { +dev_err (&pdev->dev,"Can't initialize HW when in slot reset\n" ); +return PCI_ERS_RESULT_DISCONNECT ; + } +} + +/* +* csio_pci_resume - Resume normal operations +* @pdev: PCI device +* +*/ +static void +csio_pci_resume (struct pci_dev *pdev) +{ +struct csio_hw *hw =pci_get_drvdata (pdev); +struct csio_lnode *ln; +int rv =0 ; +int i; + +/* Bring the LINK UP and Resume IO */ + +for (i =0 ; i < hw->num_pports; i++) { + ln =csio_shost_init (hw, &pdev->dev, true,NULL ); +if (!ln) { + rv = -ENODEV ; +break ; + } +/* Initialize portid */ + ln->portid = hw->pport[i].portid; + +spin_lock_irq (&hw->lock); +if (csio_lnode_start (ln) !=0 ) + rv = -ENODEV ; +spin_unlock_irq (&hw->lock); + +if (rv) +break ; + +csio_lnode_init_post (ln); + } + +if (rv) + goto err_resume_exit; + +return ; + +err_resume_exit: +csio_lnodes_block_request (hw); +spin_lock_irq (&hw->lock); +csio_hw_stop (hw); +spin_unlock_irq (&hw->lock); +csio_lnodes_unblock_request (hw); +csio_lnodes_exit (hw,0 ); +csio_hw_free (hw); +dev_err (&pdev->dev,"resume of device failed: %d\n" , rv); +} + +static struct pci_error_handlers csio_err_handler = { + .error_detected = csio_pci_error_detected, + .slot_reset = csio_pci_slot_reset, + .resume = csio_pci_resume, +}; + +static DEFINE_PCI_DEVICE_TABLE (csio_pci_tbl) = { +CSIO_DEVICE (CSIO_DEVID_T440DBG_FCOE ,0 ),/* T440DBG FCOE */ +CSIO_DEVICE (CSIO_DEVID_T420CR_FCOE ,0 ),/* T420CR FCOE */ +CSIO_DEVICE (CSIO_DEVID_T422CR_FCOE ,0 ),/* T422CR FCOE */ +CSIO_DEVICE (CSIO_DEVID_T440CR_FCOE ,0 ),/* T440CR FCOE */ +CSIO_DEVICE (CSIO_DEVID_T420BCH_FCOE ,0 ),/* T420BCH FCOE */ +CSIO_DEVICE (CSIO_DEVID_T440BCH_FCOE ,0 ),/* T440BCH FCOE */ +CSIO_DEVICE (CSIO_DEVID_T440CH_FCOE ,0 ),/* T440CH FCOE */ +CSIO_DEVICE (CSIO_DEVID_T420SO_FCOE ,0 ),/* T420SO FCOE */ +CSIO_DEVICE (CSIO_DEVID_T420CX_FCOE ,0 ),/* T420CX FCOE */ +CSIO_DEVICE (CSIO_DEVID_T420BT_FCOE ,0 ),/* T420BT FCOE */ +CSIO_DEVICE (CSIO_DEVID_T404BT_FCOE ,0 ),/* T404BT FCOE */ +CSIO_DEVICE (CSIO_DEVID_B420_FCOE ,0 ),/* B420 FCOE */ +CSIO_DEVICE (CSIO_DEVID_B404_FCOE ,0 ),/* B404 FCOE */ +CSIO_DEVICE (CSIO_DEVID_T480CR_FCOE ,0 ),/* T480 CR FCOE */ +CSIO_DEVICE (CSIO_DEVID_T440LPCR_FCOE ,0 ),/* T440 LP-CR FCOE */ +CSIO_DEVICE (CSIO_DEVID_PE10K ,0 ),/* PE10K FCOE */ +CSIO_DEVICE (CSIO_DEVID_PE10K_PF1 ,0 ),/* PE10K FCOE on PF1 */ + {0 ,0 ,0 ,0 ,0 ,0 ,0 } +}; + + +static struct pci_driver csio_pci_driver = { + .name =KBUILD_MODNAME , + .driver = { + .owner =THIS_MODULE , + }, + .id_table = csio_pci_tbl, + .probe = csio_probe_one, + .remove = csio_remove_one, + .err_handler = &csio_err_handler, +}; + +/* +* csio_init - Chelsio storage driver initialization function. +* +*/ +static int __init +csio_init (void ) +{ +int rv = -ENOMEM ; + +pr_info ("%s %s\n" ,CSIO_DRV_DESC ,CSIO_DRV_VERSION ); + +csio_dfs_init (); + + csio_fcoe_transport =fc_attach_transport (&csio_fc_transport_funcs); +if (!csio_fcoe_transport) + goto err; + + csio_fcoe_transport_vport = +fc_attach_transport (&csio_fc_transport_vport_funcs); +if (!csio_fcoe_transport_vport) + goto err_vport; + + rv =pci_register_driver (&csio_pci_driver); +if (rv) + goto err_pci; + +return 0 ; + +err_pci: +fc_release_transport (csio_fcoe_transport_vport); +err_vport: +fc_release_transport (csio_fcoe_transport); +err: +csio_dfs_exit (); +return rv; +} + +/* +* csio_exit - Chelsio storage driver uninitialization . +* +* Function that gets called in the unload path. +*/ +static void __exit +csio_exit (void ) +{ +pci_unregister_driver (&csio_pci_driver); +csio_dfs_exit (); +fc_release_transport (csio_fcoe_transport_vport); +fc_release_transport (csio_fcoe_transport); +} + +module_init (csio_init); +module_exit (csio_exit); +MODULE_AUTHOR (CSIO_DRV_AUTHOR ); +MODULE_DESCRIPTION (CSIO_DRV_DESC ); +MODULE_LICENSE (CSIO_DRV_LICENSE ); +MODULE_DEVICE_TABLE (pci, csio_pci_tbl); +MODULE_VERSION (CSIO_DRV_VERSION ); +MODULE_FIRMWARE (CSIO_FW_FNAME );
drivers/scsi/csiostor/csio_wr.c new file +1632 -0
1,632 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v5 5/8 csiostor: Chelsio FCoE offload driver submission (sources part 2).
In reply to Naresh Kumar InnaThis patch contains code for the FC transport template callbacks and the Mailbox module functionality. The FC transport callbacks include Virtual Node ports creation and deletion, FC session registration, unregistration and teardown. The Mailbox module provides services to issue/track/cancel mailbox commands and wrappers for them.
---
V5: Re-wrote error paths to reduce lock/unlock ambiguity.
drivers/scsi/csiostor/csio_attr.c | 804 +++++++++++++++++ drivers/scsi/csiostor/csio_mb.c | 1769 +++++++++++++++++++++++++++++++++++++ 2 files changed, 2573 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/csiostor/csio_attr.c create mode 100644 drivers/scsi/csiostor/csio_mb.c
drivers/scsi/csiostor/csio_attr.c new file +804 -0
@@ -0,0 +1,804 @@ +/* +* This file is part of the Chelsio FCoE driver for Linux. +* +* Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. +* +* This software is available to you under a choice of one of two +* licenses. You may choose to be licensed under the terms of the GNU +* General Public License (GPL) Version 2, available from the file +* COPYING in the main directory of this source tree, or the +* OpenIB.org BSD license below: +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* +* - Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. +* +* - Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#include <linux/kernel.h> +#include <linux/string.h> +#include <linux/delay.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/pci.h> +#include <linux/mm.h> +#include <linux/jiffies.h> +#include <scsi/fc/fc_fs.h> + +#include "csio_init.h" + +static void +csio_vport_set_state (struct csio_lnode *ln); + +/* +* csio_reg_rnode - Register a remote port with FC transport. +* @rn: Rnode representing remote port. +* +* Call fc_remote_port_add() to register this remote port with FC transport. +* If remote port is Initiator OR Target OR both, change the role appropriately. +* +*/ +void +csio_reg_rnode (struct csio_rnode *rn) +{ +struct csio_lnode *ln =csio_rnode_to_lnode (rn); +struct Scsi_Host *shost =csio_ln_to_shost (ln); +struct fc_rport_identifiers ids; +struct fc_rport *rport; +struct csio_service_parms *sp; + + ids.node_name =wwn_to_u64 (csio_rn_wwnn (rn)); + ids.port_name =wwn_to_u64 (csio_rn_wwpn (rn)); + ids.port_id = rn->nport_id; + ids.roles =FC_RPORT_ROLE_UNKNOWN ; + +if (rn->role &CSIO_RNFR_INITIATOR || rn->role &CSIO_RNFR_TARGET ) { + rport = rn->rport; +CSIO_ASSERT (rport !=NULL ); + goto update_role; + } + + rn->rport =fc_remote_port_add (shost,0 , &ids); +if (!rn->rport) { +csio_ln_err (ln,"Failed to register rport = 0x%x.\n" , + rn->nport_id); +return ; + } + + ln->num_reg_rnodes++; + rport = rn->rport; +spin_lock_irq (shost->host_lock); + *((struct csio_rnode **)rport->dd_data) = rn; +spin_unlock_irq (shost->host_lock); + + sp = &rn->rn_sparm; + rport->maxframe_size = sp->csp.sp_bb_data; +if (ntohs (sp->clsp[2 ].cp_class) &FC_CPC_VALID ) + rport->supported_classes =FC_COS_CLASS3 ; +else + rport->supported_classes =FC_COS_UNSPECIFIED ; +update_role: +if (rn->role &CSIO_RNFR_INITIATOR ) + ids.roles |=FC_RPORT_ROLE_FCP_INITIATOR ; +if (rn->role &CSIO_RNFR_TARGET ) { + ids.roles |=FC_RPORT_ROLE_FCP_TARGET ; + ln->n_scsi_tgts++; + } + +if (ids.roles !=FC_RPORT_ROLE_UNKNOWN ) +fc_remote_port_rolechg (rport, ids.roles); + + rn->scsi_id = rport->scsi_target_id; + +csio_ln_dbg (ln,"Remote port x%x role 0x%x registered\n" , + rn->nport_id, ids.roles); +} + +/* +* csio_unreg_rnode - Unregister a remote port with FC transport. +* @rn: Rnode representing remote port. +* +* Call fc_remote_port_delete() to unregister this remote port with FC +* transport. +* +*/ +void +csio_unreg_rnode (struct csio_rnode *rn) +{ +struct csio_lnode *ln =csio_rnode_to_lnode (rn); +struct fc_rport *rport = rn->rport; + + rn->role &= ~(CSIO_RNFR_INITIATOR |CSIO_RNFR_TARGET ); +fc_remote_port_delete (rport); + ln->num_reg_rnodes--; + +if (ln->n_scsi_tgts) + ln->n_scsi_tgts--; + +if (ln->last_scan_ntgts) + ln->last_scan_ntgts--; + +csio_ln_dbg (ln,"Remote port x%x un-registered\n" , rn->nport_id); +} + +/* +* csio_lnode_async_event - Async events from local port. +* @ln: lnode representing local port. +* +* Async events from local node that FC transport/SCSI ML +* should be made aware of (Eg: RSCN). +*/ +void +csio_lnode_async_event (struct csio_lnode *ln,enum csio_ln_fc_evt fc_evt) +{ +switch (fc_evt) { +case CSIO_LN_FC_RSCN : +/* Get payload of rscn from ln */ +/* For each RSCN entry */ +/* +* fc_host_post_event(shost, +* fc_get_event_number(), +* FCH_EVT_RSCN, +* rscn_entry); +*/ +break ; +case CSIO_LN_FC_LINKUP : +/* send fc_host_post_event */ +/* set vport state */ +if (csio_is_npiv_ln (ln)) +csio_vport_set_state (ln); + +break ; +case CSIO_LN_FC_LINKDOWN : +/* send fc_host_post_event */ +/* set vport state */ +if (csio_is_npiv_ln (ln)) +csio_vport_set_state (ln); + +break ; +case CSIO_LN_FC_ATTRIB_UPDATE : +csio_fchost_attr_init (ln); +break ; +default : +break ; + } +} + +/* +* csio_fchost_attr_init - Initialize FC transport attributes +* @ln: Lnode. +* +*/ +void +csio_fchost_attr_init (struct csio_lnode *ln) +{ +struct Scsi_Host *shost =csio_ln_to_shost (ln); + +fc_host_node_name (shost) =wwn_to_u64 (csio_ln_wwnn (ln)); +fc_host_port_name (shost) =wwn_to_u64 (csio_ln_wwpn (ln)); + +fc_host_supported_classes (shost) =FC_COS_CLASS3 ; +fc_host_max_npiv_vports (shost) = + (csio_lnode_to_hw (ln))->fres_info.max_vnps; +fc_host_supported_speeds (shost) =FC_PORTSPEED_10GBIT | +FC_PORTSPEED_1GBIT ; + +fc_host_maxframe_size (shost) = ln->ln_sparm.csp.sp_bb_data; +memset (fc_host_supported_fc4s (shost),0 , +sizeof (fc_host_supported_fc4s (shost))); +fc_host_supported_fc4s (shost)[7 ] =1 ; + +memset (fc_host_active_fc4s (shost),0 , +sizeof (fc_host_active_fc4s (shost))); +fc_host_active_fc4s (shost)[7 ] =1 ; +} + +/* +* csio_get_host_port_id - sysfs entries for nport_id is +* populated/cached from this function +*/ +static void +csio_get_host_port_id (struct Scsi_Host *shost) +{ +struct csio_lnode *ln =shost_priv (shost); +struct csio_hw *hw =csio_lnode_to_hw (ln); + +spin_lock_irq (&hw->lock); +fc_host_port_id (shost) = ln->nport_id; +spin_unlock_irq (&hw->lock); +} + +/* +* csio_get_port_type - Return FC local port type. +* @shost: scsi host. +* +*/ +static void +csio_get_host_port_type (struct Scsi_Host *shost) +{ +struct csio_lnode *ln =shost_priv (shost); +struct csio_hw *hw =csio_lnode_to_hw (ln); + +spin_lock_irq (&hw->lock); +if (csio_is_npiv_ln (ln)) +fc_host_port_type (shost) =FC_PORTTYPE_NPIV ; +else +fc_host_port_type (shost) =FC_PORTTYPE_NPORT ; +spin_unlock_irq (&hw->lock); +} + +/* +* csio_get_port_state - Return FC local port state. +* @shost: scsi host. +* +*/ +static void +csio_get_host_port_state (struct Scsi_Host *shost) +{ +struct csio_lnode *ln =shost_priv (shost); +struct csio_hw *hw =csio_lnode_to_hw (ln); +char state[16 ]; + +spin_lock_irq (&hw->lock); + +csio_lnode_state_to_str (ln, state); +if (!strcmp (state,"READY" )) +fc_host_port_state (shost) =FC_PORTSTATE_ONLINE ; +else if (!strcmp (state,"OFFLINE" )) +fc_host_port_state (shost) =FC_PORTSTATE_LINKDOWN ; +else +fc_host_port_state (shost) =FC_PORTSTATE_UNKNOWN ; + +spin_unlock_irq (&hw->lock); +} + +/* +* csio_get_host_speed - Return link speed to FC transport. +* @shost: scsi host. +* +*/ +static void +csio_get_host_speed (struct Scsi_Host *shost) +{ +struct csio_lnode *ln =shost_priv (shost); +struct csio_hw *hw =csio_lnode_to_hw (ln); + +spin_lock_irq (&hw->lock); +switch (hw->pport[ln->portid].link_speed) { +case FW_PORT_CAP_SPEED_1G : +fc_host_speed (shost) =FC_PORTSPEED_1GBIT ; +break ; +case FW_PORT_CAP_SPEED_10G : +fc_host_speed (shost) =FC_PORTSPEED_10GBIT ; +break ; +default : +fc_host_speed (shost) =FC_PORTSPEED_UNKNOWN ; +break ; + } +spin_unlock_irq (&hw->lock); +} + +/* +* csio_get_host_fabric_name - Return fabric name +* @shost: scsi host. +* +*/ +static void +csio_get_host_fabric_name (struct Scsi_Host *shost) +{ +struct csio_lnode *ln =shost_priv (shost); +struct csio_rnode *rn =NULL ; +struct csio_hw *hw =csio_lnode_to_hw (ln); + +spin_lock_irq (&hw->lock); + rn =csio_rnode_lookup_portid (ln,FC_FID_FLOGI ); +if (rn) +fc_host_fabric_name (shost) =wwn_to_u64 (csio_rn_wwnn (rn)); +else +fc_host_fabric_name (shost) =0 ; +spin_unlock_irq (&hw->lock); +} + +/* +* csio_get_host_speed - Return FC transport statistics. +* @ln: Lnode. +* +*/ +static struct fc_host_statistics * +csio_get_stats (struct Scsi_Host *shost) +{ +struct csio_lnode *ln =shost_priv (shost); +struct csio_hw *hw =csio_lnode_to_hw (ln); +struct fc_host_statistics *fhs = &ln->fch_stats; +struct fw_fcoe_port_stats fcoe_port_stats; +uint64_t seconds; + +memset (&fcoe_port_stats,0 ,sizeof (struct fw_fcoe_port_stats )); +csio_get_phy_port_stats (hw, ln->portid, &fcoe_port_stats); + + fhs->tx_frames += (fcoe_port_stats.tx_bcast_frames + + fcoe_port_stats.tx_mcast_frames + + fcoe_port_stats.tx_ucast_frames + + fcoe_port_stats.tx_offload_frames); + fhs->tx_words += (fcoe_port_stats.tx_bcast_bytes + + fcoe_port_stats.tx_mcast_bytes + + fcoe_port_stats.tx_ucast_bytes + + fcoe_port_stats.tx_offload_bytes) / +CSIO_WORD_TO_BYTE ; + fhs->rx_frames += (fcoe_port_stats.rx_bcast_frames + + fcoe_port_stats.rx_mcast_frames + + fcoe_port_stats.rx_ucast_frames); + fhs->rx_words += (fcoe_port_stats.rx_bcast_bytes + + fcoe_port_stats.rx_mcast_bytes + + fcoe_port_stats.rx_ucast_bytes) / +CSIO_WORD_TO_BYTE ; + fhs->error_frames += fcoe_port_stats.rx_err_frames; + fhs->fcp_input_requests += ln->stats.n_input_requests; + fhs->fcp_output_requests += ln->stats.n_output_requests; + fhs->fcp_control_requests += ln->stats.n_control_requests; + fhs->fcp_input_megabytes += ln->stats.n_input_bytes >>20 ; + fhs->fcp_output_megabytes += ln->stats.n_output_bytes >>20 ; + fhs->link_failure_count = ln->stats.n_link_down; +/* Reset stats for the device */ + seconds =jiffies_to_msecs (jiffies) - hw->stats.n_reset_start; +do_div (seconds,1000 ); + fhs->seconds_since_last_reset = seconds; + +return fhs; +} + +/* +* csio_set_rport_loss_tmo - Set the rport dev loss timeout +* @rport: fc rport. +* @timeout: new value for dev loss tmo. +* +* If timeout is non zero set the dev_loss_tmo to timeout, else set +* dev_loss_tmo to one. +*/ +static void +csio_set_rport_loss_tmo (struct fc_rport *rport,uint32_t timeout) +{ +if (timeout) + rport->dev_loss_tmo = timeout; +else + rport->dev_loss_tmo =1 ; +} + +static void +csio_vport_set_state (struct csio_lnode *ln) +{ +struct fc_vport *fc_vport = ln->fc_vport; +struct csio_lnode *pln = ln->pln; +char state[16 ]; + +/* Set fc vport state based on phyiscal lnode */ +csio_lnode_state_to_str (pln, state); +if (strcmp (state,"READY" )) { +fc_vport_set_state (fc_vport,FC_VPORT_LINKDOWN ); +return ; + } + +if (!(pln->flags &CSIO_LNF_NPIVSUPP )) { +fc_vport_set_state (fc_vport,FC_VPORT_NO_FABRIC_SUPP ); +return ; + } + +/* Set fc vport state based on virtual lnode */ +csio_lnode_state_to_str (ln, state); +if (strcmp (state,"READY" )) { +fc_vport_set_state (fc_vport,FC_VPORT_LINKDOWN ); +return ; + } +fc_vport_set_state (fc_vport,FC_VPORT_ACTIVE ); +} + +static int +csio_fcoe_alloc_vnp (struct csio_hw *hw,struct csio_lnode *ln) +{ +struct csio_lnode *pln; +struct csio_mb *mbp; +struct fw_fcoe_vnp_cmd *rsp; +int ret =0 ; +int retry =0 ; + +/* Issue VNP cmd to alloc vport */ +/* Allocate Mbox request */ +spin_lock_irq (&hw->lock); + mbp =mempool_alloc (hw->mb_mempool,GFP_ATOMIC ); +if (!mbp) { +CSIO_INC_STATS (hw, n_err_nomem); + ret = -ENOMEM ; + goto out; + } + + pln = ln->pln; + ln->fcf_flowid = pln->fcf_flowid; + ln->portid = pln->portid; + +csio_fcoe_vnp_alloc_init_mb (ln, mbp,CSIO_MB_DEFAULT_TMO , + pln->fcf_flowid, pln->vnp_flowid,0 , +csio_ln_wwnn (ln),csio_ln_wwpn (ln),NULL ); + +for (retry =0 ; retry <3 ; retry++) { +/* FW is expected to complete vnp cmd in immediate mode +* without much delay. +* Otherwise, there will be increase in IO latency since HW +* lock is held till completion of vnp mbox cmd. +*/ + ret =csio_mb_issue (hw, mbp); +if (ret != -EBUSY ) +break ; + +/* Retry if mbox returns busy */ +spin_unlock_irq (&hw->lock); +msleep (2000 ); +spin_lock_irq (&hw->lock); + } + +if (ret) { +csio_ln_err (ln,"Failed to issue mbox FCoE VNP command\n" ); + goto out_free; + } + +/* Process Mbox response of VNP command */ + rsp = (struct fw_fcoe_vnp_cmd *)(mbp->mb); +if (FW_CMD_RETVAL_GET (ntohl (rsp->alloc_to_len16)) !=FW_SUCCESS ) { +csio_ln_err (ln,"FCOE VNP ALLOC cmd returned 0x%x!\n" , +FW_CMD_RETVAL_GET (ntohl (rsp->alloc_to_len16))); + ret = -EINVAL ; + goto out_free; + } + + ln->vnp_flowid =FW_FCOE_VNP_CMD_VNPI_GET ( +ntohl (rsp->gen_wwn_to_vnpi)); +memcpy (csio_ln_wwnn (ln), rsp->vnport_wwnn,8 ); +memcpy (csio_ln_wwpn (ln), rsp->vnport_wwpn,8 ); + +csio_ln_dbg (ln,"FCOE VNPI: 0x%x\n" , ln->vnp_flowid); +csio_ln_dbg (ln,"\tWWNN: %x%x%x%x%x%x%x%x\n" , + ln->ln_sparm.wwnn[0 ], ln->ln_sparm.wwnn[1 ], + ln->ln_sparm.wwnn[2 ], ln->ln_sparm.wwnn[3 ], + ln->ln_sparm.wwnn[4 ], ln->ln_sparm.wwnn[5 ], + ln->ln_sparm.wwnn[6 ], ln->ln_sparm.wwnn[7 ]); +csio_ln_dbg (ln,"\tWWPN: %x%x%x%x%x%x%x%x\n" , + ln->ln_sparm.wwpn[0 ], ln->ln_sparm.wwpn[1 ], + ln->ln_sparm.wwpn[2 ], ln->ln_sparm.wwpn[3 ], + ln->ln_sparm.wwpn[4 ], ln->ln_sparm.wwpn[5 ], + ln->ln_sparm.wwpn[6 ], ln->ln_sparm.wwpn[7 ]); + +out_free: +mempool_free (mbp, hw->mb_mempool); +out: +spin_unlock_irq (&hw->lock); +return ret; +} + +static int +csio_fcoe_free_vnp (struct csio_hw *hw,struct csio_lnode *ln) +{ +struct csio_lnode *pln; +struct csio_mb *mbp; +struct fw_fcoe_vnp_cmd *rsp; +int ret =0 ; +int retry =0 ; + +/* Issue VNP cmd to free vport */ +/* Allocate Mbox request */ + +spin_lock_irq (&hw->lock); + mbp =mempool_alloc (hw->mb_mempool,GFP_ATOMIC ); +if (!mbp) { +CSIO_INC_STATS (hw, n_err_nomem); + ret = -ENOMEM ; + goto out; + } + + pln = ln->pln; + +csio_fcoe_vnp_free_init_mb (ln, mbp,CSIO_MB_DEFAULT_TMO , + ln->fcf_flowid, ln->vnp_flowid, +NULL ); + +for (retry =0 ; retry <3 ; retry++) { + ret =csio_mb_issue (hw, mbp); +if (ret != -EBUSY ) +break ; + +/* Retry if mbox returns busy */ +spin_unlock_irq (&hw->lock); +msleep (2000 ); +spin_lock_irq (&hw->lock); + } + +if (ret) { +csio_ln_err (ln,"Failed to issue mbox FCoE VNP command\n" ); + goto out_free; + } + +/* Process Mbox response of VNP command */ + rsp = (struct fw_fcoe_vnp_cmd *)(mbp->mb); +if (FW_CMD_RETVAL_GET (ntohl (rsp->alloc_to_len16)) !=FW_SUCCESS ) { +csio_ln_err (ln,"FCOE VNP FREE cmd returned 0x%x!\n" , +FW_CMD_RETVAL_GET (ntohl (rsp->alloc_to_len16))); + ret = -EINVAL ; + } + +out_free: +mempool_free (mbp, hw->mb_mempool); +out: +spin_unlock_irq (&hw->lock); +return ret; +} + +static int +csio_vport_create (struct fc_vport *fc_vport,bool disable) +{ +struct Scsi_Host *shost = fc_vport->shost; +struct csio_lnode *pln =shost_priv (shost); +struct csio_lnode *ln =NULL ; +struct csio_hw *hw =csio_lnode_to_hw (pln); +uint8_t wwn[8 ]; +int ret =-1 ; + + ln =csio_shost_init (hw, &fc_vport->dev, false, pln); +if (!ln) + goto error; + +if (fc_vport->node_name !=0 ) { +u64_to_wwn (fc_vport->node_name, wwn); + +if (!CSIO_VALID_WWN (wwn)) { +csio_ln_err (ln, +"vport create failed. Invalid wwnn\n" ); + goto error; + } +memcpy (csio_ln_wwnn (ln), wwn,8 ); + } + +if (fc_vport->port_name !=0 ) { +u64_to_wwn (fc_vport->port_name, wwn); + +if (!CSIO_VALID_WWN (wwn)) { +csio_ln_err (ln, +"vport create failed. Invalid wwpn\n" ); + goto error; + } + +if (csio_lnode_lookup_by_wwpn (hw, wwn)) { +csio_ln_err (ln, +"vport create failed. wwpn already exists\n" ); + goto error; + } +memcpy (csio_ln_wwpn (ln), wwn,8 ); + } + +fc_vport_set_state (fc_vport,FC_VPORT_INITIALIZING ); + +if (csio_fcoe_alloc_vnp (hw, ln)) + goto error; + + *(struct csio_lnode **)fc_vport->dd_data = ln; + ln->fc_vport = fc_vport; +if (!fc_vport->node_name) + fc_vport->node_name =wwn_to_u64 (csio_ln_wwnn (ln)); +if (!fc_vport->port_name) + fc_vport->port_name =wwn_to_u64 (csio_ln_wwpn (ln)); +csio_fchost_attr_init (ln); +return 0 ; +error: +if (ln) +csio_shost_exit (ln); + +return ret; +} + +static int +csio_vport_delete (struct fc_vport *fc_vport) +{ +struct csio_lnode *ln = *(struct csio_lnode **)fc_vport->dd_data; +struct Scsi_Host *shost =csio_ln_to_shost (ln); +struct csio_hw *hw =csio_lnode_to_hw (ln); +int rmv; + +spin_lock_irq (&hw->lock); + rmv =csio_is_hw_removing (hw); +spin_unlock_irq (&hw->lock); + +if (rmv) { +csio_shost_exit (ln); +return 0 ; + } + +/* Quiesce ios and send remove event to lnode */ +scsi_block_requests (shost); +spin_lock_irq (&hw->lock); +csio_scsim_cleanup_io_lnode (csio_hw_to_scsim (hw), ln); +csio_lnode_close (ln); +spin_unlock_irq (&hw->lock); +scsi_unblock_requests (shost); + +/* Free vnp */ +if (fc_vport->vport_state !=FC_VPORT_DISABLED ) +csio_fcoe_free_vnp (hw, ln); + +csio_shost_exit (ln); +return 0 ; +} + +static int +csio_vport_disable (struct fc_vport *fc_vport,bool disable) +{ +struct csio_lnode *ln = *(struct csio_lnode **)fc_vport->dd_data; +struct Scsi_Host *shost =csio_ln_to_shost (ln); +struct csio_hw *hw =csio_lnode_to_hw (ln); + +/* disable vport */ +if (disable) { +/* Quiesce ios and send stop event to lnode */ +scsi_block_requests (shost); +spin_lock_irq (&hw->lock); +csio_scsim_cleanup_io_lnode (csio_hw_to_scsim (hw), ln); +csio_lnode_stop (ln); +spin_unlock_irq (&hw->lock); +scsi_unblock_requests (shost); + +/* Free vnp */ +csio_fcoe_free_vnp (hw, ln); +fc_vport_set_state (fc_vport,FC_VPORT_DISABLED ); +csio_ln_err (ln,"vport disabled\n" ); +return 0 ; + }else { +/* enable vport */ +fc_vport_set_state (fc_vport,FC_VPORT_INITIALIZING ); +if (csio_fcoe_alloc_vnp (hw, ln)) { +csio_ln_err (ln,"vport enabled failed.\n" ); +return -1 ; + } +csio_ln_err (ln,"vport enabled\n" ); +return 0 ; + } +} + +static void +csio_dev_loss_tmo_callbk (struct fc_rport *rport) +{ +struct csio_rnode *rn; +struct csio_hw *hw; +struct csio_lnode *ln; + + rn = *((struct csio_rnode **)rport->dd_data); + ln =csio_rnode_to_lnode (rn); + hw =csio_lnode_to_hw (ln); + +spin_lock_irq (&hw->lock); + +/* return if driver is being removed or same rnode comes back online */ +if (csio_is_hw_removing (hw) ||csio_is_rnode_ready (rn)) + goto out; + +csio_ln_dbg (ln,"devloss timeout on rnode:%p portid:x%x flowid:x%x\n" , + rn, rn->nport_id,csio_rn_flowid (rn)); + +CSIO_INC_STATS (ln, n_dev_loss_tmo); + +/* +* enqueue devloss event to event worker thread to serialize all +* rnode events. +*/ +if (csio_enqueue_evt (hw,CSIO_EVT_DEV_LOSS , &rn,sizeof (rn))) { +CSIO_INC_STATS (hw, n_evt_drop); + goto out; + } + +if (!(hw->flags &CSIO_HWF_FWEVT_PENDING )) { + hw->flags |=CSIO_HWF_FWEVT_PENDING ; +spin_unlock_irq (&hw->lock); +schedule_work (&hw->evtq_work); +return ; + } + +out: +spin_unlock_irq (&hw->lock); +} + +/* FC transport functions template - Physical port */ +struct fc_function_template csio_fc_transport_funcs = { + .show_host_node_name =1 , + .show_host_port_name =1 , + .show_host_supported_classes =1 , + .show_host_supported_fc4s =1 , + .show_host_maxframe_size =1 , + + .get_host_port_id = csio_get_host_port_id, + .show_host_port_id =1 , + + .get_host_port_type = csio_get_host_port_type, + .show_host_port_type =1 , + + .get_host_port_state = csio_get_host_port_state, + .show_host_port_state =1 , + + .show_host_active_fc4s =1 , + .get_host_speed = csio_get_host_speed, + .show_host_speed =1 , + .get_host_fabric_name = csio_get_host_fabric_name, + .show_host_fabric_name =1 , + + .get_fc_host_stats = csio_get_stats, + + .dd_fcrport_size =sizeof (struct csio_rnode *), + .show_rport_maxframe_size =1 , + .show_rport_supported_classes =1 , + + .set_rport_dev_loss_tmo = csio_set_rport_loss_tmo, + .show_rport_dev_loss_tmo =1 , + + .show_starget_port_id =1 , + .show_starget_node_name =1 , + .show_starget_port_name =1 , + + .dev_loss_tmo_callbk = csio_dev_loss_tmo_callbk, + .dd_fcvport_size =sizeof (struct csio_lnode *), + + .vport_create = csio_vport_create, + .vport_disable = csio_vport_disable, + .vport_delete = csio_vport_delete, +}; + +/* FC transport functions template - Virtual port */ +struct fc_function_template csio_fc_transport_vport_funcs = { + .show_host_node_name =1 , + .show_host_port_name =1 , + .show_host_supported_classes =1 , + .show_host_supported_fc4s =1 , + .show_host_maxframe_size =1 , + + .get_host_port_id = csio_get_host_port_id, + .show_host_port_id =1 , + + .get_host_port_type = csio_get_host_port_type, + .show_host_port_type =1 , + + .get_host_port_state = csio_get_host_port_state, + .show_host_port_state =1 , + .show_host_active_fc4s =1 , + + .get_host_speed = csio_get_host_speed, + .show_host_speed =1 , + + .get_host_fabric_name = csio_get_host_fabric_name, + .show_host_fabric_name =1 , + + .get_fc_host_stats = csio_get_stats, + + .dd_fcrport_size =sizeof (struct csio_rnode *), + .show_rport_maxframe_size =1 , + .show_rport_supported_classes =1 , + + .set_rport_dev_loss_tmo = csio_set_rport_loss_tmo, + .show_rport_dev_loss_tmo =1 , + + .show_starget_port_id =1 , + .show_starget_node_name =1 , + .show_starget_port_name =1 , + + .dev_loss_tmo_callbk = csio_dev_loss_tmo_callbk, + +};
drivers/scsi/csiostor/csio_mb.c new file +1769 -0
1,769 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v5 6/8 csiostor: Chelsio FCoE offload driver submission (sources part 3).
In reply to Naresh Kumar InnaThis patch contains code to implement the local and remote node port functionality. It includes tracking the firmware events for changes to the states of these ports.
---
V5: Re-wrote error paths to reduce lock/unlock ambiguity.
drivers/scsi/csiostor/csio_lnode.c | 2133 ++++++++++++++++++++++++++++++++++++ drivers/scsi/csiostor/csio_rnode.c | 889 +++++++++++++++ 2 files changed, 3022 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/csiostor/csio_lnode.c create mode 100644 drivers/scsi/csiostor/csio_rnode.c
drivers/scsi/csiostor/csio_lnode.c new file +2133 -0
@@ -0,0 +1,2133 @@ +/* +* This file is part of the Chelsio FCoE driver for Linux. +* +* Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. +* +* This software is available to you under a choice of one of two +* licenses. You may choose to be licensed under the terms of the GNU +* General Public License (GPL) Version 2, available from the file +* COPYING in the main directory of this source tree, or the +* OpenIB.org BSD license below: +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* +* - Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. +* +* - Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#include <linux/kernel.h> +#include <linux/delay.h> +#include <linux/slab.h> +#include <linux/utsname.h> +#include <scsi/scsi_transport_fc.h> +#include <asm/unaligned.h> +#include <scsi/fc/fc_els.h> +#include <scsi/fc/fc_fs.h> +#include <scsi/fc/fc_gs.h> +#include <scsi/fc/fc_ms.h> + +#include "csio_hw.h" +#include "csio_mb.h" +#include "csio_lnode.h" +#include "csio_rnode.h" + +int csio_fcoe_rnodes =512 ; +int csio_fdmi_enable =1 ; + +#define PORT_ID_PTR (_x) ((uint8_t *)(&_x) + 1) + +/* Lnode SM declarations */ +static void csio_lns_uninit (struct csio_lnode *,enum csio_ln_ev ); +static void csio_lns_online (struct csio_lnode *,enum csio_ln_ev ); +static void csio_lns_ready (struct csio_lnode *,enum csio_ln_ev ); +static void csio_lns_offline (struct csio_lnode *,enum csio_ln_ev ); + +static int csio_ln_mgmt_submit_req (struct csio_ioreq *, +void (*io_cbfn) (struct csio_hw *,struct csio_ioreq *), +enum fcoe_cmn_type ,struct csio_dma_buf *,uint32_t ); + +/* LN event mapping */ +static enum csio_ln_ev fwevt_to_lnevt[] = { +CSIO_LNE_NONE ,/* None */ +CSIO_LNE_NONE ,/* PLOGI_ACC_RCVD */ +CSIO_LNE_NONE ,/* PLOGI_RJT_RCVD */ +CSIO_LNE_NONE ,/* PLOGI_RCVD */ +CSIO_LNE_NONE ,/* PLOGO_RCVD */ +CSIO_LNE_NONE ,/* PRLI_ACC_RCVD */ +CSIO_LNE_NONE ,/* PRLI_RJT_RCVD */ +CSIO_LNE_NONE ,/* PRLI_RCVD */ +CSIO_LNE_NONE ,/* PRLO_RCVD */ +CSIO_LNE_NONE ,/* NPORT_ID_CHGD */ +CSIO_LNE_LOGO ,/* FLOGO_RCVD */ +CSIO_LNE_LOGO ,/* CLR_VIRT_LNK_RCVD */ +CSIO_LNE_FAB_INIT_DONE ,/* FLOGI_ACC_RCVD */ +CSIO_LNE_NONE ,/* FLOGI_RJT_RCVD */ +CSIO_LNE_FAB_INIT_DONE ,/* FDISC_ACC_RCVD */ +CSIO_LNE_NONE ,/* FDISC_RJT_RCVD */ +CSIO_LNE_NONE ,/* FLOGI_TMO_MAX_RETRY */ +CSIO_LNE_NONE ,/* IMPL_LOGO_ADISC_ACC */ +CSIO_LNE_NONE ,/* IMPL_LOGO_ADISC_RJT */ +CSIO_LNE_NONE ,/* IMPL_LOGO_ADISC_CNFLT */ +CSIO_LNE_NONE ,/* PRLI_TMO */ +CSIO_LNE_NONE ,/* ADISC_TMO */ +CSIO_LNE_NONE ,/* RSCN_DEV_LOST */ +CSIO_LNE_NONE ,/* SCR_ACC_RCVD */ +CSIO_LNE_NONE ,/* ADISC_RJT_RCVD */ +CSIO_LNE_NONE ,/* LOGO_SNT */ +CSIO_LNE_NONE ,/* PROTO_ERR_IMPL_LOGO */ +}; + +#define CSIO_FWE_TO_LNE (_evt) ((_evt > PROTO_ERR_IMPL_LOGO) ? \ + CSIO_LNE_NONE : \ + fwevt_to_lnevt[_evt]) + +#define csio_ct_rsp (cp) (((struct fc_ct_hdr *)cp)->ct_cmd) +#define csio_ct_reason (cp) (((struct fc_ct_hdr *)cp)->ct_reason) +#define csio_ct_expl (cp) (((struct fc_ct_hdr *)cp)->ct_explan) +#define csio_ct_get_pld (cp) ((void *)(((uint8_t *)cp) + FC_CT_HDR_LEN)) + +/* +* csio_ln_match_by_portid - lookup lnode using given portid. +* @hw: HW module +* @portid: port-id. +* +* If found, returns lnode matching given portid otherwise returns NULL. +*/ +static struct csio_lnode * +csio_ln_lookup_by_portid (struct csio_hw *hw,uint8_t portid) +{ +struct csio_lnode *ln = hw->rln; +struct list_head *tmp; + +/* Match siblings lnode with portid */ +list_for_each (tmp, &hw->sln_head) { + ln = (struct csio_lnode *) tmp; +if (ln->portid == portid) +return ln; + } + +return NULL ; +} + +/* +* csio_ln_lookup_by_vnpi - Lookup lnode using given vnp id. +* @hw - HW module +* @vnpi - vnp index. +* Returns - If found, returns lnode matching given vnp id +* otherwise returns NULL. +*/ +static struct csio_lnode * +csio_ln_lookup_by_vnpi (struct csio_hw *hw,uint32_t vnp_id) +{ +struct list_head *tmp1, *tmp2; +struct csio_lnode *sln =NULL , *cln =NULL ; + +if (list_empty (&hw->sln_head)) { +CSIO_INC_STATS (hw, n_lnlkup_miss); +return NULL ; + } +/* Traverse sibling lnodes */ +list_for_each (tmp1, &hw->sln_head) { + sln = (struct csio_lnode *) tmp1; + +/* Match sibling lnode */ +if (sln->vnp_flowid == vnp_id) +return sln; + +if (list_empty (&sln->cln_head)) +continue ; + +/* Traverse children lnodes */ +list_for_each (tmp2, &sln->cln_head) { + cln = (struct csio_lnode *) tmp2; + +if (cln->vnp_flowid == vnp_id) +return cln; + } + } +CSIO_INC_STATS (hw, n_lnlkup_miss); +return NULL ; +} + +/** +* csio_lnode_lookup_by_wwpn - Lookup lnode using given wwpn. +* @hw: HW module. +* @wwpn: WWPN. +* +* If found, returns lnode matching given wwpn, returns NULL otherwise. +*/ +struct csio_lnode * +csio_lnode_lookup_by_wwpn (struct csio_hw *hw,uint8_t *wwpn) +{ +struct list_head *tmp1, *tmp2; +struct csio_lnode *sln =NULL , *cln =NULL ; + +if (list_empty (&hw->sln_head)) { +CSIO_INC_STATS (hw, n_lnlkup_miss); +return NULL ; + } +/* Traverse sibling lnodes */ +list_for_each (tmp1, &hw->sln_head) { + sln = (struct csio_lnode *) tmp1; + +/* Match sibling lnode */ +if (!memcmp (csio_ln_wwpn (sln), wwpn,8 )) +return sln; + +if (list_empty (&sln->cln_head)) +continue ; + +/* Traverse children lnodes */ +list_for_each (tmp2, &sln->cln_head) { + cln = (struct csio_lnode *) tmp2; + +if (!memcmp (csio_ln_wwpn (cln), wwpn,8 )) +return cln; + } + } +return NULL ; +} + +/* FDMI */ +static void +csio_fill_ct_iu (void *buf,uint8_t type,uint8_t sub_type,uint16_t op) +{ +struct fc_ct_hdr *cmd = (struct fc_ct_hdr *)buf; + cmd->ct_rev =FC_CT_REV ; + cmd->ct_fs_type = type; + cmd->ct_fs_subtype = sub_type; + cmd->ct_cmd = op; +} + +static int +csio_hostname (uint8_t *buf,size_t buf_len) +{ +if (snprintf (buf, buf_len,"%s" ,init_utsname ()->nodename) >0 ) +return 0 ; +return -1 ; +} + +static int +csio_osname (uint8_t *buf,size_t buf_len) +{ +if (snprintf (buf, buf_len,"%s %s %s" , +init_utsname ()->sysname, +init_utsname ()->release, +init_utsname ()->version) >0 ) +return 0 ; + +return -1 ; +} + +static inline void +csio_append_attrib (uint8_t **ptr,uint16_t type,uint8_t *val,uint16_t len) +{ +struct fc_fdmi_attr_entry *ae = (struct fc_fdmi_attr_entry *)*ptr; + ae->type =htons (type); + len +=4 ;/* includes attribute type and length */ + len = (len +3 ) & ~3 ;/* should be multiple of 4 bytes */ + ae->len =htons (len); +memset (ae->value,0 , len -4 ); +memcpy (ae->value, val, len); + *ptr += len; +} + +/* +* csio_ln_fdmi_done - FDMI registeration completion +* @hw: HW context +* @fdmi_req: fdmi request +*/ +static void +csio_ln_fdmi_done (struct csio_hw *hw,struct csio_ioreq *fdmi_req) +{ +void *cmd; +struct csio_lnode *ln = fdmi_req->lnode; + +if (fdmi_req->wr_status !=FW_SUCCESS ) { +csio_ln_err (ln,"WR error:%x in processing fdmi rpa cmd\n" , + fdmi_req->wr_status); +CSIO_INC_STATS (ln, n_fdmi_err); + } + + cmd = fdmi_req->dma_buf.vaddr; +if (ntohs (csio_ct_rsp (cmd)) !=FC_FS_ACC ) { +csio_ln_dbg (ln,"fdmi rpa cmd rejected reason %x expl %x\n" , +csio_ct_reason (cmd),csio_ct_expl (cmd)); + } +} + +/* +* csio_ln_fdmi_rhba_cbfn - RHBA completion +* @hw: HW context +* @fdmi_req: fdmi request +*/ +static void +csio_ln_fdmi_rhba_cbfn (struct csio_hw *hw,struct csio_ioreq *fdmi_req) +{ +void *cmd; +uint8_t *pld; +uint32_t len =0 ; +struct csio_lnode *ln = fdmi_req->lnode; +struct fs_fdmi_attrs *attrib_blk; +struct fc_fdmi_port_name *port_name; +uint8_t buf[64 ]; +uint32_t val; +uint8_t *fc4_type; + +if (fdmi_req->wr_status !=FW_SUCCESS ) { +csio_ln_err (ln,"WR error:%x in processing fdmi rhba cmd\n" , + fdmi_req->wr_status); +CSIO_INC_STATS (ln, n_fdmi_err); + } + + cmd = fdmi_req->dma_buf.vaddr; +if (ntohs (csio_ct_rsp (cmd)) !=FC_FS_ACC ) { +csio_ln_dbg (ln,"fdmi rhba cmd rejected reason %x expl %x\n" , +csio_ct_reason (cmd),csio_ct_expl (cmd)); + } + +if (!csio_is_rnode_ready (fdmi_req->rnode)) { +CSIO_INC_STATS (ln, n_fdmi_err); +return ; + } + +/* Prepare CT hdr for RPA cmd */ +memset (cmd,0 ,FC_CT_HDR_LEN ); +csio_fill_ct_iu (cmd,FC_FST_MGMT ,FC_FDMI_SUBTYPE ,htons (FC_FDMI_RPA )); + +/* Prepare RPA payload */ + pld = (uint8_t *)csio_ct_get_pld (cmd); + port_name = (struct fc_fdmi_port_name *)pld; +memcpy (&port_name->portname,csio_ln_wwpn (ln),8 ); + pld +=sizeof (*port_name); + +/* Start appending Port attributes */ + attrib_blk = (struct fs_fdmi_attrs *)pld; + attrib_blk->numattrs =0 ; + len +=sizeof (attrib_blk->numattrs); + pld +=sizeof (attrib_blk->numattrs); + + fc4_type = &buf[0 ]; +memset (fc4_type,0 ,FC_FDMI_PORT_ATTR_FC4TYPES_LEN ); + fc4_type[2 ] =1 ; + fc4_type[7 ] =1 ; +csio_append_attrib (&pld,FC_FDMI_PORT_ATTR_FC4TYPES , + fc4_type,FC_FDMI_PORT_ATTR_FC4TYPES_LEN ); + attrib_blk->numattrs++; + val =htonl (FC_PORTSPEED_1GBIT |FC_PORTSPEED_10GBIT ); +csio_append_attrib (&pld,FC_FDMI_PORT_ATTR_SUPPORTEDSPEED , + (uint8_t *)&val, +FC_FDMI_PORT_ATTR_SUPPORTEDSPEED_LEN ); + attrib_blk->numattrs++; + +if (hw->pport[ln->portid].link_speed ==FW_PORT_CAP_SPEED_1G ) + val =htonl (FC_PORTSPEED_1GBIT ); +else if (hw->pport[ln->portid].link_speed ==FW_PORT_CAP_SPEED_10G ) + val =htonl (FC_PORTSPEED_10GBIT ); +else + val =htonl (CSIO_HBA_PORTSPEED_UNKNOWN ); +csio_append_attrib (&pld,FC_FDMI_PORT_ATTR_CURRENTPORTSPEED , + (uint8_t *)&val, +FC_FDMI_PORT_ATTR_CURRENTPORTSPEED_LEN ); + attrib_blk->numattrs++; + + val =htonl (ln->ln_sparm.csp.sp_bb_data); +csio_append_attrib (&pld,FC_FDMI_PORT_ATTR_MAXFRAMESIZE , + (uint8_t *)&val,FC_FDMI_PORT_ATTR_MAXFRAMESIZE_LEN ); + attrib_blk->numattrs++; + +strcpy (buf,"csiostor" ); +csio_append_attrib (&pld,FC_FDMI_PORT_ATTR_OSDEVICENAME , buf, + (uint16_t )strlen (buf)); + attrib_blk->numattrs++; + +if (!csio_hostname (buf,sizeof (buf))) { +csio_append_attrib (&pld,FC_FDMI_PORT_ATTR_HOSTNAME , + buf, (uint16_t )strlen (buf)); + attrib_blk->numattrs++; + } + attrib_blk->numattrs =ntohl (attrib_blk->numattrs); + len = (uint32_t )(pld - (uint8_t *)cmd); + +/* Submit FDMI RPA request */ +spin_lock_irq (&hw->lock); +if (csio_ln_mgmt_submit_req (fdmi_req, csio_ln_fdmi_done, +FCOE_CT , &fdmi_req->dma_buf, len)) { +CSIO_INC_STATS (ln, n_fdmi_err); +csio_ln_err (ln,"Failed to issue fdmi rpa req\n" ); + } +spin_unlock_irq (&hw->lock); +} + +/* +* csio_ln_fdmi_dprt_cbfn - DPRT completion +* @hw: HW context +* @fdmi_req: fdmi request +*/ +static void +csio_ln_fdmi_dprt_cbfn (struct csio_hw *hw,struct csio_ioreq *fdmi_req) +{ +void *cmd; +uint8_t *pld; +uint32_t len =0 ; +uint32_t maxpayload =htonl (65536 ); +struct fc_fdmi_hba_identifier *hbaid; +struct csio_lnode *ln = fdmi_req->lnode; +struct fc_fdmi_rpl *reg_pl; +struct fs_fdmi_attrs *attrib_blk; +uint8_t buf[64 ]; + +if (fdmi_req->wr_status !=FW_SUCCESS ) { +csio_ln_err (ln,"WR error:%x in processing fdmi dprt cmd\n" , + fdmi_req->wr_status); +CSIO_INC_STATS (ln, n_fdmi_err); + } + +if (!csio_is_rnode_ready (fdmi_req->rnode)) { +CSIO_INC_STATS (ln, n_fdmi_err); +return ; + } + cmd = fdmi_req->dma_buf.vaddr; +if (ntohs (csio_ct_rsp (cmd)) !=FC_FS_ACC ) { +csio_ln_dbg (ln,"fdmi dprt cmd rejected reason %x expl %x\n" , +csio_ct_reason (cmd),csio_ct_expl (cmd)); + } + +/* Prepare CT hdr for RHBA cmd */ +memset (cmd,0 ,FC_CT_HDR_LEN ); +csio_fill_ct_iu (cmd,FC_FST_MGMT ,FC_FDMI_SUBTYPE ,htons (FC_FDMI_RHBA )); + len =FC_CT_HDR_LEN ; + +/* Prepare RHBA payload */ + pld = (uint8_t *)csio_ct_get_pld (cmd); + hbaid = (struct fc_fdmi_hba_identifier *)pld; +memcpy (&hbaid->id,csio_ln_wwpn (ln),8 );/* HBA identifer */ + pld +=sizeof (*hbaid); + +/* Register one port per hba */ + reg_pl = (struct fc_fdmi_rpl *)pld; + reg_pl->numport =ntohl (1 ); +memcpy (®_pl->port[0 ].portname,csio_ln_wwpn (ln),8 ); + pld +=sizeof (*reg_pl); + +/* Start appending HBA attributes hba */ + attrib_blk = (struct fs_fdmi_attrs *)pld; + attrib_blk->numattrs =0 ; + len +=sizeof (attrib_blk->numattrs); + pld +=sizeof (attrib_blk->numattrs); + +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_NODENAME ,csio_ln_wwnn (ln), +FC_FDMI_HBA_ATTR_NODENAME_LEN ); + attrib_blk->numattrs++; + +memset (buf,0 ,sizeof (buf)); + +strcpy (buf,"Chelsio Communications" ); +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_MANUFACTURER , buf, + (uint16_t )strlen (buf)); + attrib_blk->numattrs++; +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_SERIALNUMBER , + hw->vpd.sn, (uint16_t )sizeof (hw->vpd.sn)); + attrib_blk->numattrs++; +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_MODEL , hw->vpd.id, + (uint16_t )sizeof (hw->vpd.id)); + attrib_blk->numattrs++; +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_MODELDESCRIPTION , + hw->model_desc, (uint16_t )strlen (hw->model_desc)); + attrib_blk->numattrs++; +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_HARDWAREVERSION , + hw->hw_ver, (uint16_t )sizeof (hw->hw_ver)); + attrib_blk->numattrs++; +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_FIRMWAREVERSION , + hw->fwrev_str, (uint16_t )strlen (hw->fwrev_str)); + attrib_blk->numattrs++; + +if (!csio_osname (buf,sizeof (buf))) { +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_OSNAMEVERSION , + buf, (uint16_t )strlen (buf)); + attrib_blk->numattrs++; + } + +csio_append_attrib (&pld,FC_FDMI_HBA_ATTR_MAXCTPAYLOAD , + (uint8_t *)&maxpayload, +FC_FDMI_HBA_ATTR_MAXCTPAYLOAD_LEN ); + len = (uint32_t )(pld - (uint8_t *)cmd); + attrib_blk->numattrs++; + attrib_blk->numattrs =ntohl (attrib_blk->numattrs); + +/* Submit FDMI RHBA request */ +spin_lock_irq (&hw->lock); +if (csio_ln_mgmt_submit_req (fdmi_req, csio_ln_fdmi_rhba_cbfn, +FCOE_CT , &fdmi_req->dma_buf, len)) { +CSIO_INC_STATS (ln, n_fdmi_err); +csio_ln_err (ln,"Failed to issue fdmi rhba req\n" ); + } +spin_unlock_irq (&hw->lock); +} + +/* +* csio_ln_fdmi_dhba_cbfn - DHBA completion +* @hw: HW context +* @fdmi_req: fdmi request +*/ +static void +csio_ln_fdmi_dhba_cbfn (struct csio_hw *hw,struct csio_ioreq *fdmi_req) +{ +struct csio_lnode *ln = fdmi_req->lnode; +void *cmd; +struct fc_fdmi_port_name *port_name; +uint32_t len; + +if (fdmi_req->wr_status !=FW_SUCCESS ) { +csio_ln_err (ln,"WR error:%x in processing fdmi dhba cmd\n" , + fdmi_req->wr_status); +CSIO_INC_STATS (ln, n_fdmi_err); + } + +if (!csio_is_rnode_ready (fdmi_req->rnode)) { +CSIO_INC_STATS (ln, n_fdmi_err); +return ; + } + cmd = fdmi_req->dma_buf.vaddr; +if (ntohs (csio_ct_rsp (cmd)) !=FC_FS_ACC ) { +csio_ln_dbg (ln,"fdmi dhba cmd rejected reason %x expl %x\n" , +csio_ct_reason (cmd),csio_ct_expl (cmd)); + } + +/* Send FDMI cmd to de-register any Port attributes if registered +* before +*/ + +/* Prepare FDMI DPRT cmd */ +memset (cmd,0 ,FC_CT_HDR_LEN ); +csio_fill_ct_iu (cmd,FC_FST_MGMT ,FC_FDMI_SUBTYPE ,htons (FC_FDMI_DPRT )); + len =FC_CT_HDR_LEN ; + port_name = (struct fc_fdmi_port_name *)csio_ct_get_pld (cmd); +memcpy (&port_name->portname,csio_ln_wwpn (ln),8 ); + len +=sizeof (*port_name); + +/* Submit FDMI request */ +spin_lock_irq (&hw->lock); +if (csio_ln_mgmt_submit_req (fdmi_req, csio_ln_fdmi_dprt_cbfn, +FCOE_CT , &fdmi_req->dma_buf, len)) { +CSIO_INC_STATS (ln, n_fdmi_err); +csio_ln_err (ln,"Failed to issue fdmi dprt req\n" ); + } +spin_unlock_irq (&hw->lock); +} + +/** +* csio_ln_fdmi_start - Start an FDMI request. +* @ln: lnode +* @context: session context +* +* Issued with lock held. +*/ +int +csio_ln_fdmi_start (struct csio_lnode *ln,void *context) +{ +struct csio_ioreq *fdmi_req; +struct csio_rnode *fdmi_rn = (struct csio_rnode *)context; +void *cmd; +struct fc_fdmi_hba_identifier *hbaid; +uint32_t len; + +if (!(ln->flags &CSIO_LNF_FDMI_ENABLE )) +return -EPROTONOSUPPORT ; + +if (!csio_is_rnode_ready (fdmi_rn)) +CSIO_INC_STATS (ln, n_fdmi_err); + +/* Send FDMI cmd to de-register any HBA attributes if registered +* before +*/ + + fdmi_req = ln->mgmt_req; + fdmi_req->lnode = ln; + fdmi_req->rnode = fdmi_rn; + +/* Prepare FDMI DHBA cmd */ + cmd = fdmi_req->dma_buf.vaddr; +memset (cmd,0 ,FC_CT_HDR_LEN ); +csio_fill_ct_iu (cmd,FC_FST_MGMT ,FC_FDMI_SUBTYPE ,htons (FC_FDMI_DHBA )); + len =FC_CT_HDR_LEN ; + + hbaid = (struct fc_fdmi_hba_identifier *)csio_ct_get_pld (cmd); +memcpy (&hbaid->id,csio_ln_wwpn (ln),8 ); + len +=sizeof (*hbaid); + +/* Submit FDMI request */ +if (csio_ln_mgmt_submit_req (fdmi_req, csio_ln_fdmi_dhba_cbfn, +FCOE_CT , &fdmi_req->dma_buf, len)) { +CSIO_INC_STATS (ln, n_fdmi_err); +csio_ln_err (ln,"Failed to issue fdmi dhba req\n" ); + } + +return 0 ; +} + +/* +* csio_ln_vnp_read_cbfn - vnp read completion handler. +* @hw: HW lnode +* @cbfn: Completion handler. +* +* Reads vnp response and updates ln parameters. +*/ +static void +csio_ln_vnp_read_cbfn (struct csio_hw *hw,struct csio_mb *mbp) +{ +struct csio_lnode *ln = ((struct csio_lnode *)mbp->priv); +struct fw_fcoe_vnp_cmd *rsp = (struct fw_fcoe_vnp_cmd *)(mbp->mb); +struct fc_els_csp *csp; +struct fc_els_cssp *clsp; +enum fw_retval retval; + + retval =FW_CMD_RETVAL_GET (ntohl (rsp->alloc_to_len16)); +if (retval !=FW_SUCCESS ) { +csio_err (hw,"FCOE VNP read cmd returned error:0x%x\n" , retval); +mempool_free (mbp, hw->mb_mempool); +return ; + } + +spin_lock_irq (&hw->lock); + +memcpy (ln->mac, rsp->vnport_mac,sizeof (ln->mac)); +memcpy (&ln->nport_id, &rsp->vnport_mac[3 ], +sizeof (uint8_t )*3 ); + ln->nport_id =ntohl (ln->nport_id); + ln->nport_id = ln->nport_id>>8 ; + +/* Update WWNs */ +/* +* This may look like a duplication of what csio_fcoe_enable_link() +* does, but is absolutely necessary if the vnpi changes between +* a FCOE LINK UP and FCOE LINK DOWN. +*/ +memcpy (csio_ln_wwnn (ln), rsp->vnport_wwnn,8 ); +memcpy (csio_ln_wwpn (ln), rsp->vnport_wwpn,8 ); + +/* Copy common sparam */ + csp = (struct fc_els_csp *)rsp->cmn_srv_parms; + ln->ln_sparm.csp.sp_hi_ver = csp->sp_hi_ver; + ln->ln_sparm.csp.sp_lo_ver = csp->sp_lo_ver; + ln->ln_sparm.csp.sp_bb_cred =ntohs (csp->sp_bb_cred); + ln->ln_sparm.csp.sp_features =ntohs (csp->sp_features); + ln->ln_sparm.csp.sp_bb_data =ntohs (csp->sp_bb_data); + ln->ln_sparm.csp.sp_r_a_tov =ntohl (csp->sp_r_a_tov); + ln->ln_sparm.csp.sp_e_d_tov =ntohl (csp->sp_e_d_tov); + +/* Copy word 0 & word 1 of class sparam */ + clsp = (struct fc_els_cssp *)rsp->clsp_word_0_1; + ln->ln_sparm.clsp[2 ].cp_class =ntohs (clsp->cp_class); + ln->ln_sparm.clsp[2 ].cp_init =ntohs (clsp->cp_init); + ln->ln_sparm.clsp[2 ].cp_recip =ntohs (clsp->cp_recip); + ln->ln_sparm.clsp[2 ].cp_rdfs =ntohs (clsp->cp_rdfs); + +spin_unlock_irq (&hw->lock); + +mempool_free (mbp, hw->mb_mempool); + +/* Send an event to update local attribs */ +csio_lnode_async_event (ln,CSIO_LN_FC_ATTRIB_UPDATE ); +} + +/* +* csio_ln_vnp_read - Read vnp params. +* @ln: lnode +* @cbfn: Completion handler. +* +* Issued with lock held. +*/ +static int +csio_ln_vnp_read (struct csio_lnode *ln, +void (*cbfn) (struct csio_hw *,struct csio_mb *)) +{ +struct csio_hw *hw = ln->hwp; +struct csio_mb *mbp; + +/* Allocate Mbox request */ + mbp =mempool_alloc (hw->mb_mempool,GFP_ATOMIC ); +if (!mbp) { +CSIO_INC_STATS (hw, n_err_nomem); +return -ENOMEM ; + } + +/* Prepare VNP Command */ +csio_fcoe_vnp_read_init_mb (ln, mbp, +CSIO_MB_DEFAULT_TMO , + ln->fcf_flowid, + ln->vnp_flowid, + cbfn); + +/* Issue MBOX cmd */ +if (csio_mb_issue (hw, mbp)) { +csio_err (hw,"Failed to issue mbox FCoE VNP command\n" ); +mempool_free (mbp, hw->mb_mempool); +return -EINVAL ; + } + +return 0 ; +} + +/* +* csio_fcoe_enable_link - Enable fcoe link. +* @ln: lnode +* @enable: enable/disable +* Issued with lock held. +* Issues mbox cmd to bring up FCOE link on port associated with given ln. +*/ +static int +csio_fcoe_enable_link (struct csio_lnode *ln,bool enable) +{ +struct csio_hw *hw = ln->hwp; +struct csio_mb *mbp; +enum fw_retval retval; +uint8_t portid; +uint8_t sub_op; +struct fw_fcoe_link_cmd *lcmd; +int i; + + mbp =mempool_alloc (hw->mb_mempool,GFP_ATOMIC ); +if (!mbp) { +CSIO_INC_STATS (hw, n_err_nomem); +return -ENOMEM ; + } + + portid = ln->portid; + sub_op = enable ?FCOE_LINK_UP :FCOE_LINK_DOWN ; + +csio_dbg (hw,"bringing FCOE LINK %s on Port:%d\n" , + sub_op ?"UP" :"DOWN" , portid); + +csio_write_fcoe_link_cond_init_mb (ln, mbp,CSIO_MB_DEFAULT_TMO , + portid, sub_op,0 ,0 ,0 ,NULL ); + +if (csio_mb_issue (hw, mbp)) { +csio_err (hw,"failed to issue FCOE LINK cmd on port[%d]\n" , + portid); +mempool_free (mbp, hw->mb_mempool); +return -EINVAL ; + } + + retval =csio_mb_fw_retval (mbp); +if (retval !=FW_SUCCESS ) { +csio_err (hw, +"FCOE LINK %s cmd on port[%d] failed with " +"ret:x%x\n" , sub_op ?"UP" :"DOWN" , portid, retval); +mempool_free (mbp, hw->mb_mempool); +return -EINVAL ; + } + +if (!enable) + goto out; + + lcmd = (struct fw_fcoe_link_cmd *)mbp->mb; + +memcpy (csio_ln_wwnn (ln), lcmd->vnport_wwnn,8 ); +memcpy (csio_ln_wwpn (ln), lcmd->vnport_wwpn,8 ); + +for (i =0 ; i <CSIO_MAX_PPORTS ; i++) +if (hw->pport[i].portid == portid) +memcpy (hw->pport[i].mac, lcmd->phy_mac,6 ); + +out: +mempool_free (mbp, hw->mb_mempool); +return 0 ; +} + +/* +* csio_ln_read_fcf_cbfn - Read fcf parameters +* @ln: lnode +* +* read fcf response and Update ln fcf information. +*/ +static void +csio_ln_read_fcf_cbfn (struct csio_hw *hw,struct csio_mb *mbp) +{ +struct csio_lnode *ln = (struct csio_lnode *)mbp->priv; +struct csio_fcf_info *fcf_info; +struct fw_fcoe_fcf_cmd *rsp = + (struct fw_fcoe_fcf_cmd *)(mbp->mb); +enum fw_retval retval; + + retval =FW_CMD_RETVAL_GET (ntohl (rsp->retval_len16)); +if (retval !=FW_SUCCESS ) { +csio_ln_err (ln,"FCOE FCF cmd failed with ret x%x\n" , + retval); +mempool_free (mbp, hw->mb_mempool); +return ; + } + +spin_lock_irq (&hw->lock); + fcf_info = ln->fcfinfo; + fcf_info->priority =FW_FCOE_FCF_CMD_PRIORITY_GET ( +ntohs (rsp->priority_pkd)); + fcf_info->vf_id =ntohs (rsp->vf_id); + fcf_info->vlan_id = rsp->vlan_id; + fcf_info->max_fcoe_size =ntohs (rsp->max_fcoe_size); + fcf_info->fka_adv =be32_to_cpu (rsp->fka_adv); + fcf_info->fcfi =FW_FCOE_FCF_CMD_FCFI_GET (ntohl (rsp->op_to_fcfi)); + fcf_info->fpma =FW_FCOE_FCF_CMD_FPMA_GET (rsp->fpma_to_portid); + fcf_info->spma =FW_FCOE_FCF_CMD_SPMA_GET (rsp->fpma_to_portid); + fcf_info->login =FW_FCOE_FCF_CMD_LOGIN_GET (rsp->fpma_to_portid); + fcf_info->portid =FW_FCOE_FCF_CMD_PORTID_GET (rsp->fpma_to_portid); +memcpy (fcf_info->fc_map, rsp->fc_map,sizeof (fcf_info->fc_map)); +memcpy (fcf_info->mac, rsp->mac,sizeof (fcf_info->mac)); +memcpy (fcf_info->name_id, rsp->name_id,sizeof (fcf_info->name_id)); +memcpy (fcf_info->fabric, rsp->fabric,sizeof (fcf_info->fabric)); +memcpy (fcf_info->spma_mac, rsp->spma_mac,sizeof (fcf_info->spma_mac)); + +spin_unlock_irq (&hw->lock); + +mempool_free (mbp, hw->mb_mempool); +} + +/* +* csio_ln_read_fcf_entry - Read fcf entry. +* @ln: lnode +* @cbfn: Completion handler. +* +* Issued with lock held. +*/ +static int +csio_ln_read_fcf_entry (struct csio_lnode *ln, +void (*cbfn) (struct csio_hw *,struct csio_mb *)) +{ +struct csio_hw *hw = ln->hwp; +struct csio_mb *mbp; + + mbp =mempool_alloc (hw->mb_mempool,GFP_ATOMIC ); +if (!mbp) { +CSIO_INC_STATS (hw, n_err_nomem); +return -ENOMEM ; + } + +/* Get FCoE FCF information */ +csio_fcoe_read_fcf_init_mb (ln, mbp,CSIO_MB_DEFAULT_TMO , + ln->portid, ln->fcf_flowid, cbfn); + +if (csio_mb_issue (hw, mbp)) { +csio_err (hw,"failed to issue FCOE FCF cmd\n" ); +mempool_free (mbp, hw->mb_mempool); +return -EINVAL ; + } + +return 0 ; +} + +/* +* csio_handle_link_up - Logical Linkup event. +* @hw - HW module. +* @portid - Physical port number +* @fcfi - FCF index. +* @vnpi - VNP index. +* Returns - none. +* +* This event is received from FW, when virtual link is established between +* Physical port[ENode] and FCF. If its new vnpi, then local node object is +* created on this FCF and set to [ONLINE] state. +* Lnode waits for FW_RDEV_CMD event to be received indicating that +* Fabric login is completed and lnode moves to [READY] state. +* +* This called with hw lock held +*/ +static void +csio_handle_link_up (struct csio_hw *hw,uint8_t portid,uint32_t fcfi, +uint32_t vnpi) +{ +struct csio_lnode *ln =NULL ; + +/* Lookup lnode based on vnpi */ + ln =csio_ln_lookup_by_vnpi (hw, vnpi); +if (!ln) { +/* Pick lnode based on portid */ + ln =csio_ln_lookup_by_portid (hw, portid); +if (!ln) { +csio_err (hw,"failed to lookup fcoe lnode on port:%d\n" , + portid); +CSIO_DB_ASSERT (0 ); +return ; + } + +/* Check if lnode has valid vnp flowid */ +if (ln->vnp_flowid !=CSIO_INVALID_IDX ) { +/* New VN-Port */ +spin_unlock_irq (&hw->lock); +csio_lnode_alloc (hw); +spin_lock_irq (&hw->lock); +if (!ln) { +csio_err (hw, +"failed to allocate fcoe lnode" +"for port:%d vnpi:x%x\n" , + portid, vnpi); +CSIO_DB_ASSERT (0 ); +return ; + } + ln->portid = portid; + } + ln->vnp_flowid = vnpi; + ln->dev_num &= ~0xFFFF ; + ln->dev_num |= vnpi; + } + +/*Initialize fcfi */ + ln->fcf_flowid = fcfi; + +csio_info (hw,"Port:%d - FCOE LINK UP\n" , portid); + +CSIO_INC_STATS (ln, n_link_up); + +/* Send LINKUP event to SM */ +csio_post_event (&ln->sm,CSIO_LNE_LINKUP ); +} + +/* +* csio_post_event_rns +* @ln - FCOE lnode +* @evt - Given rnode event +* Returns - none +* +* Posts given rnode event to all FCOE rnodes connected with given Lnode. +* This routine is invoked when lnode receives LINK_DOWN/DOWN_LINK/CLOSE +* event. +* +* This called with hw lock held +*/ +static void +csio_post_event_rns (struct csio_lnode *ln,enum csio_rn_ev evt) +{ +struct csio_rnode *rnhead = (struct csio_rnode *) &ln->rnhead; +struct list_head *tmp, *next; +struct csio_rnode *rn; + +list_for_each_safe (tmp, next, &rnhead->sm.sm_list) { + rn = (struct csio_rnode *) tmp; +csio_post_event (&rn->sm, evt); + } +} + +/* +* csio_cleanup_rns +* @ln - FCOE lnode +* Returns - none +* +* Frees all FCOE rnodes connected with given Lnode. +* +* This called with hw lock held +*/ +static void +csio_cleanup_rns (struct csio_lnode *ln) +{ +struct csio_rnode *rnhead = (struct csio_rnode *) &ln->rnhead; +struct list_head *tmp, *next_rn; +struct csio_rnode *rn; + +list_for_each_safe (tmp, next_rn, &rnhead->sm.sm_list) { + rn = (struct csio_rnode *) tmp; +csio_put_rnode (ln, rn); + } + +} + +/* +* csio_post_event_lns +* @ln - FCOE lnode +* @evt - Given lnode event +* Returns - none +* +* Posts given lnode event to all FCOE lnodes connected with given Lnode. +* This routine is invoked when lnode receives LINK_DOWN/DOWN_LINK/CLOSE +* event. +* +* This called with hw lock held +*/ +static void +csio_post_event_lns (struct csio_lnode *ln,enum csio_ln_ev evt) +{ +struct list_head *tmp; +struct csio_lnode *cln, *sln; + +/* If NPIV lnode, send evt only to that and return */ +if (csio_is_npiv_ln (ln)) { +csio_post_event (&ln->sm, evt); +return ; + } + + sln = ln; +/* Traverse children lnodes list and send evt */ +list_for_each (tmp, &sln->cln_head) { + cln = (struct csio_lnode *) tmp; +csio_post_event (&cln->sm, evt); + } + +/* Send evt to parent lnode */ +csio_post_event (&ln->sm, evt); +} + +/* +* csio_ln_down - Lcoal nport is down +* @ln - FCOE Lnode +* Returns - none +* +* Sends LINK_DOWN events to Lnode and its associated NPIVs lnodes. +* +* This called with hw lock held +*/ +static void +csio_ln_down (struct csio_lnode *ln) +{ +csio_post_event_lns (ln,CSIO_LNE_LINK_DOWN ); +} + +/* +* csio_handle_link_down - Logical Linkdown event. +* @hw - HW module. +* @portid - Physical port number +* @fcfi - FCF index. +* @vnpi - VNP index. +* Returns - none +* +* This event is received from FW, when virtual link goes down between +* Physical port[ENode] and FCF. Lnode and its associated NPIVs lnode hosted on +* this vnpi[VN-Port] will be de-instantiated. +* +* This called with hw lock held +*/ +static void +csio_handle_link_down (struct csio_hw *hw,uint8_t portid,uint32_t fcfi, +uint32_t vnpi) +{ +struct csio_fcf_info *fp; +struct csio_lnode *ln; + +/* Lookup lnode based on vnpi */ + ln =csio_ln_lookup_by_vnpi (hw, vnpi); +if (ln) { + fp = ln->fcfinfo; +CSIO_INC_STATS (ln, n_link_down); + +/*Warn if linkdown received if lnode is not in ready state */ +if (!csio_is_lnode_ready (ln)) { +csio_ln_warn (ln, +"warn: FCOE link is already in offline " +"Ignoring Fcoe linkdown event on portid %d\n" , + portid); +CSIO_INC_STATS (ln, n_evt_drop); +return ; + } + +/* Verify portid */ +if (fp->portid != portid) { +csio_ln_warn (ln, +"warn: FCOE linkdown recv with " +"invalid port %d\n" , portid); +CSIO_INC_STATS (ln, n_evt_drop); +return ; + } + +/* verify fcfi */ +if (ln->fcf_flowid != fcfi) { +csio_ln_warn (ln, +"warn: FCOE linkdown recv with " +"invalid fcfi x%x\n" , fcfi); +CSIO_INC_STATS (ln, n_evt_drop); +return ; + } + +csio_info (hw,"Port:%d - FCOE LINK DOWN\n" , portid); + +/* Send LINK_DOWN event to lnode s/m */ +csio_ln_down (ln); + +return ; + }else { +csio_warn (hw, +"warn: FCOE linkdown recv with invalid vnpi x%x\n" , + vnpi); +CSIO_INC_STATS (hw, n_evt_drop); + } +} + +/* +* csio_is_lnode_ready - Checks FCOE lnode is in ready state. +* @ln: Lnode module +* +* Returns True if FCOE lnode is in ready state. +*/ +int +csio_is_lnode_ready (struct csio_lnode *ln) +{ +return (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_ready)); +} + +/*****************************************************************************/ +/* START: Lnode SM */ +/*****************************************************************************/ +/* +* csio_lns_uninit - The request in uninit state. +* @ln - FCOE lnode. +* @evt - Event to be processed. +* +* Process the given lnode event which is currently in "uninit" state. +* Invoked with HW lock held. +* Return - none. +*/ +static void +csio_lns_uninit (struct csio_lnode *ln,enum csio_ln_ev evt) +{ +struct csio_hw *hw =csio_lnode_to_hw (ln); +struct csio_lnode *rln = hw->rln; +int rv; + +CSIO_INC_STATS (ln, n_evt_sm[evt]); +switch (evt) { +case CSIO_LNE_LINKUP : +csio_set_state (&ln->sm, csio_lns_online); +/* Read FCF only for physical lnode */ +if (csio_is_phys_ln (ln)) { + rv =csio_ln_read_fcf_entry (ln, + csio_ln_read_fcf_cbfn); +if (rv !=0 ) { +/* TODO: Send HW RESET event */ +CSIO_INC_STATS (ln, n_err); +break ; + } + +/* Add FCF record */ +list_add_tail (&ln->fcfinfo->list, &rln->fcf_lsthead); + } + + rv =csio_ln_vnp_read (ln, csio_ln_vnp_read_cbfn); +if (rv !=0 ) { +/* TODO: Send HW RESET event */ +CSIO_INC_STATS (ln, n_err); + } +break ; + +case CSIO_LNE_DOWN_LINK : +break ; + +default : +csio_ln_dbg (ln, +"unexp ln event %d recv from did:x%x in " +"ln state[uninit].\n" , evt, ln->nport_id); +CSIO_INC_STATS (ln, n_evt_unexp); +break ; + }/* switch event */ +} + +/* +* csio_lns_online - The request in online state. +* @ln - FCOE lnode. +* @evt - Event to be processed. +* +* Process the given lnode event which is currently in "online" state. +* Invoked with HW lock held. +* Return - none. +*/ +static void +csio_lns_online (struct csio_lnode *ln,enum csio_ln_ev evt) +{ +struct csio_hw *hw =csio_lnode_to_hw (ln); + +CSIO_INC_STATS (ln, n_evt_sm[evt]); +switch (evt) { +case CSIO_LNE_LINKUP : +csio_ln_warn (ln, +"warn: FCOE link is up already " +"Ignoring linkup on port:%d\n" , ln->portid); +CSIO_INC_STATS (ln, n_evt_drop); +break ; + +case CSIO_LNE_FAB_INIT_DONE : +csio_set_state (&ln->sm, csio_lns_ready); + +spin_unlock_irq (&hw->lock); +csio_lnode_async_event (ln,CSIO_LN_FC_LINKUP ); +spin_lock_irq (&hw->lock); + +break ; + +case CSIO_LNE_LINK_DOWN : +/* Fall through */ +case CSIO_LNE_DOWN_LINK : +csio_set_state (&ln->sm, csio_lns_uninit); +if (csio_is_phys_ln (ln)) { +/* Remove FCF entry */ +list_del_init (&ln->fcfinfo->list); + } +break ; + +default : +csio_ln_dbg (ln, +"unexp ln event %d recv from did:x%x in " +"ln state[uninit].\n" , evt, ln->nport_id); +CSIO_INC_STATS (ln, n_evt_unexp); + +break ; + }/* switch event */ +} + +/* +* csio_lns_ready - The request in ready state. +* @ln - FCOE lnode. +* @evt - Event to be processed. +* +* Process the given lnode event which is currently in "ready" state. +* Invoked with HW lock held. +* Return - none. +*/ +static void +csio_lns_ready (struct csio_lnode *ln,enum csio_ln_ev evt) +{ +struct csio_hw *hw =csio_lnode_to_hw (ln); + +CSIO_INC_STATS (ln, n_evt_sm[evt]); +switch (evt) { +case CSIO_LNE_FAB_INIT_DONE : +csio_ln_err (ln, +"ignoring event %d recv from did x%x" +"in ln state[ready].\n" , evt, ln->nport_id); +CSIO_INC_STATS (ln, n_evt_drop); +break ; + +case CSIO_LNE_LINK_DOWN : +csio_set_state (&ln->sm, csio_lns_offline); +csio_post_event_rns (ln,CSIO_RNFE_DOWN ); + +spin_unlock_irq (&hw->lock); +csio_lnode_async_event (ln,CSIO_LN_FC_LINKDOWN ); +spin_lock_irq (&hw->lock); + +if (csio_is_phys_ln (ln)) { +/* Remove FCF entry */ +list_del_init (&ln->fcfinfo->list); + } +break ; + +case CSIO_LNE_DOWN_LINK : +csio_set_state (&ln->sm, csio_lns_offline); +csio_post_event_rns (ln,CSIO_RNFE_DOWN ); + +/* Host need to issue aborts in case if FW has not returned +* WRs with status "ABORTED" +*/ +spin_unlock_irq (&hw->lock); +csio_lnode_async_event (ln,CSIO_LN_FC_LINKDOWN ); +spin_lock_irq (&hw->lock); + +if (csio_is_phys_ln (ln)) { +/* Remove FCF entry */ +list_del_init (&ln->fcfinfo->list); + } +break ; + +case CSIO_LNE_CLOSE : +csio_set_state (&ln->sm, csio_lns_uninit); +csio_post_event_rns (ln,CSIO_RNFE_CLOSE ); +break ; + +case CSIO_LNE_LOGO : +csio_set_state (&ln->sm, csio_lns_offline); +csio_post_event_rns (ln,CSIO_RNFE_DOWN ); +break ; + +default : +csio_ln_dbg (ln, +"unexp ln event %d recv from did:x%x in " +"ln state[uninit].\n" , evt, ln->nport_id); +CSIO_INC_STATS (ln, n_evt_unexp); +CSIO_DB_ASSERT (0 ); +break ; + }/* switch event */ +} + +/* +* csio_lns_offline - The request in offline state. +* @ln - FCOE lnode. +* @evt - Event to be processed. +* +* Process the given lnode event which is currently in "offline" state. +* Invoked with HW lock held. +* Return - none. +*/ +static void +csio_lns_offline (struct csio_lnode *ln,enum csio_ln_ev evt) +{ +struct csio_hw *hw =csio_lnode_to_hw (ln); +struct csio_lnode *rln = hw->rln; +int rv; + +CSIO_INC_STATS (ln, n_evt_sm[evt]); +switch (evt) { +case CSIO_LNE_LINKUP : +csio_set_state (&ln->sm, csio_lns_online); +/* Read FCF only for physical lnode */ +if (csio_is_phys_ln (ln)) { + rv =csio_ln_read_fcf_entry (ln, + csio_ln_read_fcf_cbfn); +if (rv !=0 ) { +/* TODO: Send HW RESET event */ +CSIO_INC_STATS (ln, n_err); +break ; + } + +/* Add FCF record */ +list_add_tail (&ln->fcfinfo->list, &rln->fcf_lsthead); + } + + rv =csio_ln_vnp_read (ln, csio_ln_vnp_read_cbfn); +if (rv !=0 ) { +/* TODO: Send HW RESET event */ +CSIO_INC_STATS (ln, n_err); + } +break ; + +case CSIO_LNE_LINK_DOWN : +case CSIO_LNE_DOWN_LINK : +case CSIO_LNE_LOGO : +csio_ln_err (ln, +"ignoring event %d recv from did x%x" +"in ln state[offline].\n" , evt, ln->nport_id); +CSIO_INC_STATS (ln, n_evt_drop); +break ; + +case CSIO_LNE_CLOSE : +csio_set_state (&ln->sm, csio_lns_uninit); +csio_post_event_rns (ln,CSIO_RNFE_CLOSE ); +break ; + +default : +csio_ln_dbg (ln, +"unexp ln event %d recv from did:x%x in " +"ln state[offline]\n" , evt, ln->nport_id); +CSIO_INC_STATS (ln, n_evt_unexp); +CSIO_DB_ASSERT (0 ); +break ; + }/* switch event */ +} + +/*****************************************************************************/ +/* END: Lnode SM */ +/*****************************************************************************/ + +static void +csio_free_fcfinfo (struct kref *kref) +{ +struct csio_fcf_info *fcfinfo =container_of (kref, + struct csio_fcf_info, kref); +kfree (fcfinfo); +} + +/* Helper routines for attributes */ +/* +* csio_lnode_state_to_str - Get current state of FCOE lnode. +* @ln - lnode +* @str - state of lnode. +* +*/ +void +csio_lnode_state_to_str (struct csio_lnode *ln,int8_t *str) +{ +if (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_uninit)) { +strcpy (str,"UNINIT" ); +return ; + } +if (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_ready)) { +strcpy (str,"READY" ); +return ; + } +if (csio_get_state (ln) == ((csio_sm_state_t )csio_lns_offline)) { +strcpy (str,"OFFLINE" ); +return ; + } +strcpy (str,"UNKNOWN" ); +}/* csio_lnode_state_to_str */ + + +int +csio_get_phy_port_stats (struct csio_hw *hw,uint8_t portid, +struct fw_fcoe_port_stats *port_stats) +{ +struct csio_mb *mbp; +struct fw_fcoe_port_cmd_params portparams; +enum fw_retval retval; +int idx; + + mbp =mempool_alloc (hw->mb_mempool,GFP_ATOMIC ); +if (!mbp) { +csio_err (hw,"FCoE FCF PARAMS command out of memory!\n" ); +return -EINVAL ; + } + portparams.portid = portid; + +for (idx =1 ; idx <=3 ; idx++) { + portparams.idx = (idx-1 )*6 +1 ; + portparams.nstats =6 ; +if (idx ==3 ) + portparams.nstats =4 ; +csio_fcoe_read_portparams_init_mb (hw, mbp,CSIO_MB_DEFAULT_TMO , + &portparams,NULL ); +if (csio_mb_issue (hw, mbp)) { +csio_err (hw,"Issue of FCoE port params failed!\n" ); +mempool_free (mbp, hw->mb_mempool); +return -EINVAL ; + } +csio_mb_process_portparams_rsp (hw, mbp, &retval, + &portparams, port_stats); + } + +mempool_free (mbp, hw->mb_mempool); +return 0 ; +} + +/* +* csio_ln_mgmt_wr_handler -Mgmt Work Request handler. +* @wr - WR. +* @len - WR len. +* This handler is invoked when an outstanding mgmt WR is completed. +* Its invoked in the context of FW event worker thread for every +* mgmt event received. +* Return - none. +*/ + +static void +csio_ln_mgmt_wr_handler (struct csio_hw *hw,void *wr,uint32_t len) +{ +struct csio_mgmtm *mgmtm =csio_hw_to_mgmtm (hw); +struct csio_ioreq *io_req =NULL ; +struct fw_fcoe_els_ct_wr *wr_cmd; + + + wr_cmd = (struct fw_fcoe_els_ct_wr *) wr; + +if (len <sizeof (struct fw_fcoe_els_ct_wr )) { +csio_err (mgmtm->hw, +"Invalid ELS CT WR length recvd, len:%x\n" , len); + mgmtm->stats.n_err++; +return ; + } + + io_req = (struct csio_ioreq *) ((uintptr_t ) wr_cmd->cookie); + io_req->wr_status =csio_wr_status (wr_cmd); + +/* lookup ioreq exists in our active Q */ +spin_lock_irq (&hw->lock); +if (csio_mgmt_req_lookup (mgmtm, io_req) !=0 ) { +csio_err (mgmtm->hw, +"Error- Invalid IO handle recv in WR. handle: %p\n" , + io_req); + mgmtm->stats.n_err++; +spin_unlock_irq (&hw->lock); +return ; + } + + mgmtm =csio_hw_to_mgmtm (hw); + +/* Dequeue from active queue */ +list_del_init (&io_req->sm.sm_list); + mgmtm->stats.n_active--; +spin_unlock_irq (&hw->lock); + +/* io_req will be freed by completion handler */ +if (io_req->io_cbfn) + io_req->io_cbfn (hw, io_req); +} + +/** +* csio_fcoe_fwevt_handler - Event handler for Firmware FCoE events. +* @hw: HW module +* @cpl_op: CPL opcode +* @cmd: FW cmd/WR. +* +* Process received FCoE cmd/WR event from FW. +*/ +void +csio_fcoe_fwevt_handler (struct csio_hw *hw,__u8 cpl_op,__be64 *cmd) +{ +struct csio_lnode *ln; +struct csio_rnode *rn; +uint8_t portid, opcode = *(uint8_t *)cmd; +struct fw_fcoe_link_cmd *lcmd; +struct fw_wr_hdr *wr; +struct fw_rdev_wr *rdev_wr; +enum fw_fcoe_link_status lstatus; +uint32_t fcfi, rdev_flowid, vnpi; +enum csio_ln_ev evt; + +if (cpl_op ==CPL_FW6_MSG && opcode ==FW_FCOE_LINK_CMD ) { + + lcmd = (struct fw_fcoe_link_cmd *)cmd; + lstatus = lcmd->lstatus; + portid =FW_FCOE_LINK_CMD_PORTID_GET ( +ntohl (lcmd->op_to_portid)); + fcfi =FW_FCOE_LINK_CMD_FCFI_GET (ntohl (lcmd->sub_opcode_fcfi)); + vnpi =FW_FCOE_LINK_CMD_VNPI_GET (ntohl (lcmd->vnpi_pkd)); + +if (lstatus ==FCOE_LINKUP ) { + +/* HW lock here */ +spin_lock_irq (&hw->lock); +csio_handle_link_up (hw, portid, fcfi, vnpi); +spin_unlock_irq (&hw->lock); +/* HW un lock here */ + + }else if (lstatus ==FCOE_LINKDOWN ) { + +/* HW lock here */ +spin_lock_irq (&hw->lock); +csio_handle_link_down (hw, portid, fcfi, vnpi); +spin_unlock_irq (&hw->lock); +/* HW un lock here */ + }else { +csio_warn (hw,"Unexpected FCOE LINK status:0x%x\n" , +ntohl (lcmd->lstatus)); +CSIO_INC_STATS (hw, n_cpl_unexp); + } + }else if (cpl_op ==CPL_FW6_PLD ) { + wr = (struct fw_wr_hdr *) (cmd +4 ); +if (FW_WR_OP_GET (be32_to_cpu (wr->hi)) + ==FW_RDEV_WR ) { + + rdev_wr = (struct fw_rdev_wr *) (cmd +4 ); + + rdev_flowid =FW_RDEV_WR_FLOWID_GET ( +ntohl (rdev_wr->alloc_to_len16)); + vnpi =FW_RDEV_WR_ASSOC_FLOWID_GET ( +ntohl (rdev_wr->flags_to_assoc_flowid)); + +csio_dbg (hw, +"FW_RDEV_WR: flowid:x%x ev_cause:x%x " +"vnpi:0x%x\n" , rdev_flowid, + rdev_wr->event_cause, vnpi); + +if (rdev_wr->protocol !=PROT_FCOE ) { +csio_err (hw, +"FW_RDEV_WR: invalid proto:x%x " +"received with flowid:x%x\n" , + rdev_wr->protocol, + rdev_flowid); +CSIO_INC_STATS (hw, n_evt_drop); +return ; + } + +/* HW lock here */ +spin_lock_irq (&hw->lock); + ln =csio_ln_lookup_by_vnpi (hw, vnpi); +if (!ln) { +csio_err (hw, +"FW_DEV_WR: invalid vnpi:x%x received " +"with flowid:x%x\n" , vnpi, rdev_flowid); +CSIO_INC_STATS (hw, n_evt_drop); + goto out_pld; + } + + rn =csio_confirm_rnode (ln, rdev_flowid, + &rdev_wr->u.fcoe_rdev); +if (!rn) { +csio_ln_dbg (ln, +"Failed to confirm rnode " +"for flowid:x%x\n" , rdev_flowid); +CSIO_INC_STATS (hw, n_evt_drop); + goto out_pld; + } + +/* save previous event for debugging */ + ln->prev_evt = ln->cur_evt; + ln->cur_evt = rdev_wr->event_cause; +CSIO_INC_STATS (ln, n_evt_fw[rdev_wr->event_cause]); + +/* Translate all the fabric events to lnode SM events */ + evt =CSIO_FWE_TO_LNE (rdev_wr->event_cause); +if (evt) { +csio_ln_dbg (ln, +"Posting event to lnode event:%d " +"cause:%d flowid:x%x\n" , evt, + rdev_wr->event_cause, rdev_flowid); +csio_post_event (&ln->sm, evt); + } + +/* Handover event to rn SM here. */ +csio_rnode_fwevt_handler (rn, rdev_wr->event_cause); +out_pld: +spin_unlock_irq (&hw->lock); +return ; + }else { +csio_warn (hw,"unexpected WR op(0x%x) recv\n" , +FW_WR_OP_GET (be32_to_cpu ((wr->hi)))); +CSIO_INC_STATS (hw, n_cpl_unexp); + } + }else if (cpl_op ==CPL_FW6_MSG ) { + wr = (struct fw_wr_hdr *) (cmd); +if (FW_WR_OP_GET (be32_to_cpu (wr->hi)) ==FW_FCOE_ELS_CT_WR ) { +csio_ln_mgmt_wr_handler (hw, wr, +sizeof (struct fw_fcoe_els_ct_wr )); + }else { +csio_warn (hw,"unexpected WR op(0x%x) recv\n" , +FW_WR_OP_GET (be32_to_cpu ((wr->hi)))); +CSIO_INC_STATS (hw, n_cpl_unexp); + } + }else { +csio_warn (hw,"unexpected CPL op(0x%x) recv\n" , opcode); +CSIO_INC_STATS (hw, n_cpl_unexp); + } +} + +/** +* csio_lnode_start - Kickstart lnode discovery. +* @ln: lnode +* +* This routine kickstarts the discovery by issuing an FCOE_LINK (up) command. +*/ +int +csio_lnode_start (struct csio_lnode *ln) +{ +int rv =0 ; +if (csio_is_phys_ln (ln) && !(ln->flags &CSIO_LNF_LINK_ENABLE )) { + rv =csio_fcoe_enable_link (ln,1 ); + ln->flags |=CSIO_LNF_LINK_ENABLE ; + } + +return rv; +} + +/** +* csio_lnode_stop - Stop the lnode. +* @ln: lnode +* +* This routine is invoked by HW module to stop lnode and its associated NPIV +* lnodes. +*/ +void +csio_lnode_stop (struct csio_lnode *ln) +{ +csio_post_event_lns (ln,CSIO_LNE_DOWN_LINK ); +if (csio_is_phys_ln (ln) && (ln->flags &CSIO_LNF_LINK_ENABLE )) { +csio_fcoe_enable_link (ln,0 ); + ln->flags &= ~CSIO_LNF_LINK_ENABLE ; + } +csio_ln_dbg (ln,"stopping ln :%p\n" , ln); +} + +/** +* csio_lnode_close - Close an lnode. +* @ln: lnode +* +* This routine is invoked by HW module to close an lnode and its +* associated NPIV lnodes. Lnode and its associated NPIV lnodes are +* set to uninitialized state. +*/ +void +csio_lnode_close (struct csio_lnode *ln) +{ +csio_post_event_lns (ln,CSIO_LNE_CLOSE ); +if (csio_is_phys_ln (ln)) + ln->vnp_flowid =CSIO_INVALID_IDX ; + +csio_ln_dbg (ln,"closed ln :%p\n" , ln); +} + +/* +* csio_ln_prep_ecwr - Prepare ELS/CT WR. +* @io_req - IO request. +* @wr_len - WR len +* @immd_len - WR immediate data +* @sub_op - Sub opcode +* @sid - source portid. +* @did - destination portid +* @flow_id - flowid +* @fw_wr - ELS/CT WR to be prepared. +* Returns: 0 - on success +*/ +static int +csio_ln_prep_ecwr (struct csio_ioreq *io_req,uint32_t wr_len, +uint32_t immd_len,uint8_t sub_op,uint32_t sid, +uint32_t did,uint32_t flow_id,uint8_t *fw_wr) +{ +struct fw_fcoe_els_ct_wr *wr; +uint32_t port_id; + + wr = (struct fw_fcoe_els_ct_wr *)fw_wr; + wr->op_immdlen =cpu_to_be32 (FW_WR_OP (FW_FCOE_ELS_CT_WR ) | +FW_FCOE_ELS_CT_WR_IMMDLEN (immd_len)); + + wr_len =DIV_ROUND_UP (wr_len,16 ); + wr->flowid_len16 =cpu_to_be32 (FW_WR_FLOWID (flow_id) | +FW_WR_LEN16 (wr_len)); + wr->els_ct_type = sub_op; + wr->ctl_pri =0 ; + wr->cp_en_class =0 ; + wr->cookie = io_req->fw_handle; + wr->iqid = (uint16_t )cpu_to_be16 (csio_q_physiqid ( + io_req->lnode->hwp, io_req->iq_idx)); + wr->fl_to_sp =FW_FCOE_ELS_CT_WR_SP (1 ); + wr->tmo_val = (uint8_t ) io_req->tmo; + port_id =htonl (sid); +memcpy (wr->l_id,PORT_ID_PTR (port_id),3 ); + port_id =htonl (did); +memcpy (wr->r_id,PORT_ID_PTR (port_id),3 ); + +/* Prepare RSP SGL */ + wr->rsp_dmalen =cpu_to_be32 (io_req->dma_buf.len); + wr->rsp_dmaaddr =cpu_to_be64 (io_req->dma_buf.paddr); +return 0 ; +} + +/* +* csio_ln_mgmt_submit_wr - Post elsct work request. +* @mgmtm - mgmtm +* @io_req - io request. +* @sub_op - ELS or CT request type +* @pld - Dma Payload buffer +* @pld_len - Payload len +* Prepares ELSCT Work request and sents it to FW. +* Returns: 0 - on success +*/ +static int +csio_ln_mgmt_submit_wr (struct csio_mgmtm *mgmtm,struct csio_ioreq *io_req, +uint8_t sub_op,struct csio_dma_buf *pld, +uint32_t pld_len) +{ +struct csio_wr_pair wrp; +struct csio_lnode *ln = io_req->lnode; +struct csio_rnode *rn = io_req->rnode; +struct csio_hw *hw = mgmtm->hw; +uint8_t fw_wr[64 ]; +struct ulptx_sgl dsgl; +uint32_t wr_size =0 ; +uint8_t im_len =0 ; +uint32_t wr_off =0 ; + +int ret =0 ; + +/* Calculate WR Size for this ELS REQ */ + wr_size =sizeof (struct fw_fcoe_els_ct_wr ); + +/* Send as immediate data if pld < 256 */ +if (pld_len <256 ) { + wr_size +=ALIGN (pld_len,8 ); + im_len = (uint8_t )pld_len; + }else + wr_size +=sizeof (struct ulptx_sgl ); + +/* Roundup WR size in units of 16 bytes */ + wr_size =ALIGN (wr_size,16 ); + +/* Get WR to send ELS REQ */ + ret =csio_wr_get (hw, mgmtm->eq_idx, wr_size, &wrp); +if (ret !=0 ) { +csio_err (hw,"Failed to get WR for ec_req %p ret:%d\n" , + io_req, ret); +return ret; + } + +/* Prepare Generic WR used by all ELS/CT cmd */ +csio_ln_prep_ecwr (io_req, wr_size, im_len, sub_op, + ln->nport_id, rn->nport_id, +csio_rn_flowid (rn), + &fw_wr[0 ]); + +/* Copy ELS/CT WR CMD */ +csio_wr_copy_to_wrp (&fw_wr[0 ], &wrp, wr_off, +sizeof (struct fw_fcoe_els_ct_wr )); + wr_off +=sizeof (struct fw_fcoe_els_ct_wr ); + +/* Copy payload to Immediate section of WR */ +if (im_len) +csio_wr_copy_to_wrp (pld->vaddr, &wrp, wr_off, im_len); +else { +/* Program DSGL to dma payload */ + dsgl.cmd_nsge =htonl (ULPTX_CMD (ULP_TX_SC_DSGL ) | +ULPTX_MORE |ULPTX_NSGE (1 )); + dsgl.len0 =cpu_to_be32 (pld_len); + dsgl.addr0 =cpu_to_be64 (pld->paddr); +csio_wr_copy_to_wrp (&dsgl, &wrp,ALIGN (wr_off,8 ), +sizeof (struct ulptx_sgl )); + } + +/* Issue work request to xmit ELS/CT req to FW */ +csio_wr_issue (mgmtm->hw, mgmtm->eq_idx, false); +return ret; +} + +/* +* csio_ln_mgmt_submit_req - Submit FCOE Mgmt request. +* @io_req - IO Request +* @io_cbfn - Completion handler. +* @req_type - ELS or CT request type +* @pld - Dma Payload buffer +* @pld_len - Payload len +* +* +* This API used submit managment ELS/CT request. +* This called with hw lock held +* Returns: 0 - on success +* -ENOMEM - on error. +*/ +static int +csio_ln_mgmt_submit_req (struct csio_ioreq *io_req, +void (*io_cbfn) (struct csio_hw *,struct csio_ioreq *), +enum fcoe_cmn_type req_type,struct csio_dma_buf *pld, +uint32_t pld_len) +{ +struct csio_hw *hw =csio_lnode_to_hw (io_req->lnode); +struct csio_mgmtm *mgmtm =csio_hw_to_mgmtm (hw); +int rv; + + io_req->io_cbfn = io_cbfn;/* Upper layer callback handler */ + io_req->fw_handle = (uintptr_t ) (io_req); + io_req->eq_idx = mgmtm->eq_idx; + io_req->iq_idx = mgmtm->iq_idx; + + rv =csio_ln_mgmt_submit_wr (mgmtm, io_req, req_type, pld, pld_len); +if (rv ==0 ) { +list_add_tail (&io_req->sm.sm_list, &mgmtm->active_q); + mgmtm->stats.n_active++; + } +return rv; +} + +/* +* csio_ln_fdmi_init - FDMI Init entry point. +* @ln: lnode +*/ +static int +csio_ln_fdmi_init (struct csio_lnode *ln) +{ +struct csio_hw *hw =csio_lnode_to_hw (ln); +struct csio_dma_buf *dma_buf; + +/* Allocate MGMT request required for FDMI */ + ln->mgmt_req =kzalloc (sizeof (struct csio_ioreq ),GFP_KERNEL ); +if (!ln->mgmt_req) { +csio_ln_err (ln,"Failed to alloc ioreq for FDMI\n" ); +CSIO_INC_STATS (hw, n_err_nomem); +return -ENOMEM ; + } + +/* Allocate Dma buffers for FDMI response Payload */ + dma_buf = &ln->mgmt_req->dma_buf; + dma_buf->len =2048 ; + dma_buf->vaddr =pci_alloc_consistent (hw->pdev, dma_buf->len, + &dma_buf->paddr); +if (!dma_buf->vaddr) { +csio_err (hw,"Failed to alloc DMA buffer for FDMI!\n" ); +kfree (ln->mgmt_req); + ln->mgmt_req =NULL ; +return -ENOMEM ; + } + + ln->flags |=CSIO_LNF_FDMI_ENABLE ; +return 0 ; +} + +/* +* csio_ln_fdmi_exit - FDMI exit entry point. +* @ln: lnode +*/ +static int +csio_ln_fdmi_exit (struct csio_lnode *ln) +{ +struct csio_dma_buf *dma_buf; +struct csio_hw *hw =csio_lnode_to_hw (ln); + +if (!ln->mgmt_req) +return 0 ; + + dma_buf = &ln->mgmt_req->dma_buf; +if (dma_buf->vaddr) +pci_free_consistent (hw->pdev, dma_buf->len, dma_buf->vaddr, + dma_buf->paddr); + +kfree (ln->mgmt_req); +return 0 ; +} + +int +csio_scan_done (struct csio_lnode *ln,unsigned long ticks, +unsigned long time,unsigned long max_scan_ticks, +unsigned long delta_scan_ticks) +{ +int rv =0 ; + +if (time >= max_scan_ticks) +return 1 ; + +if (!ln->tgt_scan_tick) + ln->tgt_scan_tick = ticks; + +if (((ticks - ln->tgt_scan_tick) >= delta_scan_ticks)) { +if (!ln->last_scan_ntgts) + ln->last_scan_ntgts = ln->n_scsi_tgts; +else { +if (ln->last_scan_ntgts == ln->n_scsi_tgts) +return 1 ; + + ln->last_scan_ntgts = ln->n_scsi_tgts; + } + ln->tgt_scan_tick = ticks; + } +return rv; +} + +/* +* csio_notify_lnodes: +* @hw: HW module +* @note: Notification +* +* Called from the HW SM to fan out notifications to the +* Lnode SM. Since the HW SM is entered with lock held, +* there is no need to hold locks here. +* +*/ +void +csio_notify_lnodes (struct csio_hw *hw,enum csio_ln_notify note) +{ +struct list_head *tmp; +struct csio_lnode *ln; + +csio_dbg (hw,"Notifying all nodes of event %d\n" , note); + +/* Traverse children lnodes list and send evt */ +list_for_each (tmp, &hw->sln_head) { + ln = (struct csio_lnode *) tmp; + +switch (note) { +case CSIO_LN_NOTIFY_HWREADY : +csio_lnode_start (ln); +break ; + +case CSIO_LN_NOTIFY_HWRESET : +case CSIO_LN_NOTIFY_HWREMOVE : +csio_lnode_close (ln); +break ; + +case CSIO_LN_NOTIFY_HWSTOP : +csio_lnode_stop (ln); +break ; + +default : +break ; + + } + } +} + +/* +* csio_disable_lnodes: +* @hw: HW module +* @portid:port id +* @disable: disable/enable flag. +* If disable=1, disables all lnode hosted on given physical port. +* otherwise enables all the lnodes on given phsysical port. +* This routine need to called with hw lock held. +*/ +void +csio_disable_lnodes (struct csio_hw *hw,uint8_t portid,bool disable) +{ +struct list_head *tmp; +struct csio_lnode *ln; + +csio_dbg (hw,"Notifying event to all nodes of port:%d\n" , portid); + +/* Traverse sibling lnodes list and send evt */ +list_for_each (tmp, &hw->sln_head) { + ln = (struct csio_lnode *) tmp; +if (ln->portid != portid) +continue ; + +if (disable) +csio_lnode_stop (ln); +else +csio_lnode_start (ln); + } +} + +/* +* csio_ln_init - Initialize an lnode. +* @ln: lnode +* +*/ +static int +csio_ln_init (struct csio_lnode *ln) +{ +int rv = -EINVAL ; +struct csio_lnode *rln, *pln; +struct csio_hw *hw =csio_lnode_to_hw (ln); + +csio_init_state (&ln->sm, csio_lns_uninit); + ln->vnp_flowid =CSIO_INVALID_IDX ; + ln->fcf_flowid =CSIO_INVALID_IDX ; + +if (csio_is_root_ln (ln)) { + +/* This is the lnode used during initialization */ + + ln->fcfinfo =kzalloc (sizeof (struct csio_fcf_info ),GFP_KERNEL ); +if (!ln->fcfinfo) { +csio_ln_err (ln,"Failed to alloc FCF record\n" ); +CSIO_INC_STATS (hw, n_err_nomem); + goto err; + } + +INIT_LIST_HEAD (&ln->fcf_lsthead); +kref_init (&ln->fcfinfo->kref); + +if (csio_fdmi_enable &&csio_ln_fdmi_init (ln)) + goto err; + + }else {/* Either a non-root physical or a virtual lnode */ + +/* +* THe rest is common for non-root physical and NPIV lnodes. +* Just get references to all other modules +*/ + rln =csio_root_lnode (ln); + +if (csio_is_npiv_ln (ln)) { +/* NPIV */ + pln =csio_parent_lnode (ln); +kref_get (&pln->fcfinfo->kref); + ln->fcfinfo = pln->fcfinfo; + }else { +/* Another non-root physical lnode (FCF) */ + ln->fcfinfo =kzalloc (sizeof (struct csio_fcf_info ), +GFP_KERNEL ); +if (!ln->fcfinfo) { +csio_ln_err (ln, +"Failed to alloc FCF info\n" ); +CSIO_INC_STATS (hw, n_err_nomem); + goto err; + } + +kref_init (&ln->fcfinfo->kref); + +if (csio_fdmi_enable &&csio_ln_fdmi_init (ln)) + goto err; + } + + }/* if (!csio_is_root_ln(ln)) */ + +return 0 ; +err: +return rv; +} + +static void +csio_ln_exit (struct csio_lnode *ln) +{ +struct csio_lnode *pln; + +csio_cleanup_rns (ln); +if (csio_is_npiv_ln (ln)) { + pln =csio_parent_lnode (ln); +kref_put (&pln->fcfinfo->kref, csio_free_fcfinfo); + }else { +kref_put (&ln->fcfinfo->kref, csio_free_fcfinfo); +if (csio_fdmi_enable) +csio_ln_fdmi_exit (ln); + } + ln->fcfinfo =NULL ; +} + +/** +* csio_lnode_init - Initialize the members of an lnode. +* @ln: lnode +* +*/ +int +csio_lnode_init (struct csio_lnode *ln,struct csio_hw *hw, +struct csio_lnode *pln) +{ +int rv = -EINVAL ; + +/* Link this lnode to hw */ +csio_lnode_to_hw (ln) = hw; + +/* Link child to parent if child lnode */ +if (pln) + ln->pln = pln; +else + ln->pln =NULL ; + +/* Initialize scsi_tgt and timers to zero */ + ln->n_scsi_tgts =0 ; + ln->last_scan_ntgts =0 ; + ln->tgt_scan_tick =0 ; + +/* Initialize rnode list */ +INIT_LIST_HEAD (&ln->rnhead); +INIT_LIST_HEAD (&ln->cln_head); + +/* Initialize log level for debug */ + ln->params.log_level = hw->params.log_level; + +if (csio_ln_init (ln)) + goto err; + +/* Add lnode to list of sibling or children lnodes */ +spin_lock_irq (&hw->lock); +list_add_tail (&ln->sm.sm_list, pln ? &pln->cln_head : &hw->sln_head); +if (pln) + pln->num_vports++; +spin_unlock_irq (&hw->lock); + + hw->num_lns++; + +return 0 ; +err: +csio_lnode_to_hw (ln) =NULL ; +return rv; +} + +/** +* csio_lnode_exit - De-instantiate an lnode. +* @ln: lnode +* +*/ +void +csio_lnode_exit (struct csio_lnode *ln) +{ +struct csio_hw *hw =csio_lnode_to_hw (ln); + +csio_ln_exit (ln); + +/* Remove this lnode from hw->sln_head */ +spin_lock_irq (&hw->lock); + +list_del_init (&ln->sm.sm_list); + +/* If it is children lnode, decrement the +* counter in its parent lnode +*/ +if (ln->pln) + ln->pln->num_vports--; + +/* Update root lnode pointer */ +if (list_empty (&hw->sln_head)) + hw->rln =NULL ; +else + hw->rln = (struct csio_lnode *)csio_list_next (&hw->sln_head); + +spin_unlock_irq (&hw->lock); + +csio_lnode_to_hw (ln) =NULL ; + hw->num_lns--; +}
drivers/scsi/csiostor/csio_rnode.c new file +889 -0
867 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.1
Part of the diff is not shown here. View the raw message.
PATCH v5 7/8 csiostor: Chelsio FCoE offload driver submission (sources part 4).
In reply to Naresh Kumar InnaThis patch contains code to implement the interrupt handling and the fast path I/O functionality. The interrupt handling includes allocation of MSIX vectors, registering and implemeting the interrupt service routines. The fast path I/O functionality includes posting the I/O request to firmware via Work Requests, tracking/completing them, and handling task management requests. SCSI midlayer host template implementation is also covered by this patch.
---
V2:
- Inlined code instead of macro in csio_isr.c
- Use true/false instead if CSIO_TRUE/CSIO_FALSE.
- Use DMA_ defines instead of CSIO_IOREQF_DMA_ defines.
- Replaced large local stack buffer with pre-allocated memory.
- Replaced fast path macros with static functions.
- Removed extra empty lines, needless comment.
V4: Removed needless header file inclusion.
V5:
- Changed over to lockless queuecommand.
- Removed needless header inclusion.
- Re-wrote error paths to reduce lock/unlock ambiguity.
drivers/scsi/csiostor/csio_isr.c | 624 +++++++++ drivers/scsi/csiostor/csio_scsi.c | 2554 +++++++++++++++++++++++++++++++++++++ 2 files changed, 3178 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/csiostor/csio_isr.c create mode 100644 drivers/scsi/csiostor/csio_scsi.c
drivers/scsi/csiostor/csio_isr.c new file +624 -0
@@ -0,0 +1,624 @@ +/* +* This file is part of the Chelsio FCoE driver for Linux. +* +* Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. +* +* This software is available to you under a choice of one of two +* licenses. You may choose to be licensed under the terms of the GNU +* General Public License (GPL) Version 2, available from the file +* COPYING in the main directory of this source tree, or the +* OpenIB.org BSD license below: +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* +* - Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. +* +* - Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#include <linux/kernel.h> +#include <linux/pci.h> +#include <linux/interrupt.h> +#include <linux/cpumask.h> +#include <linux/string.h> + +#include "csio_init.h" +#include "csio_hw.h" + +static irqreturn_t +csio_nondata_isr (int irq,void *dev_id) +{ +struct csio_hw *hw = (struct csio_hw *) dev_id; +int rv; +unsigned long flags; + +if (unlikely (!hw)) +return IRQ_NONE ; + +if (unlikely (pci_channel_offline (hw->pdev))) { +CSIO_INC_STATS (hw, n_pcich_offline); +return IRQ_NONE ; + } + +spin_lock_irqsave (&hw->lock, flags); +csio_hw_slow_intr_handler (hw); + rv =csio_mb_isr_handler (hw); + +if (rv ==0 && !(hw->flags &CSIO_HWF_FWEVT_PENDING )) { + hw->flags |=CSIO_HWF_FWEVT_PENDING ; +spin_unlock_irqrestore (&hw->lock, flags); +schedule_work (&hw->evtq_work); +return IRQ_HANDLED ; + } +spin_unlock_irqrestore (&hw->lock, flags); +return IRQ_HANDLED ; +} + +/* +* csio_fwevt_handler - Common FW event handler routine. +* @hw: HW module. +* +* This is the ISR for FW events. It is shared b/w MSIX +* and INTx handlers. +*/ +static void +csio_fwevt_handler (struct csio_hw *hw) +{ +int rv; +unsigned long flags; + + rv =csio_fwevtq_handler (hw); + +spin_lock_irqsave (&hw->lock, flags); +if (rv ==0 && !(hw->flags &CSIO_HWF_FWEVT_PENDING )) { + hw->flags |=CSIO_HWF_FWEVT_PENDING ; +spin_unlock_irqrestore (&hw->lock, flags); +schedule_work (&hw->evtq_work); +return ; + } +spin_unlock_irqrestore (&hw->lock, flags); + +}/* csio_fwevt_handler */ + +/* +* csio_fwevt_isr() - FW events MSIX ISR +* @irq: +* @dev_id: +* +* Process WRs on the FW event queue. +* +*/ +static irqreturn_t +csio_fwevt_isr (int irq,void *dev_id) +{ +struct csio_hw *hw = (struct csio_hw *) dev_id; + +if (unlikely (!hw)) +return IRQ_NONE ; + +if (unlikely (pci_channel_offline (hw->pdev))) { +CSIO_INC_STATS (hw, n_pcich_offline); +return IRQ_NONE ; + } + +csio_fwevt_handler (hw); + +return IRQ_HANDLED ; +} + +/* +* csio_fwevt_isr() - INTx wrapper for handling FW events. +* @irq: +* @dev_id: +*/ +void +csio_fwevt_intx_handler (struct csio_hw *hw,void *wr,uint32_t len, +struct csio_fl_dma_buf *flb,void *priv) +{ +csio_fwevt_handler (hw); +}/* csio_fwevt_intx_handler */ + +/* +* csio_process_scsi_cmpl - Process a SCSI WR completion. +* @hw: HW module. +* @wr: The completed WR from the ingress queue. +* @len: Length of the WR. +* @flb: Freelist buffer array. +* +*/ +static void +csio_process_scsi_cmpl (struct csio_hw *hw,void *wr,uint32_t len, +struct csio_fl_dma_buf *flb,void *cbfn_q) +{ +struct csio_ioreq *ioreq; +uint8_t *scsiwr; +uint8_t subop; +void *cmnd; +unsigned long flags; + + ioreq =csio_scsi_cmpl_handler (hw, wr, len, flb,NULL , &scsiwr); +if (likely (ioreq)) { +if (unlikely (*scsiwr ==FW_SCSI_ABRT_CLS_WR )) { + subop =FW_SCSI_ABRT_CLS_WR_SUB_OPCODE_GET ( + ((struct fw_scsi_abrt_cls_wr *) + scsiwr)->sub_opcode_to_chk_all_io); + +csio_dbg (hw,"%s cmpl recvd ioreq:%p status:%d\n" , + subop ?"Close" :"Abort" , + ioreq, ioreq->wr_status); + +spin_lock_irqsave (&hw->lock, flags); +if (subop) +csio_scsi_closed (ioreq, + (struct list_head *)cbfn_q); +else +csio_scsi_aborted (ioreq, + (struct list_head *)cbfn_q); +/* +* We call scsi_done for I/Os that driver thinks aborts +* have timed out. If there is a race caused by FW +* completing abort at the exact same time that the +* driver has deteced the abort timeout, the following +* check prevents calling of scsi_done twice for the +* same command: once from the eh_abort_handler, another +* from csio_scsi_isr_handler(). This also avoids the +* need to check if csio_scsi_cmnd(req) is NULL in the +* fast path. +*/ + cmnd =csio_scsi_cmnd (ioreq); +if (unlikely (cmnd ==NULL )) +list_del_init (&ioreq->sm.sm_list); + +spin_unlock_irqrestore (&hw->lock, flags); + +if (unlikely (cmnd ==NULL )) +csio_put_scsi_ioreq_lock (hw, +csio_hw_to_scsim (hw), ioreq); + }else { +spin_lock_irqsave (&hw->lock, flags); +csio_scsi_completed (ioreq, (struct list_head *)cbfn_q); +spin_unlock_irqrestore (&hw->lock, flags); + } + } +} + +/* +* csio_scsi_isr_handler() - Common SCSI ISR handler. +* @iq: Ingress queue pointer. +* +* Processes SCSI completions on the SCSI IQ indicated by scm->iq_idx +* by calling csio_wr_process_iq_idx. If there are completions on the +* isr_cbfn_q, yank them out into a local queue and call their io_cbfns. +* Once done, add these completions onto the freelist. +* This routine is shared b/w MSIX and INTx. +*/ +static inline irqreturn_t +csio_scsi_isr_handler (struct csio_q *iq) +{ +struct csio_hw *hw = (struct csio_hw *)iq->owner; +LIST_HEAD (cbfn_q); +struct list_head *tmp; +struct csio_scsim *scm; +struct csio_ioreq *ioreq; +int isr_completions =0 ; + + scm =csio_hw_to_scsim (hw); + +if (unlikely (csio_wr_process_iq (hw, iq, csio_process_scsi_cmpl, + &cbfn_q) !=0 )) +return IRQ_NONE ; + +/* Call back the completion routines */ +list_for_each (tmp, &cbfn_q) { + ioreq = (struct csio_ioreq *)tmp; + isr_completions++; + ioreq->io_cbfn (hw, ioreq); +/* Release ddp buffer if used for this req */ +if (unlikely (ioreq->dcopy)) +csio_put_scsi_ddp_list_lock (hw, scm, &ioreq->gen_list, + ioreq->nsge); + } + +if (isr_completions) { +/* Return the ioreqs back to ioreq->freelist */ +csio_put_scsi_ioreq_list_lock (hw, scm, &cbfn_q, + isr_completions); + } + +return IRQ_HANDLED ; +} + +/* +* csio_scsi_isr() - SCSI MSIX handler +* @irq: +* @dev_id: +* +* This is the top level SCSI MSIX handler. Calls csio_scsi_isr_handler() +* for handling SCSI completions. +*/ +static irqreturn_t +csio_scsi_isr (int irq,void *dev_id) +{ +struct csio_q *iq = (struct csio_q *) dev_id; +struct csio_hw *hw; + +if (unlikely (!iq)) +return IRQ_NONE ; + + hw = (struct csio_hw *)iq->owner; + +if (unlikely (pci_channel_offline (hw->pdev))) { +CSIO_INC_STATS (hw, n_pcich_offline); +return IRQ_NONE ; + } + +csio_scsi_isr_handler (iq); + +return IRQ_HANDLED ; +} + +/* +* csio_scsi_intx_handler() - SCSI INTx handler +* @irq: +* @dev_id: +* +* This is the top level SCSI INTx handler. Calls csio_scsi_isr_handler() +* for handling SCSI completions. +*/ +void +csio_scsi_intx_handler (struct csio_hw *hw,void *wr,uint32_t len, +struct csio_fl_dma_buf *flb,void *priv) +{ +struct csio_q *iq = priv; + +csio_scsi_isr_handler (iq); + +}/* csio_scsi_intx_handler */ + +/* +* csio_fcoe_isr() - INTx/MSI interrupt service routine for FCoE. +* @irq: +* @dev_id: +* +* +*/ +static irqreturn_t +csio_fcoe_isr (int irq,void *dev_id) +{ +struct csio_hw *hw = (struct csio_hw *) dev_id; +struct csio_q *intx_q =NULL ; +int rv; +irqreturn_t ret =IRQ_NONE ; +unsigned long flags; + +if (unlikely (!hw)) +return IRQ_NONE ; + +if (unlikely (pci_channel_offline (hw->pdev))) { +CSIO_INC_STATS (hw, n_pcich_offline); +return IRQ_NONE ; + } + +/* Disable the interrupt for this PCI function. */ +if (hw->intr_mode ==CSIO_IM_INTX ) +csio_wr_reg32 (hw,0 ,MYPF_REG (PCIE_PF_CLI )); + +/* +* The read in the following function will flush the +* above write. +*/ +if (csio_hw_slow_intr_handler (hw)) + ret =IRQ_HANDLED ; + +/* Get the INTx Forward interrupt IQ. */ + intx_q =csio_get_q (hw, hw->intr_iq_idx); + +CSIO_DB_ASSERT (intx_q); + +/* IQ handler is not possible for intx_q, hence pass in NULL */ +if (likely (csio_wr_process_iq (hw, intx_q,NULL ,NULL ) ==0 )) + ret =IRQ_HANDLED ; + +spin_lock_irqsave (&hw->lock, flags); + rv =csio_mb_isr_handler (hw); +if (rv ==0 && !(hw->flags &CSIO_HWF_FWEVT_PENDING )) { + hw->flags |=CSIO_HWF_FWEVT_PENDING ; +spin_unlock_irqrestore (&hw->lock, flags); +schedule_work (&hw->evtq_work); +return IRQ_HANDLED ; + } +spin_unlock_irqrestore (&hw->lock, flags); + +return ret; +} + +static void +csio_add_msix_desc (struct csio_hw *hw) +{ +int i; +struct csio_msix_entries *entryp = &hw->msix_entries[0 ]; +int k =CSIO_EXTRA_VECS ; +int len =sizeof (entryp->desc) -1 ; +int cnt = hw->num_sqsets + k; + +/* Non-data vector */ +memset (entryp->desc,0 , len +1 ); +snprintf (entryp->desc, len,"csio-%02x:%02x:%x-nondata" , +CSIO_PCI_BUS (hw),CSIO_PCI_DEV (hw),CSIO_PCI_FUNC (hw)); + + entryp++; +memset (entryp->desc,0 , len +1 ); +snprintf (entryp->desc, len,"csio-%02x:%02x:%x-fwevt" , +CSIO_PCI_BUS (hw),CSIO_PCI_DEV (hw),CSIO_PCI_FUNC (hw)); + entryp++; + +/* Name SCSI vecs */ +for (i = k; i < cnt; i++, entryp++) { +memset (entryp->desc,0 , len +1 ); +snprintf (entryp->desc, len,"csio-%02x:%02x:%x-scsi%d" , +CSIO_PCI_BUS (hw),CSIO_PCI_DEV (hw), +CSIO_PCI_FUNC (hw), i -CSIO_EXTRA_VECS ); + } +} + +int +csio_request_irqs (struct csio_hw *hw) +{ +int rv, i, j, k =0 ; +struct csio_msix_entries *entryp = &hw->msix_entries[0 ]; +struct csio_scsi_cpu_info *info; + +if (hw->intr_mode !=CSIO_IM_MSIX ) { + rv =request_irq (hw->pdev->irq, csio_fcoe_isr, + (hw->intr_mode ==CSIO_IM_MSI ) ? +0 :IRQF_SHARED , +KBUILD_MODNAME , hw); +if (rv) { +if (hw->intr_mode ==CSIO_IM_MSI ) +pci_disable_msi (hw->pdev); +csio_err (hw,"Failed to allocate interrupt line.\n" ); +return -EINVAL ; + } + + goto out; + } + +/* Add the MSIX vector descriptions */ +csio_add_msix_desc (hw); + + rv =request_irq (entryp[k].vector, csio_nondata_isr,0 , + entryp[k].desc, hw); +if (rv) { +csio_err (hw,"IRQ request failed for vec %d err:%d\n" , + entryp[k].vector, rv); + goto err; + } + + entryp[k++].dev_id = (void *)hw; + + rv =request_irq (entryp[k].vector, csio_fwevt_isr,0 , + entryp[k].desc, hw); +if (rv) { +csio_err (hw,"IRQ request failed for vec %d err:%d\n" , + entryp[k].vector, rv); + goto err; + } + + entryp[k++].dev_id = (void *)hw; + +/* Allocate IRQs for SCSI */ +for (i =0 ; i < hw->num_pports; i++) { + info = &hw->scsi_cpu_info[i]; +for (j =0 ; j < info->max_cpus; j++, k++) { +struct csio_scsi_qset *sqset = &hw->sqset[i][j]; +struct csio_q *q = hw->wrm.q_arr[sqset->iq_idx]; + + rv =request_irq (entryp[k].vector, csio_scsi_isr,0 , + entryp[k].desc, q); +if (rv) { +csio_err (hw, +"IRQ request failed for vec %d err:%d\n" , + entryp[k].vector, rv); + goto err; + } + + entryp[k].dev_id = (void *)q; + + }/* for all scsi cpus */ + }/* for all ports */ + +out: + hw->flags |=CSIO_HWF_HOST_INTR_ENABLED ; + +return 0 ; + +err: +for (i =0 ; i < k; i++) { + entryp = &hw->msix_entries[i]; +free_irq (entryp->vector, entryp->dev_id); + } +pci_disable_msix (hw->pdev); + +return -EINVAL ; +} + +static void +csio_disable_msix (struct csio_hw *hw,bool free) +{ +int i; +struct csio_msix_entries *entryp; +int cnt = hw->num_sqsets +CSIO_EXTRA_VECS ; + +if (free) { +for (i =0 ; i < cnt; i++) { + entryp = &hw->msix_entries[i]; +free_irq (entryp->vector, entryp->dev_id); + } + } +pci_disable_msix (hw->pdev); +} + +/* Reduce per-port max possible CPUs */ +static void +csio_reduce_sqsets (struct csio_hw *hw,int cnt) +{ +int i; +struct csio_scsi_cpu_info *info; + +while (cnt < hw->num_sqsets) { +for (i =0 ; i < hw->num_pports; i++) { + info = &hw->scsi_cpu_info[i]; +if (info->max_cpus >1 ) { + info->max_cpus--; + hw->num_sqsets--; +if (hw->num_sqsets <= cnt) +break ; + } + } + } + +csio_dbg (hw,"Reduced sqsets to %d\n" , hw->num_sqsets); +} + +static int +csio_enable_msix (struct csio_hw *hw) +{ +int rv, i, j, k, n, min, cnt; +struct csio_msix_entries *entryp; +struct msix_entry *entries; +int extra =CSIO_EXTRA_VECS ; +struct csio_scsi_cpu_info *info; + + min = hw->num_pports + extra; + cnt = hw->num_sqsets + extra; + +/* Max vectors required based on #niqs configured in fw */ +if (hw->flags &CSIO_HWF_USING_SOFT_PARAMS || !csio_is_hw_master (hw)) + cnt =min_t (uint8_t, hw->cfg_niq, cnt); + + entries =kzalloc (sizeof (struct msix_entry ) * cnt,GFP_KERNEL ); +if (!entries) +return -ENOMEM ; + +for (i =0 ; i < cnt; i++) + entries[i].entry = (uint16_t )i; + +csio_dbg (hw,"FW supp #niq:%d, trying %d msix's\n" , hw->cfg_niq, cnt); + +while ((rv =pci_enable_msix (hw->pdev, entries, cnt)) >= min) + cnt = rv; +if (!rv) { +if (cnt < (hw->num_sqsets + extra)) { +csio_dbg (hw,"Reducing sqsets to %d\n" , cnt - extra); +csio_reduce_sqsets (hw, cnt - extra); + } + }else { +if (rv >0 ) { +pci_disable_msix (hw->pdev); +csio_info (hw,"Not using MSI-X, remainder:%d\n" , rv); + } + +kfree (entries); +return -ENOMEM ; + } + +/* Save off vectors */ +for (i =0 ; i < cnt; i++) { + entryp = &hw->msix_entries[i]; + entryp->vector = entries[i].vector; + } + +/* Distribute vectors */ + k =0 ; +csio_set_nondata_intr_idx (hw, entries[k].entry); +csio_set_mb_intr_idx (csio_hw_to_mbm (hw), entries[k++].entry); +csio_set_fwevt_intr_idx (hw, entries[k++].entry); + +for (i =0 ; i < hw->num_pports; i++) { + info = &hw->scsi_cpu_info[i]; + +for (j =0 ; j < hw->num_scsi_msix_cpus; j++) { + n = (j % info->max_cpus) + k; + hw->sqset[i][j].intr_idx = entries[n].entry; + } + + k += info->max_cpus; + } + +kfree (entries); +return 0 ; +} + +void +csio_intr_enable (struct csio_hw *hw) +{ + hw->intr_mode =CSIO_IM_NONE ; + hw->flags &= ~CSIO_HWF_HOST_INTR_ENABLED ; + +/* Try MSIX, then MSI or fall back to INTx */ +if ((csio_msi ==2 ) && !csio_enable_msix (hw)) + hw->intr_mode =CSIO_IM_MSIX ; +else { +/* Max iqs required based on #niqs configured in fw */ +if (hw->flags &CSIO_HWF_USING_SOFT_PARAMS || + !csio_is_hw_master (hw)) { +int extra =CSIO_EXTRA_MSI_IQS ; + +if (hw->cfg_niq < (hw->num_sqsets + extra)) { +csio_dbg (hw,"Reducing sqsets to %d\n" , + hw->cfg_niq - extra); +csio_reduce_sqsets (hw, hw->cfg_niq - extra); + } + } + +if ((csio_msi ==1 ) && !pci_enable_msi (hw->pdev)) + hw->intr_mode =CSIO_IM_MSI ; +else + hw->intr_mode =CSIO_IM_INTX ; + } + +csio_dbg (hw,"Using %s interrupt mode.\n" , + (hw->intr_mode ==CSIO_IM_MSIX ) ?"MSIX" : + ((hw->intr_mode ==CSIO_IM_MSI ) ?"MSI" :"INTx" )); +} + +void +csio_intr_disable (struct csio_hw *hw,bool free) +{ +csio_hw_intr_disable (hw); + +switch (hw->intr_mode) { +case CSIO_IM_MSIX : +csio_disable_msix (hw, free); +break ; +case CSIO_IM_MSI : +if (free) +free_irq (hw->pdev->irq, hw); +pci_disable_msi (hw->pdev); +break ; +case CSIO_IM_INTX : +if (free) +free_irq (hw->pdev->irq, hw); +break ; +default : +break ; + } + hw->intr_mode =CSIO_IM_NONE ; + hw->flags &= ~CSIO_HWF_HOST_INTR_ENABLED ; +}
drivers/scsi/csiostor/csio_scsi.c new file +2554 -0
2,376 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.1
Part of the diff is not shown here. View the raw message.
PATCH v5 8/8 csiostor: Chelsio FCoE offload driver submission (sources part 5).
In reply to Naresh Kumar InnaThis patch contains the hardware interfacing functionality (chip/firmware initialization/setup) and error handling. It also has slow path event handling functionality, the Makefile and Kconfig changes.
---
V3: Added const qualifier to adapter descriptor table.
V5: Re-wrote error paths to reduce lock/unlock ambiguity.
drivers/scsi/Kconfig | 1 + drivers/scsi/Makefile | 1 + drivers/scsi/csiostor/Kconfig | 19 + drivers/scsi/csiostor/Makefile | 11 + drivers/scsi/csiostor/csio_hw.c | 4395 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 4427 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/csiostor/Kconfig create mode 100644 drivers/scsi/csiostor/Makefile create mode 100644 drivers/scsi/csiostor/csio_hw.c
drivers/scsi/Kconfig +1 -0
@@ -1812,6 +1812,7 @@ config SCSI_VIRTIO This is the virtual HBA driver for virtio. If the kernel will be used in a virtual machine, say Y or M. +source "drivers/scsi/csiostor/Kconfig" endif # SCSI_LOWLEVEL
drivers/scsi/Makefile +1 -0
@@ -90,6 +90,7 @@ obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/ obj-$(CONFIG_SCSI_QLA_ISCSI) += libiscsi.o qla4xxx/ obj-$(CONFIG_SCSI_LPFC) += lpfc/ obj-$(CONFIG_SCSI_BFA_FC) += bfa/ +obj-$(CONFIG_SCSI_CHELSIO_FCOE) += csiostor/ obj-$(CONFIG_SCSI_PAS16) += pas16.o obj-$(CONFIG_SCSI_T128) += t128.o obj-$(CONFIG_SCSI_DMX3191D) += dmx3191d.o
drivers/scsi/csiostor/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +config SCSI_CHELSIO_FCOE + tristate "Chelsio Communications FCoE support" + depends on PCI && SCSI + select SCSI_FC_ATTRS + select FW_LOADER + help + This driver supports FCoE Offload functionality over + Chelsio T4-based 10Gb Converged Network Adapters. + + For general information about Chelsio and our products, visit + our website at <http://www.chelsio.com>. + + For customer support, please visit our customer support page at + <http://www.chelsio.com/support.html>. + + Please send feedback to <[email protected]>. + + To compile this driver as a module choose M here; the module + will be called csiostor.
drivers/scsi/csiostor/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# +## Chelsio FCoE driver +# +## + +ccflags-y += -I$(srctree)/drivers/net/ethernet/chelsio/cxgb4 + +obj-$(CONFIG_SCSI_CHELSIO_FCOE) += csiostor.o + +csiostor-objs := csio_attr.o csio_init.o csio_lnode.o csio_scsi.o \ + csio_hw.o csio_isr.o csio_mb.o csio_rnode.o csio_wr.o
drivers/scsi/csiostor/csio_hw.c new file +4395 -0
2,956 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.1
Part of the diff is not shown here. View the raw message.
Hi James,
Do you have any update with regards to the review of this driver? You were mentioning about getting FC folks to take a look at it.
Thanks,
Naresh.
Quoted 94 lines · Naresh Kumar Inna
This is the initial submission of the Chelsio FCoE offload driver (csiostor) to the upstream kernel. This driver currently supports FCoE offload functionality over Chelsio T4-based 10Gb Converged Network Adapters.
The following patches contain the driver sources for csiostor driver and updates to
firmware/hardwareheader files shared between csiostor, cxgb4 (Chelsio T4-based NIC driver) and cxgb4vf (Chelsio T4-based Virtual Function NIC driver). The csiostor driver is dependent on these header updates. These patches have been generated against scsi 'misc' branch.csiostor is a low level SCSI driver that interfaces with PCI, SCSI midlayer and FC transport subsystems. This driver claims the FCoE PCIe function on Chelsio Converged Network Adapters. It relies on firmware events for slow path operations like discovery, thereby offloading session management. The driver programs firmware via Work Request interfaces for fast path I/O offload features.
Version V5 of the patches addresses James's comment, primary among them being moving to the lockless version of
queuecommand(). Rest of the V5 changes are listed in the individual patches.Here is the brief description of patches:
[V5 PATCH 1/8]: Updates to header files shared between cxgb4, cxgb4vf and
csiostor.
[V5 PATCH 2/8]: Header files part 1.
[V5 PATCH 3/8]: Header files part 2.
[V5 PATCH 4/8]: Driver initialization and Work Request services. [V5 PATCH 5/8]: FC transport interfaces and mailbox services. [V5 PATCH 6/8]: Local and remote port state tracking functionality. [V5 PATCH 7/8]: Interrupt handling and fast path I/O functionality. [V5 PATCH 8/8]: Hardware interface,MakefileandKconfigchanges.Naresh Kumar Inna (8):
cxgb4/cxgb4vf: Chelsio FCoE offload driver submission (common header
updates).
csiostor: Chelsio FCoE offload driver submission (headers part 1).
csiostor: Chelsio FCoE offload driver submission (headers part 2).
csiostor: Chelsio FCoE offload driver submission (sources part 1).
csiostor: Chelsio FCoE offload driver submission (sources part 2).
csiostor: Chelsio FCoE offload driver submission (sources part 3).
csiostor: Chelsio FCoE offload driver submission (sources part 4).
csiostor: Chelsio FCoE offload driver submission (sources part 5).drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 10 +- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 16 +- drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 69 +- drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 104 +- drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 11 +- drivers/scsi/Kconfig | 1 + drivers/scsi/Makefile | 1 + drivers/scsi/csiostor/Kconfig | 19 + drivers/scsi/csiostor/Makefile | 11 + drivers/scsi/csiostor/csio_attr.c | 804 +++++ drivers/scsi/csiostor/csio_defs.h | 121 + drivers/scsi/csiostor/csio_hw.c | 4395 +++++++++++++++++++++++ drivers/scsi/csiostor/csio_hw.h | 666 ++++ drivers/scsi/csiostor/csio_init.c | 1274 +++++++ drivers/scsi/csiostor/csio_init.h | 158 + drivers/scsi/csiostor/csio_isr.c | 624 ++++ drivers/scsi/csiostor/csio_lnode.c | 2133 +++++++++++ drivers/scsi/csiostor/csio_lnode.h | 255 ++ drivers/scsi/csiostor/csio_mb.c | 1769 +++++++++ drivers/scsi/csiostor/csio_mb.h | 278 ++ drivers/scsi/csiostor/csio_rnode.c | 889 +++++ drivers/scsi/csiostor/csio_rnode.h | 141 + drivers/scsi/csiostor/csio_scsi.c | 2554 +++++++++++++ drivers/scsi/csiostor/csio_scsi.h | 342 ++ drivers/scsi/csiostor/csio_wr.c | 1632 +++++++++ drivers/scsi/csiostor/csio_wr.h | 512 +++ drivers/scsi/csiostor/t4fw_api_stor.h | 578 +++ 29 files changed, 19333 insertions(+), 37 deletions(-) create mode 100644 drivers/scsi/csiostor/Kconfig create mode 100644 drivers/scsi/csiostor/Makefile create mode 100644 drivers/scsi/csiostor/csio_attr.c create mode 100644 drivers/scsi/csiostor/csio_defs.h create mode 100644 drivers/scsi/csiostor/csio_hw.c create mode 100644 drivers/scsi/csiostor/csio_hw.h create mode 100644 drivers/scsi/csiostor/csio_init.c create mode 100644 drivers/scsi/csiostor/csio_init.h create mode 100644 drivers/scsi/csiostor/csio_isr.c create mode 100644 drivers/scsi/csiostor/csio_lnode.c create mode 100644 drivers/scsi/csiostor/csio_lnode.h create mode 100644 drivers/scsi/csiostor/csio_mb.c create mode 100644 drivers/scsi/csiostor/csio_mb.h create mode 100644 drivers/scsi/csiostor/csio_rnode.c create mode 100644 drivers/scsi/csiostor/csio_rnode.h create mode 100644 drivers/scsi/csiostor/csio_scsi.c create mode 100644 drivers/scsi/csiostor/csio_scsi.h create mode 100644 drivers/scsi/csiostor/csio_wr.c create mode 100644 drivers/scsi/csiostor/csio_wr.h create mode 100644 drivers/scsi/csiostor/t4fw_api_stor.h
Hi James,
Please let me know if you are expecting any more changes to this driver to resume its review. I have addressed all review comments as of the last series of patches (below).
Thanks,
Naresh.
Quoted 94 lines · Naresh Kumar Inna
This is the initial submission of the Chelsio FCoE offload driver (csiostor) to the upstream kernel. This driver currently supports FCoE offload functionality over Chelsio T4-based 10Gb Converged Network Adapters.
The following patches contain the driver sources for csiostor driver and updates to
firmware/hardwareheader files shared between csiostor, cxgb4 (Chelsio T4-based NIC driver) and cxgb4vf (Chelsio T4-based Virtual Function NIC driver). The csiostor driver is dependent on these header updates. These patches have been generated against scsi 'misc' branch.csiostor is a low level SCSI driver that interfaces with PCI, SCSI midlayer and FC transport subsystems. This driver claims the FCoE PCIe function on Chelsio Converged Network Adapters. It relies on firmware events for slow path operations like discovery, thereby offloading session management. The driver programs firmware via Work Request interfaces for fast path I/O offload features.
Version V5 of the patches addresses James's comment, primary among them being moving to the lockless version of
queuecommand(). Rest of the V5 changes are listed in the individual patches.Here is the brief description of patches:
[V5 PATCH 1/8]: Updates to header files shared between cxgb4, cxgb4vf and
csiostor.
[V5 PATCH 2/8]: Header files part 1.
[V5 PATCH 3/8]: Header files part 2.
[V5 PATCH 4/8]: Driver initialization and Work Request services. [V5 PATCH 5/8]: FC transport interfaces and mailbox services. [V5 PATCH 6/8]: Local and remote port state tracking functionality. [V5 PATCH 7/8]: Interrupt handling and fast path I/O functionality. [V5 PATCH 8/8]: Hardware interface,MakefileandKconfigchanges.Naresh Kumar Inna (8):
cxgb4/cxgb4vf: Chelsio FCoE offload driver submission (common header
updates).
csiostor: Chelsio FCoE offload driver submission (headers part 1).
csiostor: Chelsio FCoE offload driver submission (headers part 2).
csiostor: Chelsio FCoE offload driver submission (sources part 1).
csiostor: Chelsio FCoE offload driver submission (sources part 2).
csiostor: Chelsio FCoE offload driver submission (sources part 3).
csiostor: Chelsio FCoE offload driver submission (sources part 4).
csiostor: Chelsio FCoE offload driver submission (sources part 5).drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- drivers/net/ethernet/chelsio/cxgb4/sge.c | 10 +- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 16 +- drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 69 +- drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 104 +- drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 11 +- drivers/scsi/Kconfig | 1 + drivers/scsi/Makefile | 1 + drivers/scsi/csiostor/Kconfig | 19 + drivers/scsi/csiostor/Makefile | 11 + drivers/scsi/csiostor/csio_attr.c | 804 +++++ drivers/scsi/csiostor/csio_defs.h | 121 + drivers/scsi/csiostor/csio_hw.c | 4395 +++++++++++++++++++++++ drivers/scsi/csiostor/csio_hw.h | 666 ++++ drivers/scsi/csiostor/csio_init.c | 1274 +++++++ drivers/scsi/csiostor/csio_init.h | 158 + drivers/scsi/csiostor/csio_isr.c | 624 ++++ drivers/scsi/csiostor/csio_lnode.c | 2133 +++++++++++ drivers/scsi/csiostor/csio_lnode.h | 255 ++ drivers/scsi/csiostor/csio_mb.c | 1769 +++++++++ drivers/scsi/csiostor/csio_mb.h | 278 ++ drivers/scsi/csiostor/csio_rnode.c | 889 +++++ drivers/scsi/csiostor/csio_rnode.h | 141 + drivers/scsi/csiostor/csio_scsi.c | 2554 +++++++++++++ drivers/scsi/csiostor/csio_scsi.h | 342 ++ drivers/scsi/csiostor/csio_wr.c | 1632 +++++++++ drivers/scsi/csiostor/csio_wr.h | 512 +++ drivers/scsi/csiostor/t4fw_api_stor.h | 578 +++ 29 files changed, 19333 insertions(+), 37 deletions(-) create mode 100644 drivers/scsi/csiostor/Kconfig create mode 100644 drivers/scsi/csiostor/Makefile create mode 100644 drivers/scsi/csiostor/csio_attr.c create mode 100644 drivers/scsi/csiostor/csio_defs.h create mode 100644 drivers/scsi/csiostor/csio_hw.c create mode 100644 drivers/scsi/csiostor/csio_hw.h create mode 100644 drivers/scsi/csiostor/csio_init.c create mode 100644 drivers/scsi/csiostor/csio_init.h create mode 100644 drivers/scsi/csiostor/csio_isr.c create mode 100644 drivers/scsi/csiostor/csio_lnode.c create mode 100644 drivers/scsi/csiostor/csio_lnode.h create mode 100644 drivers/scsi/csiostor/csio_mb.c create mode 100644 drivers/scsi/csiostor/csio_mb.h create mode 100644 drivers/scsi/csiostor/csio_rnode.c create mode 100644 drivers/scsi/csiostor/csio_rnode.h create mode 100644 drivers/scsi/csiostor/csio_scsi.c create mode 100644 drivers/scsi/csiostor/csio_scsi.h create mode 100644 drivers/scsi/csiostor/csio_wr.c create mode 100644 drivers/scsi/csiostor/csio_wr.h create mode 100644 drivers/scsi/csiostor/t4fw_api_stor.h
James Bottomley
maintainerQuoted 3 lines · Naresh Kumar Inna
Please let me know if you are expecting any more changes to this driver to resume its review. I have addressed all review comments as of the last series of patches (below).
No, I don't think so, but please understand that the review talent is all busy concentrating on the merge window for at least the next week and a bit, so I won't be able to get them to pay attention until 3.7-rc1 is released.
Thanks,
James
Hi James,
I hope now is a good time to resume the review of this driver. I will send out v6 version of the driver shortly, which has some bug fixes and other cleanup.
Thanks,
Naresh.
Quoted 15 lines · James Bottomley
Quoted 3 lines · Naresh Kumar Inna
Please let me know if you are expecting any more changes to this driver to resume its review. I have addressed all review comments as of the last series of patches (below).
No, I don't think so, but please understand that the review talent is all busy concentrating on the merge window for at least the next week and a bit, so I won't be able to get them to pay attention until 3.7-rc1 is released.
Thanks,
James