git: fd95966af50b - main - ciss: hw.ciss.initator_id to set the initiator ID

From: Warner Losh <imp_at_FreeBSD.org>
Date: Mon, 14 Oct 2024 05:41:01 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=fd95966af50bab6229bc5e67fadc7ffd915f77f5

commit fd95966af50bab6229bc5e67fadc7ffd915f77f5
Author:     Peter Eriksson <pen@lysator.liu.se>
AuthorDate: 2024-10-14 04:01:33 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-10-14 05:37:46 +0000

    ciss: hw.ciss.initator_id to set the initiator ID
    
    Add hw.ciss.inititor_id to set the initiator to something other than the
    default.
    
    PR: 246279
    Reviewed by: imp
    Tested by: Marek Zarychta
    Differential Revision: https://reviews.freebsd.org/D25155
---
 sys/dev/ciss/ciss.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/sys/dev/ciss/ciss.c b/sys/dev/ciss/ciss.c
index a6071735c87b..d4786302d928 100644
--- a/sys/dev/ciss/ciss.c
+++ b/sys/dev/ciss/ciss.c
@@ -245,7 +245,15 @@ static struct cdevsw ciss_cdevsw = {
 SYSCTL_NODE(_hw, OID_AUTO, ciss, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, "CISS sysctl tunables");
 
 /*
- * This tunable can be used to force a specific value for transfer speed.
+ * This tunable can be used to force a specific initiator id
+ */
+static int ciss_initiator_id = CAM_TARGET_WILDCARD;
+SYSCTL_INT(_hw_ciss, OID_AUTO, initiator_id, CTLFLAG_RDTUN,
+	   &ciss_initiator_id, 0,
+	   "force a specific initiator id");
+
+/*
+ * This tunable can be used to force a specific initiator id
  */
 static int ciss_base_transfer_speed = 132 * 1024;
 SYSCTL_INT(_hw_ciss, OID_AUTO, base_transfer_speed, CTLFLAG_RDTUN,
@@ -3073,7 +3081,10 @@ ciss_cam_action(struct cam_sim *sim, union ccb *ccb)
 	cpi->hba_misc = 0;
 	cpi->max_target = MAX(sc->ciss_max_physical_target, sc->ciss_cfg->max_logical_supported);
 	cpi->max_lun = 0;		/* 'logical drive' channel only */
-	cpi->initiator_id = sc->ciss_cfg->max_logical_supported;
+	if (ciss_initiator_id != CAM_TARGET_WILDCARD)
+		cpi->initiator_id = ciss_initiator_id;
+	else
+		cpi->initiator_id = sc->ciss_cfg->max_logical_supported;
 	strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
 	strlcpy(cpi->hba_vid, "CISS", HBA_IDLEN);
 	strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);