Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: scsi_transport_fc: Introduce encryption group in fc_rport attribute

Introduce a new structure for reporting an encrypted session over an
fc_rport. The encryption group is added as an attribute in struct
fc_rport and reports information in fc_encryption_info. This structure
contains a status member variable, which stores a bit value indicating
an encrypted session.

Signed-off-by: Sarah Catania <sarah.catania@broadcom.com>
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://patch.msgid.link/20251211001659.138635-2-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Sarah Catania and committed by
Martin K. Petersen
bd2bc528 8f0b4cce

+63
+8
drivers/base/transport_class.c
··· 169 169 goto err_del; 170 170 } 171 171 172 + if (tcont->encryption) { 173 + error = sysfs_create_group(&classdev->kobj, tcont->encryption); 174 + if (error) 175 + goto err_del; 176 + } 177 + 172 178 return 0; 173 179 174 180 err_del: ··· 250 244 if (tclass->remove != anon_transport_dummy_function) { 251 245 if (tcont->statistics) 252 246 sysfs_remove_group(&classdev->kobj, tcont->statistics); 247 + if (tcont->encryption) 248 + sysfs_remove_group(&classdev->kobj, tcont->encryption); 253 249 attribute_container_class_device_del(classdev); 254 250 } 255 251
+42
drivers/scsi/scsi_transport_fc.c
··· 1328 1328 static FC_DEVICE_ATTR(rport, fast_io_fail_tmo, S_IRUGO | S_IWUSR, 1329 1329 show_fc_rport_fast_io_fail_tmo, store_fc_rport_fast_io_fail_tmo); 1330 1330 1331 + #define fc_rport_encryption(name) \ 1332 + static ssize_t fc_rport_encinfo_##name(struct device *cd, \ 1333 + struct device_attribute *attr, \ 1334 + char *buf) \ 1335 + { \ 1336 + struct fc_rport *rport = transport_class_to_rport(cd); \ 1337 + struct Scsi_Host *shost = rport_to_shost(rport); \ 1338 + struct fc_internal *i = to_fc_internal(shost->transportt); \ 1339 + struct fc_encryption_info *info; \ 1340 + ssize_t ret = -ENOENT; \ 1341 + u32 data; \ 1342 + \ 1343 + if (i->f->get_fc_rport_enc_info) { \ 1344 + info = (i->f->get_fc_rport_enc_info)(rport); \ 1345 + if (info) { \ 1346 + data = info->name; \ 1347 + if (!strcmp(#name, "status")) { \ 1348 + ret = scnprintf(buf, \ 1349 + FC_RPORT_ENCRYPTION_STATUS_MAX_LEN, \ 1350 + "%s\n", \ 1351 + data ? "Encrypted" : "Unencrypted"); \ 1352 + } \ 1353 + } \ 1354 + } \ 1355 + return ret; \ 1356 + } \ 1357 + static FC_DEVICE_ATTR(rport, encryption_##name, 0444, fc_rport_encinfo_##name, NULL) \ 1358 + 1359 + fc_rport_encryption(status); 1360 + 1361 + static struct attribute *fc_rport_encryption_attrs[] = { 1362 + &device_attr_rport_encryption_status.attr, 1363 + NULL 1364 + }; 1365 + 1366 + static struct attribute_group fc_rport_encryption_group = { 1367 + .name = "encryption", 1368 + .attrs = fc_rport_encryption_attrs, 1369 + }; 1370 + 1331 1371 #define fc_rport_fpin_statistic(name) \ 1332 1372 static ssize_t fc_rport_fpinstat_##name(struct device *cd, \ 1333 1373 struct device_attribute *attr, \ ··· 2673 2633 i->rport_attr_cont.ac.attrs = &i->rport_attrs[0]; 2674 2634 i->rport_attr_cont.ac.class = &fc_rport_class.class; 2675 2635 i->rport_attr_cont.ac.match = fc_rport_match; 2636 + if (ft->get_fc_rport_enc_info) 2637 + i->rport_attr_cont.encryption = &fc_rport_encryption_group; 2676 2638 i->rport_attr_cont.statistics = &fc_rport_statistics_group; 2677 2639 transport_container_register(&i->rport_attr_cont); 2678 2640
+1
include/linux/transport_class.h
··· 56 56 struct transport_container { 57 57 struct attribute_container ac; 58 58 const struct attribute_group *statistics; 59 + const struct attribute_group *encryption; 59 60 }; 60 61 61 62 #define attribute_container_to_transport_container(x) \
+12
include/scsi/scsi_transport_fc.h
··· 317 317 u64 cn_device_specific; 318 318 }; 319 319 320 + #define FC_RPORT_ENCRYPTION_STATUS_MAX_LEN 14 321 + /* 322 + * Encryption Information 323 + */ 324 + struct fc_encryption_info { 325 + /* Encryption Status */ 326 + u8 status; 327 + }; 328 + 320 329 /* Macro for use in defining Remote Port attributes */ 321 330 #define FC_RPORT_ATTR(_name,_mode,_show,_store) \ 322 331 struct device_attribute dev_attr_rport_##_name = \ ··· 373 364 u64 port_name; 374 365 u32 port_id; 375 366 u32 roles; 367 + struct fc_encryption_info enc_info; 376 368 enum fc_port_state port_state; /* Will only be ONLINE or UNKNOWN */ 377 369 u32 scsi_target_id; 378 370 u32 fast_io_fail_tmo; ··· 700 690 701 691 struct fc_host_statistics * (*get_fc_host_stats)(struct Scsi_Host *); 702 692 void (*reset_fc_host_stats)(struct Scsi_Host *); 693 + 694 + struct fc_encryption_info * (*get_fc_rport_enc_info)(struct fc_rport *); 703 695 704 696 int (*issue_fc_host_lip)(struct Scsi_Host *); 705 697