scsi: fnic: Decode firmware role configuration

Add FNIC_ROLE_CONFIG_MASK and use it to decode firmware role bits when
reading vNIC configuration and probing the PCI device.

Accept FCP and NVMe initiator roles, report FC target and FC-NVMe target
roles explicitly as unsupported, and keep truly undefined role settings on
the existing FC initiator default path.

Log the configured role flags and expose role names for trace output.

Reviewed-by: Sesidhar Baddela <sebaddel@cisco.com>
Reviewed-by: Arulprabhu Ponnusamy <arulponn@cisco.com>
Reviewed-by: Gian Carlo Boffa <gcboffa@cisco.com>
Reviewed-by: Arun Easi <aeasi@cisco.com>
Reviewed-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Karan Tilak Kumar <kartilak@cisco.com>
Co-developed-by: Hannes Reinecke <hare@kernel.org>
Link: https://patch.msgid.link/20260724174811.5118-4-kartilak@cisco.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Karan Tilak Kumar
2026-07-24 10:48:01 -07:00
committed by Martin K. Petersen
parent 6128fec941
commit 12bd1b2912
4 changed files with 51 additions and 5 deletions

View File

@@ -43,6 +43,7 @@
#define FNIC_DFLT_QUEUE_DEPTH 256
#define FNIC_STATS_RATE_LIMIT 4 /* limit rate at which stats are pulled up */
#define LUN0_DELAY_TIME 9
#define FNIC_ROLE_CONFIG_MASK (0xFF0)
/*
* Tag bits used for special requests.

View File

@@ -844,7 +844,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_fnic_get_config;
}
switch (fnic->config.flags & 0xff0) {
switch (fnic->config.flags & FNIC_ROLE_CONFIG_MASK) {
case VFCF_FC_INITIATOR:
{
host =
@@ -863,8 +863,27 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
fnic->fnic_num);
}
break;
case VFCF_FC_TARGET:
dev_info(&fnic->pdev->dev,
"fnic: %d is scsi target\n",
fnic->fnic_num);
err = -EOPNOTSUPP;
goto err_out_fnic_role;
case VFCF_FC_NVME_INITIATOR:
fnic->role = FNIC_ROLE_NVME_INITIATOR;
dev_info(&fnic->pdev->dev, "fnic: %d is NVME initiator\n",
fnic->fnic_num);
break;
case VFCF_FC_NVME_TARGET:
dev_info(&fnic->pdev->dev,
"fnic: %d is NVME target\n",
fnic->fnic_num);
err = -EOPNOTSUPP;
goto err_out_fnic_role;
default:
dev_info(&fnic->pdev->dev, "fnic: %d has no role defined\n", fnic->fnic_num);
dev_info(&fnic->pdev->dev,
"fnic: %d has no role defined (0x%x)\n",
fnic->fnic_num, fnic->config.flags & FNIC_ROLE_CONFIG_MASK);
err = -EINVAL;
goto err_out_fnic_role;
}

View File

@@ -22,6 +22,7 @@
int fnic_get_vnic_config(struct fnic *fnic)
{
struct vnic_fc_config *c = &fnic->config;
u32 role;
int err;
#define GET_CONFIG(m) \
@@ -58,9 +59,31 @@ int fnic_get_vnic_config(struct fnic *fnic)
GET_CONFIG(intr_mode);
GET_CONFIG(wq_copy_count);
if ((c->flags & (VFCF_FC_INITIATOR)) == 0) {
dev_info(&fnic->pdev->dev, "vNIC role not defined (def role: FC Init)\n");
role = c->flags & FNIC_ROLE_CONFIG_MASK;
switch (role) {
case 0:
dev_info(&fnic->pdev->dev,
"vNIC role not defined (def role: FC Init)\n");
c->flags |= VFCF_FC_INITIATOR;
break;
case VFCF_FC_INITIATOR:
case VFCF_FC_NVME_INITIATOR:
break;
case VFCF_FC_TARGET:
dev_info(&fnic->pdev->dev,
"vNIC role is FC Target (unsupported)\n");
break;
case VFCF_FC_NVME_TARGET:
dev_info(&fnic->pdev->dev,
"vNIC role is FC-NVMe Target (unsupported)\n");
break;
default:
dev_info(&fnic->pdev->dev,
"vNIC role not supported (0x%x), defaulting to FC Init\n",
role);
c->flags &= ~FNIC_ROLE_CONFIG_MASK;
c->flags |= VFCF_FC_INITIATOR;
break;
}
c->wq_enet_desc_count =
@@ -163,6 +186,8 @@ int fnic_get_vnic_config(struct fnic *fnic)
c->port_down_io_retries, c->port_down_timeout);
dev_info(&fnic->pdev->dev, "fNIC wq_copy_count: %d\n", c->wq_copy_count);
dev_info(&fnic->pdev->dev, "fNIC intr mode: %d\n", c->intr_mode);
dev_info(&fnic->pdev->dev, "fNIC role flags: 0x%x\n",
(c->flags & FNIC_ROLE_CONFIG_MASK));
return 0;
}

View File

@@ -31,7 +31,8 @@ int fnic_fc_trace_cleared = 1;
static DEFINE_SPINLOCK(fnic_fc_trace_lock);
static const char * const fnic_role_str[] = {
[FNIC_ROLE_FCP_INITIATOR] = "FCP_Initiator",
[FNIC_ROLE_FCP_INITIATOR] = "FCP_Initiator",
[FNIC_ROLE_NVME_INITIATOR] = "NVMeF_Initiator",
};
const char *fnic_role_to_str(unsigned int role)