Re: [PATCH v4 5/9] snic:add SCSI handling, AEN, and fwreset handling
Hi Hannes, Thank you for reviewing patches. Please find responses inline. I will incorporate the comments and suggestions in next patch submittal. On 09/04/15 6:46 pm, Hannes Reinecke h...@suse.de wrote: Hi Narsimhulu, please find some comments inline. On 04/09/2015 01:49 PM, Narsimhulu Musini wrote: snic_scsi.c contains scsi handling, includes queuing io, abort, lun reset, and host reset. Also it handles asynchronous event notifications from FW. Signed-off-by: Narsimhulu Musini nmus...@cisco.com Signed-off-by: Sesidhar Baddela sebad...@cisco.com --- * v2 - Changed queuecommand to lock-free version. - Converted custom error codes to standard error codes. drivers/scsi/snic/snic_scsi.c | 2638 + 1 file changed, 2638 insertions(+) create mode 100644 drivers/scsi/snic/snic_scsi.c diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c new file mode 100644 index 000..5d877f0 --- /dev/null +++ b/drivers/scsi/snic/snic_scsi.c @@ -0,0 +1,2638 @@ +/* + * Copyright 2014 Cisco Systems, Inc. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * 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/mempool.h +#include linux/errno.h +#include linux/init.h +#include linux/workqueue.h +#include linux/pci.h +#include linux/spinlock.h +#include linux/delay.h +#include linux/gfp.h +#include scsi/scsi.h +#include scsi/scsi_host.h +#include scsi/scsi_device.h +#include scsi/scsi_cmnd.h +#include scsi/scsi_tcq.h +#include scsi/scsi_dbg.h + +#include snic_io.h +#include snic.h + +#define snic_cmd_tag(sc)(((struct scsi_cmnd *) sc)-request-tag) + +const char *snic_state_str[] = { +[SNIC_INIT] = SNIC_INIT, +[SNIC_ERROR]= SNIC_ERROR, +[SNIC_ONLINE] = SNIC_ONLINE, +[SNIC_OFFLINE] = SNIC_OFFLINE, +[SNIC_FWRESET] = SNIC_FWRESET, +}; + +static const char * const snic_req_state_str[] = { +[SNIC_IOREQ_NOT_INITED] = SNIC_IOREQ_NOT_INITED, +[SNIC_IOREQ_PENDING]= SNIC_IOREQ_PENDING, +[SNIC_IOREQ_ABTS_PENDING] = SNIC_IOREQ_ABTS_PENDING, +[SNIC_IOREQ_ABTS_COMPLETE] = SNIC_IOREQ_ABTS_COMPELTE, +[SNIC_IOREQ_LR_PENDING] = SNIC_IOREQ_LR_PENDING, +[SNIC_IOREQ_LR_COMPLETE] = SNIC_IOREQ_LR_COMPELTE, +[SNIC_IOREQ_COMPLETE] = SNIC_IOREQ_CMD_COMPELTE, +}; + +/* snic cmd status strings */ +static const char * const snic_io_status_str[] = { +[SNIC_STAT_IO_SUCCESS] = SNIC_STAT_IO_SUCCESS, /* 0x0 */ +[SNIC_STAT_INVALID_HDR] = SNIC_STAT_INVALID_HDR, +[SNIC_STAT_OUT_OF_RES] = SNIC_STAT_OUT_OF_RES, +[SNIC_STAT_INVALID_PARM] = SNIC_STAT_INVALID_PARM, +[SNIC_STAT_REQ_NOT_SUP] = SNIC_STAT_REQ_NOT_SUP, +[SNIC_STAT_IO_NOT_FOUND] = SNIC_STAT_IO_NOT_FOUND, +[SNIC_STAT_ABORTED] = SNIC_STAT_ABORTED, +[SNIC_STAT_TIMEOUT] = SNIC_STAT_TIMEOUT, +[SNIC_STAT_SGL_INVALID] = SNIC_STAT_SGL_INVALID, +[SNIC_STAT_DATA_CNT_MISMATCH] = SNIC_STAT_DATA_CNT_MISMATCH, +[SNIC_STAT_FW_ERR] = SNIC_STAT_FW_ERR, +[SNIC_STAT_ITMF_REJECT] = SNIC_STAT_ITMF_REJECT, +[SNIC_STAT_ITMF_FAIL] = SNIC_STAT_ITMF_FAIL, +[SNIC_STAT_ITMF_INCORRECT_LUN] = SNIC_STAT_ITMF_INCORRECT_LUN, +[SNIC_STAT_CMND_REJECT] = SNIC_STAT_CMND_REJECT, +[SNIC_STAT_DEV_OFFLINE] = SNIC_STAT_DEV_OFFLINE, +[SNIC_STAT_NO_BOOTLUN] = SNIC_STAT_NO_BOOTLUN, +[SNIC_STAT_SCSI_ERR]= SNIC_STAT_SCSI_ERR, +[SNIC_STAT_NOT_READY] = SNIC_STAT_NOT_READY, +[SNIC_STAT_FATAL_ERROR] = SNIC_STAT_FATAL_ERROR, +}; + +static void snic_scsi_cleanup(struct snic *, int); + +const char * +snic_state_to_str(unsigned int state) +{ +if (state = ARRAY_SIZE(snic_state_str) || !snic_state_str[state]) +return Unknown; + +return snic_state_str[state]; +} + +static const char * +snic_io_status_to_str(unsigned int state) +{ +if ((state = ARRAY_SIZE(snic_io_status_str)) || + (!snic_io_status_str[state])) +return Unknown; + +return snic_io_status_str[state]; +} + +static const char * +snic_ioreq_state_to_str(unsigned int state) +{ +if (state = ARRAY_SIZE(snic_req_state_str) || +!snic_req_state_str[state]) +return Unknown; + +return snic_req_state_str[state]; +} + +static
Re: [PATCH v4 5/9] snic:add SCSI handling, AEN, and fwreset handling
Hi Narsimhulu, please find some comments inline. On 04/09/2015 01:49 PM, Narsimhulu Musini wrote: snic_scsi.c contains scsi handling, includes queuing io, abort, lun reset, and host reset. Also it handles asynchronous event notifications from FW. Signed-off-by: Narsimhulu Musini nmus...@cisco.com Signed-off-by: Sesidhar Baddela sebad...@cisco.com --- * v2 - Changed queuecommand to lock-free version. - Converted custom error codes to standard error codes. drivers/scsi/snic/snic_scsi.c | 2638 + 1 file changed, 2638 insertions(+) create mode 100644 drivers/scsi/snic/snic_scsi.c diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c new file mode 100644 index 000..5d877f0 --- /dev/null +++ b/drivers/scsi/snic/snic_scsi.c @@ -0,0 +1,2638 @@ +/* + * Copyright 2014 Cisco Systems, Inc. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * 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/mempool.h +#include linux/errno.h +#include linux/init.h +#include linux/workqueue.h +#include linux/pci.h +#include linux/spinlock.h +#include linux/delay.h +#include linux/gfp.h +#include scsi/scsi.h +#include scsi/scsi_host.h +#include scsi/scsi_device.h +#include scsi/scsi_cmnd.h +#include scsi/scsi_tcq.h +#include scsi/scsi_dbg.h + +#include snic_io.h +#include snic.h + +#define snic_cmd_tag(sc) (((struct scsi_cmnd *) sc)-request-tag) + +const char *snic_state_str[] = { + [SNIC_INIT] = SNIC_INIT, + [SNIC_ERROR]= SNIC_ERROR, + [SNIC_ONLINE] = SNIC_ONLINE, + [SNIC_OFFLINE] = SNIC_OFFLINE, + [SNIC_FWRESET] = SNIC_FWRESET, +}; + +static const char * const snic_req_state_str[] = { + [SNIC_IOREQ_NOT_INITED] = SNIC_IOREQ_NOT_INITED, + [SNIC_IOREQ_PENDING]= SNIC_IOREQ_PENDING, + [SNIC_IOREQ_ABTS_PENDING] = SNIC_IOREQ_ABTS_PENDING, + [SNIC_IOREQ_ABTS_COMPLETE] = SNIC_IOREQ_ABTS_COMPELTE, + [SNIC_IOREQ_LR_PENDING] = SNIC_IOREQ_LR_PENDING, + [SNIC_IOREQ_LR_COMPLETE] = SNIC_IOREQ_LR_COMPELTE, + [SNIC_IOREQ_COMPLETE] = SNIC_IOREQ_CMD_COMPELTE, +}; + +/* snic cmd status strings */ +static const char * const snic_io_status_str[] = { + [SNIC_STAT_IO_SUCCESS] = SNIC_STAT_IO_SUCCESS, /* 0x0 */ + [SNIC_STAT_INVALID_HDR] = SNIC_STAT_INVALID_HDR, + [SNIC_STAT_OUT_OF_RES] = SNIC_STAT_OUT_OF_RES, + [SNIC_STAT_INVALID_PARM] = SNIC_STAT_INVALID_PARM, + [SNIC_STAT_REQ_NOT_SUP] = SNIC_STAT_REQ_NOT_SUP, + [SNIC_STAT_IO_NOT_FOUND] = SNIC_STAT_IO_NOT_FOUND, + [SNIC_STAT_ABORTED] = SNIC_STAT_ABORTED, + [SNIC_STAT_TIMEOUT] = SNIC_STAT_TIMEOUT, + [SNIC_STAT_SGL_INVALID] = SNIC_STAT_SGL_INVALID, + [SNIC_STAT_DATA_CNT_MISMATCH] = SNIC_STAT_DATA_CNT_MISMATCH, + [SNIC_STAT_FW_ERR] = SNIC_STAT_FW_ERR, + [SNIC_STAT_ITMF_REJECT] = SNIC_STAT_ITMF_REJECT, + [SNIC_STAT_ITMF_FAIL] = SNIC_STAT_ITMF_FAIL, + [SNIC_STAT_ITMF_INCORRECT_LUN] = SNIC_STAT_ITMF_INCORRECT_LUN, + [SNIC_STAT_CMND_REJECT] = SNIC_STAT_CMND_REJECT, + [SNIC_STAT_DEV_OFFLINE] = SNIC_STAT_DEV_OFFLINE, + [SNIC_STAT_NO_BOOTLUN] = SNIC_STAT_NO_BOOTLUN, + [SNIC_STAT_SCSI_ERR]= SNIC_STAT_SCSI_ERR, + [SNIC_STAT_NOT_READY] = SNIC_STAT_NOT_READY, + [SNIC_STAT_FATAL_ERROR] = SNIC_STAT_FATAL_ERROR, +}; + +static void snic_scsi_cleanup(struct snic *, int); + +const char * +snic_state_to_str(unsigned int state) +{ + if (state = ARRAY_SIZE(snic_state_str) || !snic_state_str[state]) + return Unknown; + + return snic_state_str[state]; +} + +static const char * +snic_io_status_to_str(unsigned int state) +{ + if ((state = ARRAY_SIZE(snic_io_status_str)) || + (!snic_io_status_str[state])) + return Unknown; + + return snic_io_status_str[state]; +} + +static const char * +snic_ioreq_state_to_str(unsigned int state) +{ + if (state = ARRAY_SIZE(snic_req_state_str) || + !snic_req_state_str[state]) + return Unknown; + + return snic_req_state_str[state]; +} + +static inline spinlock_t * +snic_io_lock_hash(struct snic *snic, struct scsi_cmnd *sc) +{ + u32 hash = snic_cmd_tag(sc) (SNIC_IO_LOCKS - 1); + + return
[PATCH v4 5/9] snic:add SCSI handling, AEN, and fwreset handling
snic_scsi.c contains scsi handling, includes queuing io, abort, lun reset, and host reset. Also it handles asynchronous event notifications from FW. Signed-off-by: Narsimhulu Musini nmus...@cisco.com Signed-off-by: Sesidhar Baddela sebad...@cisco.com --- * v2 - Changed queuecommand to lock-free version. - Converted custom error codes to standard error codes. drivers/scsi/snic/snic_scsi.c | 2638 + 1 file changed, 2638 insertions(+) create mode 100644 drivers/scsi/snic/snic_scsi.c diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c new file mode 100644 index 000..5d877f0 --- /dev/null +++ b/drivers/scsi/snic/snic_scsi.c @@ -0,0 +1,2638 @@ +/* + * Copyright 2014 Cisco Systems, Inc. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * 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/mempool.h +#include linux/errno.h +#include linux/init.h +#include linux/workqueue.h +#include linux/pci.h +#include linux/spinlock.h +#include linux/delay.h +#include linux/gfp.h +#include scsi/scsi.h +#include scsi/scsi_host.h +#include scsi/scsi_device.h +#include scsi/scsi_cmnd.h +#include scsi/scsi_tcq.h +#include scsi/scsi_dbg.h + +#include snic_io.h +#include snic.h + +#define snic_cmd_tag(sc) (((struct scsi_cmnd *) sc)-request-tag) + +const char *snic_state_str[] = { + [SNIC_INIT] = SNIC_INIT, + [SNIC_ERROR]= SNIC_ERROR, + [SNIC_ONLINE] = SNIC_ONLINE, + [SNIC_OFFLINE] = SNIC_OFFLINE, + [SNIC_FWRESET] = SNIC_FWRESET, +}; + +static const char * const snic_req_state_str[] = { + [SNIC_IOREQ_NOT_INITED] = SNIC_IOREQ_NOT_INITED, + [SNIC_IOREQ_PENDING]= SNIC_IOREQ_PENDING, + [SNIC_IOREQ_ABTS_PENDING] = SNIC_IOREQ_ABTS_PENDING, + [SNIC_IOREQ_ABTS_COMPLETE] = SNIC_IOREQ_ABTS_COMPELTE, + [SNIC_IOREQ_LR_PENDING] = SNIC_IOREQ_LR_PENDING, + [SNIC_IOREQ_LR_COMPLETE] = SNIC_IOREQ_LR_COMPELTE, + [SNIC_IOREQ_COMPLETE] = SNIC_IOREQ_CMD_COMPELTE, +}; + +/* snic cmd status strings */ +static const char * const snic_io_status_str[] = { + [SNIC_STAT_IO_SUCCESS] = SNIC_STAT_IO_SUCCESS, /* 0x0 */ + [SNIC_STAT_INVALID_HDR] = SNIC_STAT_INVALID_HDR, + [SNIC_STAT_OUT_OF_RES] = SNIC_STAT_OUT_OF_RES, + [SNIC_STAT_INVALID_PARM] = SNIC_STAT_INVALID_PARM, + [SNIC_STAT_REQ_NOT_SUP] = SNIC_STAT_REQ_NOT_SUP, + [SNIC_STAT_IO_NOT_FOUND] = SNIC_STAT_IO_NOT_FOUND, + [SNIC_STAT_ABORTED] = SNIC_STAT_ABORTED, + [SNIC_STAT_TIMEOUT] = SNIC_STAT_TIMEOUT, + [SNIC_STAT_SGL_INVALID] = SNIC_STAT_SGL_INVALID, + [SNIC_STAT_DATA_CNT_MISMATCH] = SNIC_STAT_DATA_CNT_MISMATCH, + [SNIC_STAT_FW_ERR] = SNIC_STAT_FW_ERR, + [SNIC_STAT_ITMF_REJECT] = SNIC_STAT_ITMF_REJECT, + [SNIC_STAT_ITMF_FAIL] = SNIC_STAT_ITMF_FAIL, + [SNIC_STAT_ITMF_INCORRECT_LUN] = SNIC_STAT_ITMF_INCORRECT_LUN, + [SNIC_STAT_CMND_REJECT] = SNIC_STAT_CMND_REJECT, + [SNIC_STAT_DEV_OFFLINE] = SNIC_STAT_DEV_OFFLINE, + [SNIC_STAT_NO_BOOTLUN] = SNIC_STAT_NO_BOOTLUN, + [SNIC_STAT_SCSI_ERR]= SNIC_STAT_SCSI_ERR, + [SNIC_STAT_NOT_READY] = SNIC_STAT_NOT_READY, + [SNIC_STAT_FATAL_ERROR] = SNIC_STAT_FATAL_ERROR, +}; + +static void snic_scsi_cleanup(struct snic *, int); + +const char * +snic_state_to_str(unsigned int state) +{ + if (state = ARRAY_SIZE(snic_state_str) || !snic_state_str[state]) + return Unknown; + + return snic_state_str[state]; +} + +static const char * +snic_io_status_to_str(unsigned int state) +{ + if ((state = ARRAY_SIZE(snic_io_status_str)) || +(!snic_io_status_str[state])) + return Unknown; + + return snic_io_status_str[state]; +} + +static const char * +snic_ioreq_state_to_str(unsigned int state) +{ + if (state = ARRAY_SIZE(snic_req_state_str) || + !snic_req_state_str[state]) + return Unknown; + + return snic_req_state_str[state]; +} + +static inline spinlock_t * +snic_io_lock_hash(struct snic *snic, struct scsi_cmnd *sc) +{ + u32 hash = snic_cmd_tag(sc) (SNIC_IO_LOCKS - 1); + + return snic-io_req_lock[hash]; +} + +static inline spinlock_t * +snic_io_lock_tag(struct snic *snic, int tag) +{ + return snic-io_req_lock[tag (SNIC_IO_LOCKS