Re: [PATCH 1/1] qedi: Add support for offload iSCSI Boot

2017-06-27 Thread Javali, Nilesh


On 26/06/17, 10:29 PM, "Martin K. Petersen" 
wrote:

>
>Nilesh,
>
>> This patch adds support for offload iSCSI boot (Boot from SAN
>> over iSCSI offload).
>>
>> The dependent qed patches for this support are,
>> - qed: Support NVM-image reading API
>> - qed: Share additional information with qedf
>
>You had tagged this for 4.12/scsi-fixes but the above patches are not
>present in 4.12. So I presume this would be a candidate for a second
>stage 4.13 merge?
Yes.

>
>Patch looks OK to me, but please resubmit with a slightly more verbose
>description of the changes and how they work.
Done. Resubmitted the patch.

Thanks,
Nilesh



Re: [PATCH 1/1] qedi: Add support for offload iSCSI Boot

2017-06-26 Thread Martin K. Petersen

Nilesh,

> This patch adds support for offload iSCSI boot (Boot from SAN
> over iSCSI offload).
>
> The dependent qed patches for this support are,
> - qed: Support NVM-image reading API
> - qed: Share additional information with qedf

You had tagged this for 4.12/scsi-fixes but the above patches are not
present in 4.12. So I presume this would be a candidate for a second
stage 4.13 merge?

Patch looks OK to me, but please resubmit with a slightly more verbose
description of the changes and how they work.

Thanks!

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCH 1/1] qedi: Add support for offload iSCSI Boot

2017-06-19 Thread Nilesh Javali
This patch adds support for offload iSCSI boot (Boot from SAN
over iSCSI offload).

The dependent qed patches for this support are,
- qed: Support NVM-image reading API
- qed: Share additional information with qedf

Signed-off-by: Arun Easi 
Signed-off-by: Andrew Vasquez 
Signed-off-by: Manish Rangankar 
Signed-off-by: Nilesh Javali 
---
 drivers/scsi/qedi/qedi.h   |  17 ++
 drivers/scsi/qedi/qedi_main.c  | 419 +
 drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | 210 +
 3 files changed, 646 insertions(+)
 create mode 100644 drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h

diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h
index 32632c9..91d2f51 100644
--- a/drivers/scsi/qedi/qedi.h
+++ b/drivers/scsi/qedi/qedi.h
@@ -23,11 +23,17 @@
 #include 
 #include 
 #include "qedi_version.h"
+#include "qedi_nvm_iscsi_cfg.h"
 
 #define QEDI_MODULE_NAME   "qedi"
 
 struct qedi_endpoint;
 
+#ifndef GET_FIELD2
+#define GET_FIELD2(value, name) \
+   (((value) & (name ## _MASK)) >> (name ## _OFFSET))
+#endif
+
 /*
  * PCI function probe defines
  */
@@ -66,6 +72,11 @@
 #define QEDI_HW_DMA_BOUNDARY   0xfff
 #define QEDI_PATH_HANDLE   0xFE000UL
 
+enum qedi_nvm_tgts {
+   QEDI_NVM_TGT_PRI,
+   QEDI_NVM_TGT_SEC,
+};
+
 struct qedi_uio_ctrl {
/* meta data */
u32 uio_hsi_version;
@@ -283,6 +294,8 @@ struct qedi_ctx {
void *bdq_pbl_list;
dma_addr_t bdq_pbl_list_dma;
u8 bdq_pbl_list_num_entries;
+   struct nvm_iscsi_cfg *iscsi_cfg;
+   dma_addr_t nvm_buf_dma;
void __iomem *bdq_primary_prod;
void __iomem *bdq_secondary_prod;
u16 bdq_prod_idx;
@@ -337,6 +350,10 @@ struct qedi_ctx {
bool use_fast_sge;
 
atomic_t num_offloads;
+#define SYSFS_FLAG_FW_SEL_BOOT 2
+#define IPV6_LEN   41
+#define IPV4_LEN   17
+   struct iscsi_boot_kset *boot_kset;
 };
 
 struct qedi_work {
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c
index 09a2946..f07ac1c 100644
--- a/drivers/scsi/qedi/qedi_main.c
+++ b/drivers/scsi/qedi/qedi_main.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1143,6 +1144,30 @@ static int qedi_setup_int(struct qedi_ctx *qedi)
return rc;
 }
 
+static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi)
+{
+   if (qedi->iscsi_cfg)
+   dma_free_coherent(>pdev->dev,
+ sizeof(struct nvm_iscsi_cfg),
+ qedi->iscsi_cfg, qedi->nvm_buf_dma);
+}
+
+static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi)
+{
+   qedi->iscsi_cfg = dma_zalloc_coherent(>pdev->dev,
+sizeof(struct nvm_iscsi_cfg),
+>nvm_buf_dma, GFP_KERNEL);
+   if (!qedi->iscsi_cfg) {
+   QEDI_ERR(>dbg_ctx, "Could not allocate NVM BUF.\n");
+   return -ENOMEM;
+   }
+   QEDI_INFO(>dbg_ctx, QEDI_LOG_INFO,
+ "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg,
+ qedi->nvm_buf_dma);
+
+   return 0;
+}
+
 static void qedi_free_bdq(struct qedi_ctx *qedi)
 {
int i;
@@ -1183,6 +1208,7 @@ static void qedi_free_global_queues(struct qedi_ctx *qedi)
kfree(gl[i]);
}
qedi_free_bdq(qedi);
+   qedi_free_nvm_iscsi_cfg(qedi);
 }
 
 static int qedi_alloc_bdq(struct qedi_ctx *qedi)
@@ -1309,6 +1335,11 @@ static int qedi_alloc_global_queues(struct qedi_ctx 
*qedi)
if (rc)
goto mem_alloc_failure;
 
+   /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */
+   rc = qedi_alloc_nvm_iscsi_cfg(qedi);
+   if (rc)
+   goto mem_alloc_failure;
+
/* Allocate a CQ and an associated PBL for each MSI-X
 * vector.
 */
@@ -1673,6 +1704,387 @@ void qedi_reset_host_mtu(struct qedi_ctx *qedi, u16 mtu)
qedi_ops->ll2->start(qedi->cdev, );
 }
 
+/**
+ * qedi_get_nvram_block: - Scan through the iSCSI NVRAM block (while accounting
+ * for gaps) for the matching absolute-pf-id of the QEDI device.
+ */
+static struct nvm_iscsi_block *
+qedi_get_nvram_block(struct qedi_ctx *qedi)
+{
+   int i;
+   u8 pf;
+   u32 flags;
+   struct nvm_iscsi_block *block;
+
+   pf = qedi->dev_info.common.abs_pf_id;
+   block = >iscsi_cfg->block[0];
+   for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) {
+   flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >>
+   NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET;
+   if (flags & (NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY |
+   NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED) &&
+   (pf == (block->id & NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK)
+