diff options
Diffstat (limited to 'drivers/scsi/be2iscsi/be_iscsi.c')
-rw-r--r-- | drivers/scsi/be2iscsi/be_iscsi.c | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c index 6d63e7b312cf..7d4d2275573c 100644 --- a/drivers/scsi/be2iscsi/be_iscsi.c +++ b/drivers/scsi/be2iscsi/be_iscsi.c | |||
@@ -300,40 +300,16 @@ int beiscsi_get_host_param(struct Scsi_Host *shost, | |||
300 | enum iscsi_host_param param, char *buf) | 300 | enum iscsi_host_param param, char *buf) |
301 | { | 301 | { |
302 | struct beiscsi_hba *phba = (struct beiscsi_hba *)iscsi_host_priv(shost); | 302 | struct beiscsi_hba *phba = (struct beiscsi_hba *)iscsi_host_priv(shost); |
303 | struct be_cmd_resp_get_mac_addr *resp; | ||
304 | struct be_mcc_wrb *wrb; | ||
305 | unsigned int tag, wrb_num; | ||
306 | int len = 0; | 303 | int len = 0; |
307 | unsigned short status, extd_status; | 304 | int status; |
308 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; | ||
309 | 305 | ||
310 | SE_DEBUG(DBG_LVL_8, "In beiscsi_get_host_param, param= %d\n", param); | 306 | SE_DEBUG(DBG_LVL_8, "In beiscsi_get_host_param, param= %d\n", param); |
311 | switch (param) { | 307 | switch (param) { |
312 | case ISCSI_HOST_PARAM_HWADDRESS: | 308 | case ISCSI_HOST_PARAM_HWADDRESS: |
313 | tag = be_cmd_get_mac_addr(phba); | 309 | status = beiscsi_get_macaddr(buf, phba); |
314 | if (!tag) { | 310 | if (status < 0) { |
315 | SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n"); | 311 | SE_DEBUG(DBG_LVL_1, "beiscsi_get_macaddr Failed\n"); |
316 | return -EAGAIN; | 312 | return status; |
317 | } else | ||
318 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | ||
319 | phba->ctrl.mcc_numtag[tag]); | ||
320 | |||
321 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; | ||
322 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; | ||
323 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; | ||
324 | if (status || extd_status) { | ||
325 | SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed" | ||
326 | " status = %d extd_status = %d\n", | ||
327 | status, extd_status); | ||
328 | free_mcc_tag(&phba->ctrl, tag); | ||
329 | return -EAGAIN; | ||
330 | } else { | ||
331 | wrb = queue_get_wrb(mccq, wrb_num); | ||
332 | free_mcc_tag(&phba->ctrl, tag); | ||
333 | resp = embedded_payload(wrb); | ||
334 | memcpy(phba->mac_address, resp->mac_address, ETH_ALEN); | ||
335 | len = sysfs_format_mac(buf, phba->mac_address, | ||
336 | ETH_ALEN); | ||
337 | } | 313 | } |
338 | break; | 314 | break; |
339 | default: | 315 | default: |
@@ -342,6 +318,48 @@ int beiscsi_get_host_param(struct Scsi_Host *shost, | |||
342 | return len; | 318 | return len; |
343 | } | 319 | } |
344 | 320 | ||
321 | int beiscsi_get_macaddr(char *buf, struct beiscsi_hba *phba) | ||
322 | { | ||
323 | struct be_cmd_resp_get_mac_addr *resp; | ||
324 | struct be_mcc_wrb *wrb; | ||
325 | unsigned int tag, wrb_num; | ||
326 | unsigned short status, extd_status; | ||
327 | struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; | ||
328 | int rc; | ||
329 | |||
330 | if (phba->read_mac_address) | ||
331 | return sysfs_format_mac(buf, phba->mac_address, | ||
332 | ETH_ALEN); | ||
333 | |||
334 | tag = be_cmd_get_mac_addr(phba); | ||
335 | if (!tag) { | ||
336 | SE_DEBUG(DBG_LVL_1, "be_cmd_get_mac_addr Failed\n"); | ||
337 | return -EBUSY; | ||
338 | } else | ||
339 | wait_event_interruptible(phba->ctrl.mcc_wait[tag], | ||
340 | phba->ctrl.mcc_numtag[tag]); | ||
341 | |||
342 | wrb_num = (phba->ctrl.mcc_numtag[tag] & 0x00FF0000) >> 16; | ||
343 | extd_status = (phba->ctrl.mcc_numtag[tag] & 0x0000FF00) >> 8; | ||
344 | status = phba->ctrl.mcc_numtag[tag] & 0x000000FF; | ||
345 | if (status || extd_status) { | ||
346 | SE_DEBUG(DBG_LVL_1, "Failed to get be_cmd_get_mac_addr" | ||
347 | " status = %d extd_status = %d\n", | ||
348 | status, extd_status); | ||
349 | free_mcc_tag(&phba->ctrl, tag); | ||
350 | return -EAGAIN; | ||
351 | } | ||
352 | wrb = queue_get_wrb(mccq, wrb_num); | ||
353 | free_mcc_tag(&phba->ctrl, tag); | ||
354 | resp = embedded_payload(wrb); | ||
355 | memcpy(phba->mac_address, resp->mac_address, ETH_ALEN); | ||
356 | rc = sysfs_format_mac(buf, phba->mac_address, | ||
357 | ETH_ALEN); | ||
358 | phba->read_mac_address = 1; | ||
359 | return rc; | ||
360 | } | ||
361 | |||
362 | |||
345 | /** | 363 | /** |
346 | * beiscsi_conn_get_stats - get the iscsi stats | 364 | * beiscsi_conn_get_stats - get the iscsi stats |
347 | * @cls_conn: pointer to iscsi cls conn | 365 | * @cls_conn: pointer to iscsi cls conn |