diff options
author | James Smart <James.Smart@Emulex.Com> | 2008-08-24 21:49:00 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-10-13 09:28:53 -0400 |
commit | e59058c44025d71c9b7f260076a932935d3bba95 (patch) | |
tree | 36cd4b31ac3b130849c5ad4d2c0cef035a7389dd /drivers/scsi/lpfc/lpfc_attr.c | |
parent | 4a27446f3e39b06c28d1c8e31d33a5340826ed5c (diff) |
[SCSI] lpfc 8.2.8 : Add kernel-doc function headers
Signed-off-by: James Smart <james.smart@emulex.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r-- | drivers/scsi/lpfc/lpfc_attr.c | 919 |
1 files changed, 914 insertions, 5 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index 37bfa0bd1dae..2926a2a7ee70 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c | |||
@@ -49,6 +49,21 @@ | |||
49 | #define LPFC_LINK_SPEED_BITMAP 0x00000117 | 49 | #define LPFC_LINK_SPEED_BITMAP 0x00000117 |
50 | #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8" | 50 | #define LPFC_LINK_SPEED_STRING "0, 1, 2, 4, 8" |
51 | 51 | ||
52 | /** | ||
53 | * lpfc_jedec_to_ascii: Hex to ascii convertor according to JEDEC rules. | ||
54 | * @incr: integer to convert. | ||
55 | * @hdw: ascii string holding converted integer plus a string terminator. | ||
56 | * | ||
57 | * Description: | ||
58 | * JEDEC Joint Electron Device Engineering Council. | ||
59 | * Convert a 32 bit integer composed of 8 nibbles into an 8 byte ascii | ||
60 | * character string. The string is then terminated with a NULL in byte 9. | ||
61 | * Hex 0-9 becomes ascii '0' to '9'. | ||
62 | * Hex a-f becomes ascii '=' to 'B' capital B. | ||
63 | * | ||
64 | * Notes: | ||
65 | * Coded for 32 bit integers only. | ||
66 | **/ | ||
52 | static void | 67 | static void |
53 | lpfc_jedec_to_ascii(int incr, char hdw[]) | 68 | lpfc_jedec_to_ascii(int incr, char hdw[]) |
54 | { | 69 | { |
@@ -65,6 +80,14 @@ lpfc_jedec_to_ascii(int incr, char hdw[]) | |||
65 | return; | 80 | return; |
66 | } | 81 | } |
67 | 82 | ||
83 | /** | ||
84 | * lpfc_drvr_version_show: Return the Emulex driver string with version number. | ||
85 | * @dev: class unused variable. | ||
86 | * @attr: device attribute, not used. | ||
87 | * @buf: on return contains the module description text. | ||
88 | * | ||
89 | * Returns: size of formatted string. | ||
90 | **/ | ||
68 | static ssize_t | 91 | static ssize_t |
69 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, | 92 | lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, |
70 | char *buf) | 93 | char *buf) |
@@ -72,6 +95,14 @@ lpfc_drvr_version_show(struct device *dev, struct device_attribute *attr, | |||
72 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); | 95 | return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n"); |
73 | } | 96 | } |
74 | 97 | ||
98 | /** | ||
99 | * lpfc_info_show: Return some pci info about the host in ascii. | ||
100 | * @dev: class converted to a Scsi_host structure. | ||
101 | * @attr: device attribute, not used. | ||
102 | * @buf: on return contains the formatted text from lpfc_info(). | ||
103 | * | ||
104 | * Returns: size of formatted string. | ||
105 | **/ | ||
75 | static ssize_t | 106 | static ssize_t |
76 | lpfc_info_show(struct device *dev, struct device_attribute *attr, | 107 | lpfc_info_show(struct device *dev, struct device_attribute *attr, |
77 | char *buf) | 108 | char *buf) |
@@ -81,6 +112,14 @@ lpfc_info_show(struct device *dev, struct device_attribute *attr, | |||
81 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); | 112 | return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host)); |
82 | } | 113 | } |
83 | 114 | ||
115 | /** | ||
116 | * lpfc_serialnum_show: Return the hba serial number in ascii. | ||
117 | * @dev: class converted to a Scsi_host structure. | ||
118 | * @attr: device attribute, not used. | ||
119 | * @buf: on return contains the formatted text serial number. | ||
120 | * | ||
121 | * Returns: size of formatted string. | ||
122 | **/ | ||
84 | static ssize_t | 123 | static ssize_t |
85 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, | 124 | lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, |
86 | char *buf) | 125 | char *buf) |
@@ -92,6 +131,18 @@ lpfc_serialnum_show(struct device *dev, struct device_attribute *attr, | |||
92 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); | 131 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber); |
93 | } | 132 | } |
94 | 133 | ||
134 | /** | ||
135 | * lpfc_temp_sensor_show: Return the temperature sensor level. | ||
136 | * @dev: class converted to a Scsi_host structure. | ||
137 | * @attr: device attribute, not used. | ||
138 | * @buf: on return contains the formatted support level. | ||
139 | * | ||
140 | * Description: | ||
141 | * Returns a number indicating the temperature sensor level currently | ||
142 | * supported, zero or one in ascii. | ||
143 | * | ||
144 | * Returns: size of formatted string. | ||
145 | **/ | ||
95 | static ssize_t | 146 | static ssize_t |
96 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, | 147 | lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, |
97 | char *buf) | 148 | char *buf) |
@@ -102,6 +153,14 @@ lpfc_temp_sensor_show(struct device *dev, struct device_attribute *attr, | |||
102 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); | 153 | return snprintf(buf, PAGE_SIZE, "%d\n",phba->temp_sensor_support); |
103 | } | 154 | } |
104 | 155 | ||
156 | /** | ||
157 | * lpfc_modeldesc_show: Return the model description of the hba. | ||
158 | * @dev: class converted to a Scsi_host structure. | ||
159 | * @attr: device attribute, not used. | ||
160 | * @buf: on return contains the scsi vpd model description. | ||
161 | * | ||
162 | * Returns: size of formatted string. | ||
163 | **/ | ||
105 | static ssize_t | 164 | static ssize_t |
106 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, | 165 | lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, |
107 | char *buf) | 166 | char *buf) |
@@ -113,6 +172,14 @@ lpfc_modeldesc_show(struct device *dev, struct device_attribute *attr, | |||
113 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); | 172 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc); |
114 | } | 173 | } |
115 | 174 | ||
175 | /** | ||
176 | * lpfc_modelname_show: Return the model name of the hba. | ||
177 | * @dev: class converted to a Scsi_host structure. | ||
178 | * @attr: device attribute, not used. | ||
179 | * @buf: on return contains the scsi vpd model name. | ||
180 | * | ||
181 | * Returns: size of formatted string. | ||
182 | **/ | ||
116 | static ssize_t | 183 | static ssize_t |
117 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, | 184 | lpfc_modelname_show(struct device *dev, struct device_attribute *attr, |
118 | char *buf) | 185 | char *buf) |
@@ -124,6 +191,14 @@ lpfc_modelname_show(struct device *dev, struct device_attribute *attr, | |||
124 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); | 191 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName); |
125 | } | 192 | } |
126 | 193 | ||
194 | /** | ||
195 | * lpfc_programtype_show: Return the program type of the hba. | ||
196 | * @dev: class converted to a Scsi_host structure. | ||
197 | * @attr: device attribute, not used. | ||
198 | * @buf: on return contains the scsi vpd program type. | ||
199 | * | ||
200 | * Returns: size of formatted string. | ||
201 | **/ | ||
127 | static ssize_t | 202 | static ssize_t |
128 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, | 203 | lpfc_programtype_show(struct device *dev, struct device_attribute *attr, |
129 | char *buf) | 204 | char *buf) |
@@ -135,6 +210,14 @@ lpfc_programtype_show(struct device *dev, struct device_attribute *attr, | |||
135 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); | 210 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType); |
136 | } | 211 | } |
137 | 212 | ||
213 | /** | ||
214 | * lpfc_vportnum_show: Return the port number in ascii of the hba. | ||
215 | * @dev: class converted to a Scsi_host structure. | ||
216 | * @attr: device attribute, not used. | ||
217 | * @buf: on return contains scsi vpd program type. | ||
218 | * | ||
219 | * Returns: size of formatted string. | ||
220 | **/ | ||
138 | static ssize_t | 221 | static ssize_t |
139 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, | 222 | lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, |
140 | char *buf) | 223 | char *buf) |
@@ -146,6 +229,14 @@ lpfc_vportnum_show(struct device *dev, struct device_attribute *attr, | |||
146 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); | 229 | return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port); |
147 | } | 230 | } |
148 | 231 | ||
232 | /** | ||
233 | * lpfc_fwrev_show: Return the firmware rev running in the hba. | ||
234 | * @dev: class converted to a Scsi_host structure. | ||
235 | * @attr: device attribute, not used. | ||
236 | * @buf: on return contains the scsi vpd program type. | ||
237 | * | ||
238 | * Returns: size of formatted string. | ||
239 | **/ | ||
149 | static ssize_t | 240 | static ssize_t |
150 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, | 241 | lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, |
151 | char *buf) | 242 | char *buf) |
@@ -159,6 +250,14 @@ lpfc_fwrev_show(struct device *dev, struct device_attribute *attr, | |||
159 | return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev); | 250 | return snprintf(buf, PAGE_SIZE, "%s, sli-%d\n", fwrev, phba->sli_rev); |
160 | } | 251 | } |
161 | 252 | ||
253 | /** | ||
254 | * lpfc_hdw_show: Return the jedec information about the hba. | ||
255 | * @dev: class converted to a Scsi_host structure. | ||
256 | * @attr: device attribute, not used. | ||
257 | * @buf: on return contains the scsi vpd program type. | ||
258 | * | ||
259 | * Returns: size of formatted string. | ||
260 | **/ | ||
162 | static ssize_t | 261 | static ssize_t |
163 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) | 262 | lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) |
164 | { | 263 | { |
@@ -171,6 +270,15 @@ lpfc_hdw_show(struct device *dev, struct device_attribute *attr, char *buf) | |||
171 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); | 270 | lpfc_jedec_to_ascii(vp->rev.biuRev, hdw); |
172 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); | 271 | return snprintf(buf, PAGE_SIZE, "%s\n", hdw); |
173 | } | 272 | } |
273 | |||
274 | /** | ||
275 | * lpfc_option_rom_version_show: Return the adapter ROM FCode version. | ||
276 | * @dev: class converted to a Scsi_host structure. | ||
277 | * @attr: device attribute, not used. | ||
278 | * @buf: on return contains the ROM and FCode ascii strings. | ||
279 | * | ||
280 | * Returns: size of formatted string. | ||
281 | **/ | ||
174 | static ssize_t | 282 | static ssize_t |
175 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, | 283 | lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, |
176 | char *buf) | 284 | char *buf) |
@@ -181,6 +289,18 @@ lpfc_option_rom_version_show(struct device *dev, struct device_attribute *attr, | |||
181 | 289 | ||
182 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); | 290 | return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion); |
183 | } | 291 | } |
292 | |||
293 | /** | ||
294 | * lpfc_state_show: Return the link state of the port. | ||
295 | * @dev: class converted to a Scsi_host structure. | ||
296 | * @attr: device attribute, not used. | ||
297 | * @buf: on return contains text describing the state of the link. | ||
298 | * | ||
299 | * Notes: | ||
300 | * The switch statement has no default so zero will be returned. | ||
301 | * | ||
302 | * Returns: size of formatted string. | ||
303 | **/ | ||
184 | static ssize_t | 304 | static ssize_t |
185 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, | 305 | lpfc_link_state_show(struct device *dev, struct device_attribute *attr, |
186 | char *buf) | 306 | char *buf) |
@@ -253,6 +373,18 @@ lpfc_link_state_show(struct device *dev, struct device_attribute *attr, | |||
253 | return len; | 373 | return len; |
254 | } | 374 | } |
255 | 375 | ||
376 | /** | ||
377 | * lpfc_num_discovered_ports_show: Return sum of mapped and unmapped vports. | ||
378 | * @dev: class device that is converted into a Scsi_host. | ||
379 | * @attr: device attribute, not used. | ||
380 | * @buf: on return contains the sum of fc mapped and unmapped. | ||
381 | * | ||
382 | * Description: | ||
383 | * Returns the ascii text number of the sum of the fc mapped and unmapped | ||
384 | * vport counts. | ||
385 | * | ||
386 | * Returns: size of formatted string. | ||
387 | **/ | ||
256 | static ssize_t | 388 | static ssize_t |
257 | lpfc_num_discovered_ports_show(struct device *dev, | 389 | lpfc_num_discovered_ports_show(struct device *dev, |
258 | struct device_attribute *attr, char *buf) | 390 | struct device_attribute *attr, char *buf) |
@@ -264,7 +396,20 @@ lpfc_num_discovered_ports_show(struct device *dev, | |||
264 | vport->fc_map_cnt + vport->fc_unmap_cnt); | 396 | vport->fc_map_cnt + vport->fc_unmap_cnt); |
265 | } | 397 | } |
266 | 398 | ||
267 | 399 | /** | |
400 | * lpfc_issue_lip: Misnomer, name carried over from long ago. | ||
401 | * @shost: Scsi_Host pointer. | ||
402 | * | ||
403 | * Description: | ||
404 | * Bring the link down gracefully then re-init the link. The firmware will | ||
405 | * re-init the fiber channel interface as required. Does not issue a LIP. | ||
406 | * | ||
407 | * Returns: | ||
408 | * -EPERM port offline or management commands are being blocked | ||
409 | * -ENOMEM cannot allocate memory for the mailbox command | ||
410 | * -EIO error sending the mailbox command | ||
411 | * zero for success | ||
412 | **/ | ||
268 | static int | 413 | static int |
269 | lpfc_issue_lip(struct Scsi_Host *shost) | 414 | lpfc_issue_lip(struct Scsi_Host *shost) |
270 | { | 415 | { |
@@ -306,6 +451,21 @@ lpfc_issue_lip(struct Scsi_Host *shost) | |||
306 | return 0; | 451 | return 0; |
307 | } | 452 | } |
308 | 453 | ||
454 | /** | ||
455 | * lpfc_do_offline: Issues a mailbox command to bring the link down. | ||
456 | * @phba: lpfc_hba pointer. | ||
457 | * @type: LPFC_EVT_OFFLINE, LPFC_EVT_WARM_START, LPFC_EVT_KILL. | ||
458 | * | ||
459 | * Notes: | ||
460 | * Assumes any error from lpfc_do_offline() will be negative. | ||
461 | * Can wait up to 5 seconds for the port ring buffers count | ||
462 | * to reach zero, prints a warning if it is not zero and continues. | ||
463 | * lpfc_workq_post_event() returns a non-zero return coce if call fails. | ||
464 | * | ||
465 | * Returns: | ||
466 | * -EIO error posting the event | ||
467 | * zero for success | ||
468 | **/ | ||
309 | static int | 469 | static int |
310 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) | 470 | lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) |
311 | { | 471 | { |
@@ -353,6 +513,22 @@ lpfc_do_offline(struct lpfc_hba *phba, uint32_t type) | |||
353 | return 0; | 513 | return 0; |
354 | } | 514 | } |
355 | 515 | ||
516 | /** | ||
517 | * lpfc_selective_reset: Offline then onlines the port. | ||
518 | * @phba: lpfc_hba pointer. | ||
519 | * | ||
520 | * Description: | ||
521 | * If the port is configured to allow a reset then the hba is brought | ||
522 | * offline then online. | ||
523 | * | ||
524 | * Notes: | ||
525 | * Assumes any error from lpfc_do_offline() will be negative. | ||
526 | * | ||
527 | * Returns: | ||
528 | * lpfc_do_offline() return code if not zero | ||
529 | * -EIO reset not configured or error posting the event | ||
530 | * zero for success | ||
531 | **/ | ||
356 | static int | 532 | static int |
357 | lpfc_selective_reset(struct lpfc_hba *phba) | 533 | lpfc_selective_reset(struct lpfc_hba *phba) |
358 | { | 534 | { |
@@ -378,6 +554,27 @@ lpfc_selective_reset(struct lpfc_hba *phba) | |||
378 | return 0; | 554 | return 0; |
379 | } | 555 | } |
380 | 556 | ||
557 | /** | ||
558 | * lpfc_issue_reset: Selectively resets an adapter. | ||
559 | * @dev: class device that is converted into a Scsi_host. | ||
560 | * @attr: device attribute, not used. | ||
561 | * @buf: containing the string "selective". | ||
562 | * @count: unused variable. | ||
563 | * | ||
564 | * Description: | ||
565 | * If the buf contains the string "selective" then lpfc_selective_reset() | ||
566 | * is called to perform the reset. | ||
567 | * | ||
568 | * Notes: | ||
569 | * Assumes any error from lpfc_selective_reset() will be negative. | ||
570 | * If lpfc_selective_reset() returns zero then the length of the buffer | ||
571 | * is returned which indicates succcess | ||
572 | * | ||
573 | * Returns: | ||
574 | * -EINVAL if the buffer does not contain the string "selective" | ||
575 | * length of buf if lpfc-selective_reset() if the call succeeds | ||
576 | * return value of lpfc_selective_reset() if the call fails | ||
577 | **/ | ||
381 | static ssize_t | 578 | static ssize_t |
382 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, | 579 | lpfc_issue_reset(struct device *dev, struct device_attribute *attr, |
383 | const char *buf, size_t count) | 580 | const char *buf, size_t count) |
@@ -397,6 +594,14 @@ lpfc_issue_reset(struct device *dev, struct device_attribute *attr, | |||
397 | return status; | 594 | return status; |
398 | } | 595 | } |
399 | 596 | ||
597 | /** | ||
598 | * lpfc_nport_evt_cnt_show: Return the number of nport events. | ||
599 | * @dev: class device that is converted into a Scsi_host. | ||
600 | * @attr: device attribute, not used. | ||
601 | * @buf: on return contains the ascii number of nport events. | ||
602 | * | ||
603 | * Returns: size of formatted string. | ||
604 | **/ | ||
400 | static ssize_t | 605 | static ssize_t |
401 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, | 606 | lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, |
402 | char *buf) | 607 | char *buf) |
@@ -408,6 +613,14 @@ lpfc_nport_evt_cnt_show(struct device *dev, struct device_attribute *attr, | |||
408 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); | 613 | return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt); |
409 | } | 614 | } |
410 | 615 | ||
616 | /** | ||
617 | * lpfc_board_mode_show: Return the state of the board. | ||
618 | * @dev: class device that is converted into a Scsi_host. | ||
619 | * @attr: device attribute, not used. | ||
620 | * @buf: on return contains the state of the adapter. | ||
621 | * | ||
622 | * Returns: size of formatted string. | ||
623 | **/ | ||
411 | static ssize_t | 624 | static ssize_t |
412 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, | 625 | lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, |
413 | char *buf) | 626 | char *buf) |
@@ -429,6 +642,19 @@ lpfc_board_mode_show(struct device *dev, struct device_attribute *attr, | |||
429 | return snprintf(buf, PAGE_SIZE, "%s\n", state); | 642 | return snprintf(buf, PAGE_SIZE, "%s\n", state); |
430 | } | 643 | } |
431 | 644 | ||
645 | /** | ||
646 | * lpfc_board_mode_store: Puts the hba in online, offline, warm or error state. | ||
647 | * @dev: class device that is converted into a Scsi_host. | ||
648 | * @attr: device attribute, not used. | ||
649 | * @buf: containing one of the strings "online", "offline", "warm" or "error". | ||
650 | * @count: unused variable. | ||
651 | * | ||
652 | * Returns: | ||
653 | * -EACCES if enable hba reset not enabled | ||
654 | * -EINVAL if the buffer does not contain a valid string (see above) | ||
655 | * -EIO if lpfc_workq_post_event() or lpfc_do_offline() fails | ||
656 | * buf length greater than zero indicates success | ||
657 | **/ | ||
432 | static ssize_t | 658 | static ssize_t |
433 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, | 659 | lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, |
434 | const char *buf, size_t count) | 660 | const char *buf, size_t count) |
@@ -462,6 +688,24 @@ lpfc_board_mode_store(struct device *dev, struct device_attribute *attr, | |||
462 | return -EIO; | 688 | return -EIO; |
463 | } | 689 | } |
464 | 690 | ||
691 | /** | ||
692 | * lpfc_get_hba_info: Return various bits of informaton about the adapter. | ||
693 | * @phba: pointer to the adapter structure. | ||
694 | * @mxri max xri count. | ||
695 | * @axri available xri count. | ||
696 | * @mrpi max rpi count. | ||
697 | * @arpi available rpi count. | ||
698 | * @mvpi max vpi count. | ||
699 | * @avpi available vpi count. | ||
700 | * | ||
701 | * Description: | ||
702 | * If an integer pointer for an count is not null then the value for the | ||
703 | * count is returned. | ||
704 | * | ||
705 | * Returns: | ||
706 | * zero on error | ||
707 | * one for success | ||
708 | **/ | ||
465 | static int | 709 | static int |
466 | lpfc_get_hba_info(struct lpfc_hba *phba, | 710 | lpfc_get_hba_info(struct lpfc_hba *phba, |
467 | uint32_t *mxri, uint32_t *axri, | 711 | uint32_t *mxri, uint32_t *axri, |
@@ -524,6 +768,20 @@ lpfc_get_hba_info(struct lpfc_hba *phba, | |||
524 | return 1; | 768 | return 1; |
525 | } | 769 | } |
526 | 770 | ||
771 | /** | ||
772 | * lpfc_max_rpi_show: Return maximum rpi. | ||
773 | * @dev: class device that is converted into a Scsi_host. | ||
774 | * @attr: device attribute, not used. | ||
775 | * @buf: on return contains the maximum rpi count in decimal or "Unknown". | ||
776 | * | ||
777 | * Description: | ||
778 | * Calls lpfc_get_hba_info() asking for just the mrpi count. | ||
779 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | ||
780 | * to "Unknown" and the buffer length is returned, therefore the caller | ||
781 | * must check for "Unknown" in the buffer to detect a failure. | ||
782 | * | ||
783 | * Returns: size of formatted string. | ||
784 | **/ | ||
527 | static ssize_t | 785 | static ssize_t |
528 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, | 786 | lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, |
529 | char *buf) | 787 | char *buf) |
@@ -538,6 +796,20 @@ lpfc_max_rpi_show(struct device *dev, struct device_attribute *attr, | |||
538 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | 796 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
539 | } | 797 | } |
540 | 798 | ||
799 | /** | ||
800 | * lpfc_used_rpi_show: Return maximum rpi minus available rpi. | ||
801 | * @dev: class device that is converted into a Scsi_host. | ||
802 | * @attr: device attribute, not used. | ||
803 | * @buf: containing the used rpi count in decimal or "Unknown". | ||
804 | * | ||
805 | * Description: | ||
806 | * Calls lpfc_get_hba_info() asking for just the mrpi and arpi counts. | ||
807 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | ||
808 | * to "Unknown" and the buffer length is returned, therefore the caller | ||
809 | * must check for "Unknown" in the buffer to detect a failure. | ||
810 | * | ||
811 | * Returns: size of formatted string. | ||
812 | **/ | ||
541 | static ssize_t | 813 | static ssize_t |
542 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, | 814 | lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, |
543 | char *buf) | 815 | char *buf) |
@@ -552,6 +824,20 @@ lpfc_used_rpi_show(struct device *dev, struct device_attribute *attr, | |||
552 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | 824 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
553 | } | 825 | } |
554 | 826 | ||
827 | /** | ||
828 | * lpfc_max_xri_show: Return maximum xri. | ||
829 | * @dev: class device that is converted into a Scsi_host. | ||
830 | * @attr: device attribute, not used. | ||
831 | * @buf: on return contains the maximum xri count in decimal or "Unknown". | ||
832 | * | ||
833 | * Description: | ||
834 | * Calls lpfc_get_hba_info() asking for just the mrpi count. | ||
835 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | ||
836 | * to "Unknown" and the buffer length is returned, therefore the caller | ||
837 | * must check for "Unknown" in the buffer to detect a failure. | ||
838 | * | ||
839 | * Returns: size of formatted string. | ||
840 | **/ | ||
555 | static ssize_t | 841 | static ssize_t |
556 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, | 842 | lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, |
557 | char *buf) | 843 | char *buf) |
@@ -566,6 +852,20 @@ lpfc_max_xri_show(struct device *dev, struct device_attribute *attr, | |||
566 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | 852 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
567 | } | 853 | } |
568 | 854 | ||
855 | /** | ||
856 | * lpfc_used_xri_show: Return maximum xpi minus the available xpi. | ||
857 | * @dev: class device that is converted into a Scsi_host. | ||
858 | * @attr: device attribute, not used. | ||
859 | * @buf: on return contains the used xri count in decimal or "Unknown". | ||
860 | * | ||
861 | * Description: | ||
862 | * Calls lpfc_get_hba_info() asking for just the mxri and axri counts. | ||
863 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | ||
864 | * to "Unknown" and the buffer length is returned, therefore the caller | ||
865 | * must check for "Unknown" in the buffer to detect a failure. | ||
866 | * | ||
867 | * Returns: size of formatted string. | ||
868 | **/ | ||
569 | static ssize_t | 869 | static ssize_t |
570 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, | 870 | lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, |
571 | char *buf) | 871 | char *buf) |
@@ -580,6 +880,20 @@ lpfc_used_xri_show(struct device *dev, struct device_attribute *attr, | |||
580 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | 880 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
581 | } | 881 | } |
582 | 882 | ||
883 | /** | ||
884 | * lpfc_max_vpi_show: Return maximum vpi. | ||
885 | * @dev: class device that is converted into a Scsi_host. | ||
886 | * @attr: device attribute, not used. | ||
887 | * @buf: on return contains the maximum vpi count in decimal or "Unknown". | ||
888 | * | ||
889 | * Description: | ||
890 | * Calls lpfc_get_hba_info() asking for just the mvpi count. | ||
891 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | ||
892 | * to "Unknown" and the buffer length is returned, therefore the caller | ||
893 | * must check for "Unknown" in the buffer to detect a failure. | ||
894 | * | ||
895 | * Returns: size of formatted string. | ||
896 | **/ | ||
583 | static ssize_t | 897 | static ssize_t |
584 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, | 898 | lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, |
585 | char *buf) | 899 | char *buf) |
@@ -594,6 +908,20 @@ lpfc_max_vpi_show(struct device *dev, struct device_attribute *attr, | |||
594 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | 908 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
595 | } | 909 | } |
596 | 910 | ||
911 | /** | ||
912 | * lpfc_used_vpi_show: Return maximum vpi minus the available vpi. | ||
913 | * @dev: class device that is converted into a Scsi_host. | ||
914 | * @attr: device attribute, not used. | ||
915 | * @buf: on return contains the used vpi count in decimal or "Unknown". | ||
916 | * | ||
917 | * Description: | ||
918 | * Calls lpfc_get_hba_info() asking for just the mvpi and avpi counts. | ||
919 | * If lpfc_get_hba_info() returns zero (failure) the buffer text is set | ||
920 | * to "Unknown" and the buffer length is returned, therefore the caller | ||
921 | * must check for "Unknown" in the buffer to detect a failure. | ||
922 | * | ||
923 | * Returns: size of formatted string. | ||
924 | **/ | ||
597 | static ssize_t | 925 | static ssize_t |
598 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, | 926 | lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, |
599 | char *buf) | 927 | char *buf) |
@@ -608,6 +936,19 @@ lpfc_used_vpi_show(struct device *dev, struct device_attribute *attr, | |||
608 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); | 936 | return snprintf(buf, PAGE_SIZE, "Unknown\n"); |
609 | } | 937 | } |
610 | 938 | ||
939 | /** | ||
940 | * lpfc_npiv_info_show: Return text about NPIV support for the adapter. | ||
941 | * @dev: class device that is converted into a Scsi_host. | ||
942 | * @attr: device attribute, not used. | ||
943 | * @buf: text that must be interpreted to determine if npiv is supported. | ||
944 | * | ||
945 | * Description: | ||
946 | * Buffer will contain text indicating npiv is not suppoerted on the port, | ||
947 | * the port is an NPIV physical port, or it is an npiv virtual port with | ||
948 | * the id of the vport. | ||
949 | * | ||
950 | * Returns: size of formatted string. | ||
951 | **/ | ||
611 | static ssize_t | 952 | static ssize_t |
612 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, | 953 | lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, |
613 | char *buf) | 954 | char *buf) |
@@ -623,6 +964,17 @@ lpfc_npiv_info_show(struct device *dev, struct device_attribute *attr, | |||
623 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); | 964 | return snprintf(buf, PAGE_SIZE, "NPIV Virtual (VPI %d)\n", vport->vpi); |
624 | } | 965 | } |
625 | 966 | ||
967 | /** | ||
968 | * lpfc_poll_show: Return text about poll support for the adapter. | ||
969 | * @dev: class device that is converted into a Scsi_host. | ||
970 | * @attr: device attribute, not used. | ||
971 | * @buf: on return contains the cfg_poll in hex. | ||
972 | * | ||
973 | * Notes: | ||
974 | * cfg_poll should be a lpfc_polling_flags type. | ||
975 | * | ||
976 | * Returns: size of formatted string. | ||
977 | **/ | ||
626 | static ssize_t | 978 | static ssize_t |
627 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, | 979 | lpfc_poll_show(struct device *dev, struct device_attribute *attr, |
628 | char *buf) | 980 | char *buf) |
@@ -634,6 +986,20 @@ lpfc_poll_show(struct device *dev, struct device_attribute *attr, | |||
634 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); | 986 | return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll); |
635 | } | 987 | } |
636 | 988 | ||
989 | /** | ||
990 | * lpfc_poll_store: Set the value of cfg_poll for the adapter. | ||
991 | * @dev: class device that is converted into a Scsi_host. | ||
992 | * @attr: device attribute, not used. | ||
993 | * @buf: one or more lpfc_polling_flags values. | ||
994 | * @count: not used. | ||
995 | * | ||
996 | * Notes: | ||
997 | * buf contents converted to integer and checked for a valid value. | ||
998 | * | ||
999 | * Returns: | ||
1000 | * -EINVAL if the buffer connot be converted or is out of range | ||
1001 | * length of the buf on success | ||
1002 | **/ | ||
637 | static ssize_t | 1003 | static ssize_t |
638 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, | 1004 | lpfc_poll_store(struct device *dev, struct device_attribute *attr, |
639 | const char *buf, size_t count) | 1005 | const char *buf, size_t count) |
@@ -692,6 +1058,20 @@ lpfc_poll_store(struct device *dev, struct device_attribute *attr, | |||
692 | return strlen(buf); | 1058 | return strlen(buf); |
693 | } | 1059 | } |
694 | 1060 | ||
1061 | /** | ||
1062 | * lpfc_param_show: Return a cfg attribute value in decimal. | ||
1063 | * | ||
1064 | * Description: | ||
1065 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1066 | * into a function with the name lpfc_hba_queue_depth_show. | ||
1067 | * | ||
1068 | * lpfc_##attr##_show: Return the decimal value of an adapters cfg_xxx field. | ||
1069 | * @dev: class device that is converted into a Scsi_host. | ||
1070 | * @attr: device attribute, not used. | ||
1071 | * @buf: on return contains the attribute value in decimal. | ||
1072 | * | ||
1073 | * Returns: size of formatted string. | ||
1074 | **/ | ||
695 | #define lpfc_param_show(attr) \ | 1075 | #define lpfc_param_show(attr) \ |
696 | static ssize_t \ | 1076 | static ssize_t \ |
697 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | 1077 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
@@ -706,6 +1086,20 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
706 | phba->cfg_##attr);\ | 1086 | phba->cfg_##attr);\ |
707 | } | 1087 | } |
708 | 1088 | ||
1089 | /** | ||
1090 | * lpfc_param_hex_show: Return a cfg attribute value in hex. | ||
1091 | * | ||
1092 | * Description: | ||
1093 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1094 | * into a function with the name lpfc_hba_queue_depth_show | ||
1095 | * | ||
1096 | * lpfc_##attr##_show: Return the hex value of an adapters cfg_xxx field. | ||
1097 | * @dev: class device that is converted into a Scsi_host. | ||
1098 | * @attr: device attribute, not used. | ||
1099 | * @buf: on return contains the attribute value in hexidecimal. | ||
1100 | * | ||
1101 | * Returns: size of formatted string. | ||
1102 | **/ | ||
709 | #define lpfc_param_hex_show(attr) \ | 1103 | #define lpfc_param_hex_show(attr) \ |
710 | static ssize_t \ | 1104 | static ssize_t \ |
711 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | 1105 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
@@ -720,6 +1114,25 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
720 | phba->cfg_##attr);\ | 1114 | phba->cfg_##attr);\ |
721 | } | 1115 | } |
722 | 1116 | ||
1117 | /** | ||
1118 | * lpfc_param_init: Intializes a cfg attribute. | ||
1119 | * | ||
1120 | * Description: | ||
1121 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1122 | * into a function with the name lpfc_hba_queue_depth_init. The macro also | ||
1123 | * takes a default argument, a minimum and maximum argument. | ||
1124 | * | ||
1125 | * lpfc_##attr##_init: Initializes an attribute. | ||
1126 | * @phba: pointer the the adapter structure. | ||
1127 | * @val: integer attribute value. | ||
1128 | * | ||
1129 | * Validates the min and max values then sets the adapter config field | ||
1130 | * accordingly, or uses the default if out of range and prints an error message. | ||
1131 | * | ||
1132 | * Returns: | ||
1133 | * zero on success | ||
1134 | * -EINVAL if default used | ||
1135 | **/ | ||
723 | #define lpfc_param_init(attr, default, minval, maxval) \ | 1136 | #define lpfc_param_init(attr, default, minval, maxval) \ |
724 | static int \ | 1137 | static int \ |
725 | lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ | 1138 | lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ |
@@ -735,6 +1148,26 @@ lpfc_##attr##_init(struct lpfc_hba *phba, int val) \ | |||
735 | return -EINVAL;\ | 1148 | return -EINVAL;\ |
736 | } | 1149 | } |
737 | 1150 | ||
1151 | /** | ||
1152 | * lpfc_param_set: Set a cfg attribute value. | ||
1153 | * | ||
1154 | * Description: | ||
1155 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1156 | * into a function with the name lpfc_hba_queue_depth_set | ||
1157 | * | ||
1158 | * lpfc_##attr##_set: Sets an attribute value. | ||
1159 | * @phba: pointer the the adapter structure. | ||
1160 | * @val: integer attribute value. | ||
1161 | * | ||
1162 | * Description: | ||
1163 | * Validates the min and max values then sets the | ||
1164 | * adapter config field if in the valid range. prints error message | ||
1165 | * and does not set the parameter if invalid. | ||
1166 | * | ||
1167 | * Returns: | ||
1168 | * zero on success | ||
1169 | * -EINVAL if val is invalid | ||
1170 | **/ | ||
738 | #define lpfc_param_set(attr, default, minval, maxval) \ | 1171 | #define lpfc_param_set(attr, default, minval, maxval) \ |
739 | static int \ | 1172 | static int \ |
740 | lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ | 1173 | lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ |
@@ -749,6 +1182,27 @@ lpfc_##attr##_set(struct lpfc_hba *phba, int val) \ | |||
749 | return -EINVAL;\ | 1182 | return -EINVAL;\ |
750 | } | 1183 | } |
751 | 1184 | ||
1185 | /** | ||
1186 | * lpfc_param_store: Set a vport attribute value. | ||
1187 | * | ||
1188 | * Description: | ||
1189 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1190 | * into a function with the name lpfc_hba_queue_depth_store. | ||
1191 | * | ||
1192 | * lpfc_##attr##_store: Set an sttribute value. | ||
1193 | * @dev: class device that is converted into a Scsi_host. | ||
1194 | * @attr: device attribute, not used. | ||
1195 | * @buf: contains the attribute value in ascii. | ||
1196 | * @count: not used. | ||
1197 | * | ||
1198 | * Description: | ||
1199 | * Convert the ascii text number to an integer, then | ||
1200 | * use the lpfc_##attr##_set function to set the value. | ||
1201 | * | ||
1202 | * Returns: | ||
1203 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails | ||
1204 | * length of buffer upon success. | ||
1205 | **/ | ||
752 | #define lpfc_param_store(attr) \ | 1206 | #define lpfc_param_store(attr) \ |
753 | static ssize_t \ | 1207 | static ssize_t \ |
754 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ | 1208 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
@@ -768,6 +1222,20 @@ lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ | |||
768 | return -EINVAL;\ | 1222 | return -EINVAL;\ |
769 | } | 1223 | } |
770 | 1224 | ||
1225 | /** | ||
1226 | * lpfc_vport_param_show: Return decimal formatted cfg attribute value. | ||
1227 | * | ||
1228 | * Description: | ||
1229 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1230 | * into a function with the name lpfc_hba_queue_depth_show | ||
1231 | * | ||
1232 | * lpfc_##attr##_show: prints the attribute value in decimal. | ||
1233 | * @dev: class device that is converted into a Scsi_host. | ||
1234 | * @attr: device attribute, not used. | ||
1235 | * @buf: on return contains the attribute value in decimal. | ||
1236 | * | ||
1237 | * Returns: length of formatted string. | ||
1238 | **/ | ||
771 | #define lpfc_vport_param_show(attr) \ | 1239 | #define lpfc_vport_param_show(attr) \ |
772 | static ssize_t \ | 1240 | static ssize_t \ |
773 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | 1241 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
@@ -780,6 +1248,21 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
780 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ | 1248 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_##attr);\ |
781 | } | 1249 | } |
782 | 1250 | ||
1251 | /** | ||
1252 | * lpfc_vport_param_hex_show: Return hex formatted attribute value. | ||
1253 | * | ||
1254 | * Description: | ||
1255 | * Macro that given an attr e.g. | ||
1256 | * hba_queue_depth expands into a function with the name | ||
1257 | * lpfc_hba_queue_depth_show | ||
1258 | * | ||
1259 | * lpfc_##attr##_show: prints the attribute value in hexidecimal. | ||
1260 | * @dev: class device that is converted into a Scsi_host. | ||
1261 | * @attr: device attribute, not used. | ||
1262 | * @buf: on return contains the attribute value in hexidecimal. | ||
1263 | * | ||
1264 | * Returns: length of formatted string. | ||
1265 | **/ | ||
783 | #define lpfc_vport_param_hex_show(attr) \ | 1266 | #define lpfc_vport_param_hex_show(attr) \ |
784 | static ssize_t \ | 1267 | static ssize_t \ |
785 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | 1268 | lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ |
@@ -792,6 +1275,24 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \ | |||
792 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ | 1275 | return snprintf(buf, PAGE_SIZE, "%#x\n", vport->cfg_##attr);\ |
793 | } | 1276 | } |
794 | 1277 | ||
1278 | /** | ||
1279 | * lpfc_vport_param_init: Initialize a vport cfg attribute. | ||
1280 | * | ||
1281 | * Description: | ||
1282 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1283 | * into a function with the name lpfc_hba_queue_depth_init. The macro also | ||
1284 | * takes a default argument, a minimum and maximum argument. | ||
1285 | * | ||
1286 | * lpfc_##attr##_init: validates the min and max values then sets the | ||
1287 | * adapter config field accordingly, or uses the default if out of range | ||
1288 | * and prints an error message. | ||
1289 | * @phba: pointer the the adapter structure. | ||
1290 | * @val: integer attribute value. | ||
1291 | * | ||
1292 | * Returns: | ||
1293 | * zero on success | ||
1294 | * -EINVAL if default used | ||
1295 | **/ | ||
795 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ | 1296 | #define lpfc_vport_param_init(attr, default, minval, maxval) \ |
796 | static int \ | 1297 | static int \ |
797 | lpfc_##attr##_init(struct lpfc_vport *vport, int val) \ | 1298 | lpfc_##attr##_init(struct lpfc_vport *vport, int val) \ |
@@ -807,6 +1308,23 @@ lpfc_##attr##_init(struct lpfc_vport *vport, int val) \ | |||
807 | return -EINVAL;\ | 1308 | return -EINVAL;\ |
808 | } | 1309 | } |
809 | 1310 | ||
1311 | /** | ||
1312 | * lpfc_vport_param_set: Set a vport cfg attribute. | ||
1313 | * | ||
1314 | * Description: | ||
1315 | * Macro that given an attr e.g. hba_queue_depth expands | ||
1316 | * into a function with the name lpfc_hba_queue_depth_set | ||
1317 | * | ||
1318 | * lpfc_##attr##_set: validates the min and max values then sets the | ||
1319 | * adapter config field if in the valid range. prints error message | ||
1320 | * and does not set the parameter if invalid. | ||
1321 | * @phba: pointer the the adapter structure. | ||
1322 | * @val: integer attribute value. | ||
1323 | * | ||
1324 | * Returns: | ||
1325 | * zero on success | ||
1326 | * -EINVAL if val is invalid | ||
1327 | **/ | ||
810 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ | 1328 | #define lpfc_vport_param_set(attr, default, minval, maxval) \ |
811 | static int \ | 1329 | static int \ |
812 | lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ | 1330 | lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ |
@@ -821,6 +1339,23 @@ lpfc_##attr##_set(struct lpfc_vport *vport, int val) \ | |||
821 | return -EINVAL;\ | 1339 | return -EINVAL;\ |
822 | } | 1340 | } |
823 | 1341 | ||
1342 | /** | ||
1343 | * lpfc_vport_param_store: Set a vport attribute. | ||
1344 | * | ||
1345 | * Description: | ||
1346 | * Macro that given an attr e.g. hba_queue_depth | ||
1347 | * expands into a function with the name lpfc_hba_queue_depth_store | ||
1348 | * | ||
1349 | * lpfc_##attr##_store: convert the ascii text number to an integer, then | ||
1350 | * use the lpfc_##attr##_set function to set the value. | ||
1351 | * @cdev: class device that is converted into a Scsi_host. | ||
1352 | * @buf: contains the attribute value in decimal. | ||
1353 | * @count: not used. | ||
1354 | * | ||
1355 | * Returns: | ||
1356 | * -EINVAL if val is invalid or lpfc_##attr##_set() fails | ||
1357 | * length of buffer upon success. | ||
1358 | **/ | ||
824 | #define lpfc_vport_param_store(attr) \ | 1359 | #define lpfc_vport_param_store(attr) \ |
825 | static ssize_t \ | 1360 | static ssize_t \ |
826 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ | 1361 | lpfc_##attr##_store(struct device *dev, struct device_attribute *attr, \ |
@@ -958,6 +1493,17 @@ static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); | |||
958 | 1493 | ||
959 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; | 1494 | static char *lpfc_soft_wwn_key = "C99G71SL8032A"; |
960 | 1495 | ||
1496 | /** | ||
1497 | * lpfc_soft_wwn_enable_store: Allows setting of the wwn if the key is valid. | ||
1498 | * @dev: class device that is converted into a Scsi_host. | ||
1499 | * @attr: device attribute, not used. | ||
1500 | * @buf: containing the string lpfc_soft_wwn_key. | ||
1501 | * @count: must be size of lpfc_soft_wwn_key. | ||
1502 | * | ||
1503 | * Returns: | ||
1504 | * -EINVAL if the buffer does not contain lpfc_soft_wwn_key | ||
1505 | * length of buf indicates success | ||
1506 | **/ | ||
961 | static ssize_t | 1507 | static ssize_t |
962 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, | 1508 | lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, |
963 | const char *buf, size_t count) | 1509 | const char *buf, size_t count) |
@@ -994,6 +1540,14 @@ lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr, | |||
994 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, | 1540 | static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, |
995 | lpfc_soft_wwn_enable_store); | 1541 | lpfc_soft_wwn_enable_store); |
996 | 1542 | ||
1543 | /** | ||
1544 | * lpfc_soft_wwpn_show: Return the cfg soft ww port name of the adapter. | ||
1545 | * @dev: class device that is converted into a Scsi_host. | ||
1546 | * @attr: device attribute, not used. | ||
1547 | * @buf: on return contains the wwpn in hexidecimal. | ||
1548 | * | ||
1549 | * Returns: size of formatted string. | ||
1550 | **/ | ||
997 | static ssize_t | 1551 | static ssize_t |
998 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, | 1552 | lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, |
999 | char *buf) | 1553 | char *buf) |
@@ -1006,7 +1560,19 @@ lpfc_soft_wwpn_show(struct device *dev, struct device_attribute *attr, | |||
1006 | (unsigned long long)phba->cfg_soft_wwpn); | 1560 | (unsigned long long)phba->cfg_soft_wwpn); |
1007 | } | 1561 | } |
1008 | 1562 | ||
1009 | 1563 | /** | |
1564 | * lpfc_soft_wwpn_store: Set the ww port name of the adapter. | ||
1565 | * @dev class device that is converted into a Scsi_host. | ||
1566 | * @attr: device attribute, not used. | ||
1567 | * @buf: contains the wwpn in hexidecimal. | ||
1568 | * @count: number of wwpn bytes in buf | ||
1569 | * | ||
1570 | * Returns: | ||
1571 | * -EACCES hba reset not enabled, adapter over temp | ||
1572 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwpn byte invalid | ||
1573 | * -EIO error taking adapter offline or online | ||
1574 | * value of count on success | ||
1575 | **/ | ||
1010 | static ssize_t | 1576 | static ssize_t |
1011 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, | 1577 | lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, |
1012 | const char *buf, size_t count) | 1578 | const char *buf, size_t count) |
@@ -1080,6 +1646,14 @@ lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr, | |||
1080 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ | 1646 | static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR,\ |
1081 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); | 1647 | lpfc_soft_wwpn_show, lpfc_soft_wwpn_store); |
1082 | 1648 | ||
1649 | /** | ||
1650 | * lpfc_soft_wwnn_show: Return the cfg soft ww node name for the adapter. | ||
1651 | * @dev: class device that is converted into a Scsi_host. | ||
1652 | * @attr: device attribute, not used. | ||
1653 | * @buf: on return contains the wwnn in hexidecimal. | ||
1654 | * | ||
1655 | * Returns: size of formatted string. | ||
1656 | **/ | ||
1083 | static ssize_t | 1657 | static ssize_t |
1084 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, | 1658 | lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, |
1085 | char *buf) | 1659 | char *buf) |
@@ -1090,7 +1664,16 @@ lpfc_soft_wwnn_show(struct device *dev, struct device_attribute *attr, | |||
1090 | (unsigned long long)phba->cfg_soft_wwnn); | 1664 | (unsigned long long)phba->cfg_soft_wwnn); |
1091 | } | 1665 | } |
1092 | 1666 | ||
1093 | 1667 | /** | |
1668 | * lpfc_soft_wwnn_store: sets the ww node name of the adapter. | ||
1669 | * @cdev: class device that is converted into a Scsi_host. | ||
1670 | * @buf: contains the ww node name in hexidecimal. | ||
1671 | * @count: number of wwnn bytes in buf. | ||
1672 | * | ||
1673 | * Returns: | ||
1674 | * -EINVAL soft wwn not enabled, count is invalid, invalid wwnn byte invalid | ||
1675 | * value of count on success | ||
1676 | **/ | ||
1094 | static ssize_t | 1677 | static ssize_t |
1095 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, | 1678 | lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr, |
1096 | const char *buf, size_t count) | 1679 | const char *buf, size_t count) |
@@ -1178,6 +1761,15 @@ module_param(lpfc_nodev_tmo, int, 0); | |||
1178 | MODULE_PARM_DESC(lpfc_nodev_tmo, | 1761 | MODULE_PARM_DESC(lpfc_nodev_tmo, |
1179 | "Seconds driver will hold I/O waiting " | 1762 | "Seconds driver will hold I/O waiting " |
1180 | "for a device to come back"); | 1763 | "for a device to come back"); |
1764 | |||
1765 | /** | ||
1766 | * lpfc_nodev_tmo_show: Return the hba dev loss timeout value. | ||
1767 | * @dev: class converted to a Scsi_host structure. | ||
1768 | * @attr: device attribute, not used. | ||
1769 | * @buf: on return contains the dev loss timeout in decimal. | ||
1770 | * | ||
1771 | * Returns: size of formatted string. | ||
1772 | **/ | ||
1181 | static ssize_t | 1773 | static ssize_t |
1182 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, | 1774 | lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, |
1183 | char *buf) | 1775 | char *buf) |
@@ -1189,6 +1781,21 @@ lpfc_nodev_tmo_show(struct device *dev, struct device_attribute *attr, | |||
1189 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); | 1781 | return snprintf(buf, PAGE_SIZE, "%d\n", vport->cfg_devloss_tmo); |
1190 | } | 1782 | } |
1191 | 1783 | ||
1784 | /** | ||
1785 | * lpfc_nodev_tmo_init: Set the hba nodev timeout value. | ||
1786 | * @vport: lpfc vport structure pointer. | ||
1787 | * @val: contains the nodev timeout value. | ||
1788 | * | ||
1789 | * Description: | ||
1790 | * If the devloss tmo is already set then nodev tmo is set to devloss tmo, | ||
1791 | * a kernel error message is printed and zero is returned. | ||
1792 | * Else if val is in range then nodev tmo and devloss tmo are set to val. | ||
1793 | * Otherwise nodev tmo is set to the default value. | ||
1794 | * | ||
1795 | * Returns: | ||
1796 | * zero if already set or if val is in range | ||
1797 | * -EINVAL val out of range | ||
1798 | **/ | ||
1192 | static int | 1799 | static int |
1193 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) | 1800 | lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) |
1194 | { | 1801 | { |
@@ -1215,6 +1822,13 @@ lpfc_nodev_tmo_init(struct lpfc_vport *vport, int val) | |||
1215 | return -EINVAL; | 1822 | return -EINVAL; |
1216 | } | 1823 | } |
1217 | 1824 | ||
1825 | /** | ||
1826 | * lpfc_update_rport_devloss_tmo: Update dev loss tmo value. | ||
1827 | * @vport: lpfc vport structure pointer. | ||
1828 | * | ||
1829 | * Description: | ||
1830 | * Update all the ndlp's dev loss tmo with the vport devloss tmo value. | ||
1831 | **/ | ||
1218 | static void | 1832 | static void |
1219 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) | 1833 | lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) |
1220 | { | 1834 | { |
@@ -1229,6 +1843,21 @@ lpfc_update_rport_devloss_tmo(struct lpfc_vport *vport) | |||
1229 | spin_unlock_irq(shost->host_lock); | 1843 | spin_unlock_irq(shost->host_lock); |
1230 | } | 1844 | } |
1231 | 1845 | ||
1846 | /** | ||
1847 | * lpfc_nodev_tmo_set: Set the vport nodev tmo and devloss tmo values. | ||
1848 | * @vport: lpfc vport structure pointer. | ||
1849 | * @val: contains the tmo value. | ||
1850 | * | ||
1851 | * Description: | ||
1852 | * If the devloss tmo is already set or the vport dev loss tmo has changed | ||
1853 | * then a kernel error message is printed and zero is returned. | ||
1854 | * Else if val is in range then nodev tmo and devloss tmo are set to val. | ||
1855 | * Otherwise nodev tmo is set to the default value. | ||
1856 | * | ||
1857 | * Returns: | ||
1858 | * zero if already set or if val is in range | ||
1859 | * -EINVAL val out of range | ||
1860 | **/ | ||
1232 | static int | 1861 | static int |
1233 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) | 1862 | lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val) |
1234 | { | 1863 | { |
@@ -1269,6 +1898,21 @@ MODULE_PARM_DESC(lpfc_devloss_tmo, | |||
1269 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, | 1898 | lpfc_vport_param_init(devloss_tmo, LPFC_DEF_DEVLOSS_TMO, |
1270 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) | 1899 | LPFC_MIN_DEVLOSS_TMO, LPFC_MAX_DEVLOSS_TMO) |
1271 | lpfc_vport_param_show(devloss_tmo) | 1900 | lpfc_vport_param_show(devloss_tmo) |
1901 | |||
1902 | /** | ||
1903 | * lpfc_devloss_tmo_set: Sets vport nodev tmo, devloss tmo values, changed bit. | ||
1904 | * @vport: lpfc vport structure pointer. | ||
1905 | * @val: contains the tmo value. | ||
1906 | * | ||
1907 | * Description: | ||
1908 | * If val is in a valid range then set the vport nodev tmo, | ||
1909 | * devloss tmo, also set the vport dev loss tmo changed flag. | ||
1910 | * Else a kernel error message is printed. | ||
1911 | * | ||
1912 | * Returns: | ||
1913 | * zero if val is in range | ||
1914 | * -EINVAL val out of range | ||
1915 | **/ | ||
1272 | static int | 1916 | static int |
1273 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) | 1917 | lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val) |
1274 | { | 1918 | { |
@@ -1366,6 +2010,21 @@ MODULE_PARM_DESC(lpfc_restrict_login, | |||
1366 | "Restrict virtual ports login to remote initiators."); | 2010 | "Restrict virtual ports login to remote initiators."); |
1367 | lpfc_vport_param_show(restrict_login); | 2011 | lpfc_vport_param_show(restrict_login); |
1368 | 2012 | ||
2013 | /** | ||
2014 | * lpfc_restrict_login_init: Set the vport restrict login flag. | ||
2015 | * @vport: lpfc vport structure pointer. | ||
2016 | * @val: contains the restrict login value. | ||
2017 | * | ||
2018 | * Description: | ||
2019 | * If val is not in a valid range then log a kernel error message and set | ||
2020 | * the vport restrict login to one. | ||
2021 | * If the port type is physical clear the restrict login flag and return. | ||
2022 | * Else set the restrict login flag to val. | ||
2023 | * | ||
2024 | * Returns: | ||
2025 | * zero if val is in range | ||
2026 | * -EINVAL val out of range | ||
2027 | **/ | ||
1369 | static int | 2028 | static int |
1370 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) | 2029 | lpfc_restrict_login_init(struct lpfc_vport *vport, int val) |
1371 | { | 2030 | { |
@@ -1385,6 +2044,22 @@ lpfc_restrict_login_init(struct lpfc_vport *vport, int val) | |||
1385 | return 0; | 2044 | return 0; |
1386 | } | 2045 | } |
1387 | 2046 | ||
2047 | /** | ||
2048 | * lpfc_restrict_login_set: Set the vport restrict login flag. | ||
2049 | * @vport: lpfc vport structure pointer. | ||
2050 | * @val: contains the restrict login value. | ||
2051 | * | ||
2052 | * Description: | ||
2053 | * If val is not in a valid range then log a kernel error message and set | ||
2054 | * the vport restrict login to one. | ||
2055 | * If the port type is physical and the val is not zero log a kernel | ||
2056 | * error message, clear the restrict login flag and return zero. | ||
2057 | * Else set the restrict login flag to val. | ||
2058 | * | ||
2059 | * Returns: | ||
2060 | * zero if val is in range | ||
2061 | * -EINVAL val out of range | ||
2062 | **/ | ||
1388 | static int | 2063 | static int |
1389 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) | 2064 | lpfc_restrict_login_set(struct lpfc_vport *vport, int val) |
1390 | { | 2065 | { |
@@ -1441,6 +2116,23 @@ LPFC_VPORT_ATTR_R(scan_down, 1, 0, 1, | |||
1441 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. | 2116 | # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6]. |
1442 | # Default value is 0. | 2117 | # Default value is 0. |
1443 | */ | 2118 | */ |
2119 | |||
2120 | /** | ||
2121 | * lpfc_topology_set: Set the adapters topology field. | ||
2122 | * @phba: lpfc_hba pointer. | ||
2123 | * @val: topology value. | ||
2124 | * | ||
2125 | * Description: | ||
2126 | * If val is in a valid range then set the adapter's topology field and | ||
2127 | * issue a lip; if the lip fails reset the topology to the old value. | ||
2128 | * | ||
2129 | * If the value is not in range log a kernel error message and return an error. | ||
2130 | * | ||
2131 | * Returns: | ||
2132 | * zero if val is in range and lip okay | ||
2133 | * non-zero return value from lpfc_issue_lip() | ||
2134 | * -EINVAL val out of range | ||
2135 | **/ | ||
1444 | static int | 2136 | static int |
1445 | lpfc_topology_set(struct lpfc_hba *phba, int val) | 2137 | lpfc_topology_set(struct lpfc_hba *phba, int val) |
1446 | { | 2138 | { |
@@ -1479,6 +2171,24 @@ static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, | |||
1479 | # 8 = 8 Gigabaud | 2171 | # 8 = 8 Gigabaud |
1480 | # Value range is [0,8]. Default value is 0. | 2172 | # Value range is [0,8]. Default value is 0. |
1481 | */ | 2173 | */ |
2174 | |||
2175 | /** | ||
2176 | * lpfc_link_speed_set: Set the adapters link speed. | ||
2177 | * @phba: lpfc_hba pointer. | ||
2178 | * @val: link speed value. | ||
2179 | * | ||
2180 | * Description: | ||
2181 | * If val is in a valid range then set the adapter's link speed field and | ||
2182 | * issue a lip; if the lip fails reset the link speed to the old value. | ||
2183 | * | ||
2184 | * Notes: | ||
2185 | * If the value is not in range log a kernel error message and return an error. | ||
2186 | * | ||
2187 | * Returns: | ||
2188 | * zero if val is in range and lip okay. | ||
2189 | * non-zero return value from lpfc_issue_lip() | ||
2190 | * -EINVAL val out of range | ||
2191 | **/ | ||
1482 | static int | 2192 | static int |
1483 | lpfc_link_speed_set(struct lpfc_hba *phba, int val) | 2193 | lpfc_link_speed_set(struct lpfc_hba *phba, int val) |
1484 | { | 2194 | { |
@@ -1513,6 +2223,23 @@ static int lpfc_link_speed = 0; | |||
1513 | module_param(lpfc_link_speed, int, 0); | 2223 | module_param(lpfc_link_speed, int, 0); |
1514 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); | 2224 | MODULE_PARM_DESC(lpfc_link_speed, "Select link speed"); |
1515 | lpfc_param_show(link_speed) | 2225 | lpfc_param_show(link_speed) |
2226 | |||
2227 | /** | ||
2228 | * lpfc_link_speed_init: Set the adapters link speed. | ||
2229 | * @phba: lpfc_hba pointer. | ||
2230 | * @val: link speed value. | ||
2231 | * | ||
2232 | * Description: | ||
2233 | * If val is in a valid range then set the adapter's link speed field. | ||
2234 | * | ||
2235 | * Notes: | ||
2236 | * If the value is not in range log a kernel error message, clear the link | ||
2237 | * speed and return an error. | ||
2238 | * | ||
2239 | * Returns: | ||
2240 | * zero if val saved. | ||
2241 | * -EINVAL val out of range | ||
2242 | **/ | ||
1516 | static int | 2243 | static int |
1517 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) | 2244 | lpfc_link_speed_init(struct lpfc_hba *phba, int val) |
1518 | { | 2245 | { |
@@ -1734,6 +2461,24 @@ struct device_attribute *lpfc_vport_attrs[] = { | |||
1734 | NULL, | 2461 | NULL, |
1735 | }; | 2462 | }; |
1736 | 2463 | ||
2464 | /** | ||
2465 | * sysfs_ctlreg_write: Write method for writing to ctlreg. | ||
2466 | * @kobj: kernel kobject that contains the kernel class device. | ||
2467 | * @bin_attr: kernel attributes passed to us. | ||
2468 | * @buf: contains the data to be written to the adapter IOREG space. | ||
2469 | * @off: offset into buffer to beginning of data. | ||
2470 | * @count: bytes to transfer. | ||
2471 | * | ||
2472 | * Description: | ||
2473 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. | ||
2474 | * Uses the adapter io control registers to send buf contents to the adapter. | ||
2475 | * | ||
2476 | * Returns: | ||
2477 | * -ERANGE off and count combo out of range | ||
2478 | * -EINVAL off, count or buff address invalid | ||
2479 | * -EPERM adapter is offline | ||
2480 | * value of count, buf contents written | ||
2481 | **/ | ||
1737 | static ssize_t | 2482 | static ssize_t |
1738 | sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 2483 | sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, |
1739 | char *buf, loff_t off, size_t count) | 2484 | char *buf, loff_t off, size_t count) |
@@ -1766,6 +2511,23 @@ sysfs_ctlreg_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
1766 | return count; | 2511 | return count; |
1767 | } | 2512 | } |
1768 | 2513 | ||
2514 | /** | ||
2515 | * sysfs_ctlreg_read: Read method for reading from ctlreg. | ||
2516 | * @kobj: kernel kobject that contains the kernel class device. | ||
2517 | * @bin_attr: kernel attributes passed to us. | ||
2518 | * @buf: if succesful contains the data from the adapter IOREG space. | ||
2519 | * @off: offset into buffer to beginning of data. | ||
2520 | * @count: bytes to transfer. | ||
2521 | * | ||
2522 | * Description: | ||
2523 | * Accessed via /sys/class/scsi_host/hostxxx/ctlreg. | ||
2524 | * Uses the adapter io control registers to read data into buf. | ||
2525 | * | ||
2526 | * Returns: | ||
2527 | * -ERANGE off and count combo out of range | ||
2528 | * -EINVAL off, count or buff address invalid | ||
2529 | * value of count, buf contents read | ||
2530 | **/ | ||
1769 | static ssize_t | 2531 | static ssize_t |
1770 | sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 2532 | sysfs_ctlreg_read(struct kobject *kobj, struct bin_attribute *bin_attr, |
1771 | char *buf, loff_t off, size_t count) | 2533 | char *buf, loff_t off, size_t count) |
@@ -1810,7 +2572,10 @@ static struct bin_attribute sysfs_ctlreg_attr = { | |||
1810 | .write = sysfs_ctlreg_write, | 2572 | .write = sysfs_ctlreg_write, |
1811 | }; | 2573 | }; |
1812 | 2574 | ||
1813 | 2575 | /** | |
2576 | * sysfs_mbox_idle: frees the sysfs mailbox. | ||
2577 | * @phba: lpfc_hba pointer | ||
2578 | **/ | ||
1814 | static void | 2579 | static void |
1815 | sysfs_mbox_idle(struct lpfc_hba *phba) | 2580 | sysfs_mbox_idle(struct lpfc_hba *phba) |
1816 | { | 2581 | { |
@@ -1824,6 +2589,27 @@ sysfs_mbox_idle(struct lpfc_hba *phba) | |||
1824 | } | 2589 | } |
1825 | } | 2590 | } |
1826 | 2591 | ||
2592 | /** | ||
2593 | * sysfs_mbox_write: Write method for writing information via mbox. | ||
2594 | * @kobj: kernel kobject that contains the kernel class device. | ||
2595 | * @bin_attr: kernel attributes passed to us. | ||
2596 | * @buf: contains the data to be written to sysfs mbox. | ||
2597 | * @off: offset into buffer to beginning of data. | ||
2598 | * @count: bytes to transfer. | ||
2599 | * | ||
2600 | * Description: | ||
2601 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. | ||
2602 | * Uses the sysfs mbox to send buf contents to the adapter. | ||
2603 | * | ||
2604 | * Returns: | ||
2605 | * -ERANGE off and count combo out of range | ||
2606 | * -EINVAL off, count or buff address invalid | ||
2607 | * zero if count is zero | ||
2608 | * -EPERM adapter is offline | ||
2609 | * -ENOMEM failed to allocate memory for the mail box | ||
2610 | * -EAGAIN offset, state or mbox is NULL | ||
2611 | * count number of bytes transferred | ||
2612 | **/ | ||
1827 | static ssize_t | 2613 | static ssize_t |
1828 | sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | 2614 | sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, |
1829 | char *buf, loff_t off, size_t count) | 2615 | char *buf, loff_t off, size_t count) |
@@ -1878,6 +2664,29 @@ sysfs_mbox_write(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
1878 | return count; | 2664 | return count; |
1879 | } | 2665 | } |
1880 | 2666 | ||
2667 | /** | ||
2668 | * sysfs_mbox_read: Read method for reading information via mbox. | ||
2669 | * @kobj: kernel kobject that contains the kernel class device. | ||
2670 | * @bin_attr: kernel attributes passed to us. | ||
2671 | * @buf: contains the data to be read from sysfs mbox. | ||
2672 | * @off: offset into buffer to beginning of data. | ||
2673 | * @count: bytes to transfer. | ||
2674 | * | ||
2675 | * Description: | ||
2676 | * Accessed via /sys/class/scsi_host/hostxxx/mbox. | ||
2677 | * Uses the sysfs mbox to receive data from to the adapter. | ||
2678 | * | ||
2679 | * Returns: | ||
2680 | * -ERANGE off greater than mailbox command size | ||
2681 | * -EINVAL off, count or buff address invalid | ||
2682 | * zero if off and count are zero | ||
2683 | * -EACCES adapter over temp | ||
2684 | * -EPERM garbage can value to catch a multitude of errors | ||
2685 | * -EAGAIN management IO not permitted, state or off error | ||
2686 | * -ETIME mailbox timeout | ||
2687 | * -ENODEV mailbox error | ||
2688 | * count number of bytes transferred | ||
2689 | **/ | ||
1881 | static ssize_t | 2690 | static ssize_t |
1882 | sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, | 2691 | sysfs_mbox_read(struct kobject *kobj, struct bin_attribute *bin_attr, |
1883 | char *buf, loff_t off, size_t count) | 2692 | char *buf, loff_t off, size_t count) |
@@ -2059,6 +2868,14 @@ static struct bin_attribute sysfs_mbox_attr = { | |||
2059 | .write = sysfs_mbox_write, | 2868 | .write = sysfs_mbox_write, |
2060 | }; | 2869 | }; |
2061 | 2870 | ||
2871 | /** | ||
2872 | * lpfc_alloc_sysfs_attr: Creates the sysfs, ctlreg, menlo and mbox entries. | ||
2873 | * @vport: address of lpfc vport structure. | ||
2874 | * | ||
2875 | * Return codes: | ||
2876 | * zero on success | ||
2877 | * error return code from sysfs_create_bin_file() | ||
2878 | **/ | ||
2062 | int | 2879 | int |
2063 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) | 2880 | lpfc_alloc_sysfs_attr(struct lpfc_vport *vport) |
2064 | { | 2881 | { |
@@ -2082,6 +2899,10 @@ out: | |||
2082 | return error; | 2899 | return error; |
2083 | } | 2900 | } |
2084 | 2901 | ||
2902 | /** | ||
2903 | * lpfc_free_sysfs_attr: Removes the sysfs, ctlreg, menlo and mbox entries. | ||
2904 | * @vport: address of lpfc vport structure. | ||
2905 | **/ | ||
2085 | void | 2906 | void |
2086 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) | 2907 | lpfc_free_sysfs_attr(struct lpfc_vport *vport) |
2087 | { | 2908 | { |
@@ -2096,6 +2917,10 @@ lpfc_free_sysfs_attr(struct lpfc_vport *vport) | |||
2096 | * Dynamic FC Host Attributes Support | 2917 | * Dynamic FC Host Attributes Support |
2097 | */ | 2918 | */ |
2098 | 2919 | ||
2920 | /** | ||
2921 | * lpfc_get_host_port_id: Copy the vport DID into the scsi host port id. | ||
2922 | * @shost: kernel scsi host pointer. | ||
2923 | **/ | ||
2099 | static void | 2924 | static void |
2100 | lpfc_get_host_port_id(struct Scsi_Host *shost) | 2925 | lpfc_get_host_port_id(struct Scsi_Host *shost) |
2101 | { | 2926 | { |
@@ -2105,6 +2930,10 @@ lpfc_get_host_port_id(struct Scsi_Host *shost) | |||
2105 | fc_host_port_id(shost) = vport->fc_myDID; | 2930 | fc_host_port_id(shost) = vport->fc_myDID; |
2106 | } | 2931 | } |
2107 | 2932 | ||
2933 | /** | ||
2934 | * lpfc_get_host_port_type: Set the value of the scsi host port type. | ||
2935 | * @shost: kernel scsi host pointer. | ||
2936 | **/ | ||
2108 | static void | 2937 | static void |
2109 | lpfc_get_host_port_type(struct Scsi_Host *shost) | 2938 | lpfc_get_host_port_type(struct Scsi_Host *shost) |
2110 | { | 2939 | { |
@@ -2133,6 +2962,10 @@ lpfc_get_host_port_type(struct Scsi_Host *shost) | |||
2133 | spin_unlock_irq(shost->host_lock); | 2962 | spin_unlock_irq(shost->host_lock); |
2134 | } | 2963 | } |
2135 | 2964 | ||
2965 | /** | ||
2966 | * lpfc_get_host_port_state: Set the value of the scsi host port state. | ||
2967 | * @shost: kernel scsi host pointer. | ||
2968 | **/ | ||
2136 | static void | 2969 | static void |
2137 | lpfc_get_host_port_state(struct Scsi_Host *shost) | 2970 | lpfc_get_host_port_state(struct Scsi_Host *shost) |
2138 | { | 2971 | { |
@@ -2167,6 +3000,10 @@ lpfc_get_host_port_state(struct Scsi_Host *shost) | |||
2167 | spin_unlock_irq(shost->host_lock); | 3000 | spin_unlock_irq(shost->host_lock); |
2168 | } | 3001 | } |
2169 | 3002 | ||
3003 | /** | ||
3004 | * lpfc_get_host_speed: Set the value of the scsi host speed. | ||
3005 | * @shost: kernel scsi host pointer. | ||
3006 | **/ | ||
2170 | static void | 3007 | static void |
2171 | lpfc_get_host_speed(struct Scsi_Host *shost) | 3008 | lpfc_get_host_speed(struct Scsi_Host *shost) |
2172 | { | 3009 | { |
@@ -2199,6 +3036,10 @@ lpfc_get_host_speed(struct Scsi_Host *shost) | |||
2199 | spin_unlock_irq(shost->host_lock); | 3036 | spin_unlock_irq(shost->host_lock); |
2200 | } | 3037 | } |
2201 | 3038 | ||
3039 | /** | ||
3040 | * lpfc_get_host_fabric_name: Set the value of the scsi host fabric name. | ||
3041 | * @shost: kernel scsi host pointer. | ||
3042 | **/ | ||
2202 | static void | 3043 | static void |
2203 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) | 3044 | lpfc_get_host_fabric_name (struct Scsi_Host *shost) |
2204 | { | 3045 | { |
@@ -2221,6 +3062,18 @@ lpfc_get_host_fabric_name (struct Scsi_Host *shost) | |||
2221 | fc_host_fabric_name(shost) = node_name; | 3062 | fc_host_fabric_name(shost) = node_name; |
2222 | } | 3063 | } |
2223 | 3064 | ||
3065 | /** | ||
3066 | * lpfc_get_stats: Return statistical information about the adapter. | ||
3067 | * @shost: kernel scsi host pointer. | ||
3068 | * | ||
3069 | * Notes: | ||
3070 | * NULL on error for link down, no mbox pool, sli2 active, | ||
3071 | * management not allowed, memory allocation error, or mbox error. | ||
3072 | * | ||
3073 | * Returns: | ||
3074 | * NULL for error | ||
3075 | * address of the adapter host statistics | ||
3076 | **/ | ||
2224 | static struct fc_host_statistics * | 3077 | static struct fc_host_statistics * |
2225 | lpfc_get_stats(struct Scsi_Host *shost) | 3078 | lpfc_get_stats(struct Scsi_Host *shost) |
2226 | { | 3079 | { |
@@ -2334,6 +3187,10 @@ lpfc_get_stats(struct Scsi_Host *shost) | |||
2334 | return hs; | 3187 | return hs; |
2335 | } | 3188 | } |
2336 | 3189 | ||
3190 | /** | ||
3191 | * lpfc_reset_stats: Copy the adapter link stats information. | ||
3192 | * @shost: kernel scsi host pointer. | ||
3193 | **/ | ||
2337 | static void | 3194 | static void |
2338 | lpfc_reset_stats(struct Scsi_Host *shost) | 3195 | lpfc_reset_stats(struct Scsi_Host *shost) |
2339 | { | 3196 | { |
@@ -2411,6 +3268,14 @@ lpfc_reset_stats(struct Scsi_Host *shost) | |||
2411 | * are no sysfs handlers for link_down_tmo. | 3268 | * are no sysfs handlers for link_down_tmo. |
2412 | */ | 3269 | */ |
2413 | 3270 | ||
3271 | /** | ||
3272 | * lpfc_get_node_by_target: Return the nodelist for a target. | ||
3273 | * @starget: kernel scsi target pointer. | ||
3274 | * | ||
3275 | * Returns: | ||
3276 | * address of the node list if found | ||
3277 | * NULL target not found | ||
3278 | **/ | ||
2414 | static struct lpfc_nodelist * | 3279 | static struct lpfc_nodelist * |
2415 | lpfc_get_node_by_target(struct scsi_target *starget) | 3280 | lpfc_get_node_by_target(struct scsi_target *starget) |
2416 | { | 3281 | { |
@@ -2432,6 +3297,10 @@ lpfc_get_node_by_target(struct scsi_target *starget) | |||
2432 | return NULL; | 3297 | return NULL; |
2433 | } | 3298 | } |
2434 | 3299 | ||
3300 | /** | ||
3301 | * lpfc_get_starget_port_id: Set the target port id to the ndlp DID or -1. | ||
3302 | * @starget: kernel scsi target pointer. | ||
3303 | **/ | ||
2435 | static void | 3304 | static void |
2436 | lpfc_get_starget_port_id(struct scsi_target *starget) | 3305 | lpfc_get_starget_port_id(struct scsi_target *starget) |
2437 | { | 3306 | { |
@@ -2440,6 +3309,12 @@ lpfc_get_starget_port_id(struct scsi_target *starget) | |||
2440 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; | 3309 | fc_starget_port_id(starget) = ndlp ? ndlp->nlp_DID : -1; |
2441 | } | 3310 | } |
2442 | 3311 | ||
3312 | /** | ||
3313 | * lpfc_get_starget_node_name: Set the target node name. | ||
3314 | * @starget: kernel scsi target pointer. | ||
3315 | * | ||
3316 | * Description: Set the target node name to the ndlp node name wwn or zero. | ||
3317 | **/ | ||
2443 | static void | 3318 | static void |
2444 | lpfc_get_starget_node_name(struct scsi_target *starget) | 3319 | lpfc_get_starget_node_name(struct scsi_target *starget) |
2445 | { | 3320 | { |
@@ -2449,6 +3324,12 @@ lpfc_get_starget_node_name(struct scsi_target *starget) | |||
2449 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; | 3324 | ndlp ? wwn_to_u64(ndlp->nlp_nodename.u.wwn) : 0; |
2450 | } | 3325 | } |
2451 | 3326 | ||
3327 | /** | ||
3328 | * lpfc_get_starget_port_name: Set the target port name. | ||
3329 | * @starget: kernel scsi target pointer. | ||
3330 | * | ||
3331 | * Description: set the target port name to the ndlp port name wwn or zero. | ||
3332 | **/ | ||
2452 | static void | 3333 | static void |
2453 | lpfc_get_starget_port_name(struct scsi_target *starget) | 3334 | lpfc_get_starget_port_name(struct scsi_target *starget) |
2454 | { | 3335 | { |
@@ -2458,6 +3339,15 @@ lpfc_get_starget_port_name(struct scsi_target *starget) | |||
2458 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; | 3339 | ndlp ? wwn_to_u64(ndlp->nlp_portname.u.wwn) : 0; |
2459 | } | 3340 | } |
2460 | 3341 | ||
3342 | /** | ||
3343 | * lpfc_set_rport_loss_tmo: Set the rport dev loss tmo. | ||
3344 | * @rport: fc rport address. | ||
3345 | * @timeout: new value for dev loss tmo. | ||
3346 | * | ||
3347 | * Description: | ||
3348 | * If timeout is non zero set the dev_loss_tmo to timeout, else set | ||
3349 | * dev_loss_tmo to one. | ||
3350 | **/ | ||
2461 | static void | 3351 | static void |
2462 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | 3352 | lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) |
2463 | { | 3353 | { |
@@ -2467,7 +3357,18 @@ lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout) | |||
2467 | rport->dev_loss_tmo = 1; | 3357 | rport->dev_loss_tmo = 1; |
2468 | } | 3358 | } |
2469 | 3359 | ||
2470 | 3360 | /** | |
3361 | * lpfc_rport_show_function: Return rport target information. | ||
3362 | * | ||
3363 | * Description: | ||
3364 | * Macro that uses field to generate a function with the name lpfc_show_rport_ | ||
3365 | * | ||
3366 | * lpfc_show_rport_##field: returns the bytes formatted in buf | ||
3367 | * @cdev: class converted to an fc_rport. | ||
3368 | * @buf: on return contains the target_field or zero. | ||
3369 | * | ||
3370 | * Returns: size of formatted string. | ||
3371 | **/ | ||
2471 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ | 3372 | #define lpfc_rport_show_function(field, format_string, sz, cast) \ |
2472 | static ssize_t \ | 3373 | static ssize_t \ |
2473 | lpfc_show_rport_##field (struct device *dev, \ | 3374 | lpfc_show_rport_##field (struct device *dev, \ |
@@ -2602,6 +3503,10 @@ struct fc_function_template lpfc_vport_transport_functions = { | |||
2602 | .vport_disable = lpfc_vport_disable, | 3503 | .vport_disable = lpfc_vport_disable, |
2603 | }; | 3504 | }; |
2604 | 3505 | ||
3506 | /** | ||
3507 | * lpfc_get_cfgparam: Used during probe_one to init the adapter structure. | ||
3508 | * @phba: lpfc_hba pointer. | ||
3509 | **/ | ||
2605 | void | 3510 | void |
2606 | lpfc_get_cfgparam(struct lpfc_hba *phba) | 3511 | lpfc_get_cfgparam(struct lpfc_hba *phba) |
2607 | { | 3512 | { |
@@ -2637,6 +3542,10 @@ lpfc_get_cfgparam(struct lpfc_hba *phba) | |||
2637 | return; | 3542 | return; |
2638 | } | 3543 | } |
2639 | 3544 | ||
3545 | /** | ||
3546 | * lpfc_get_vport_cfgparam: Used during port create, init the vport structure. | ||
3547 | * @vport: lpfc_vport pointer. | ||
3548 | **/ | ||
2640 | void | 3549 | void |
2641 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) | 3550 | lpfc_get_vport_cfgparam(struct lpfc_vport *vport) |
2642 | { | 3551 | { |