28 #include <scsi/scsi.h>
56 "beiscsi_session_create: invalid ep\n");
60 phba = beiscsi_ep->
phba;
64 "BS_%d : In beiscsi_session_create\n");
66 if (cmds_max > beiscsi_ep->
phba->params.wrbs_per_cxn) {
68 "BS_%d : Cannot handle %d cmds."
69 "Max cmds per session supported is %d. Using %d."
71 beiscsi_ep->
phba->params.wrbs_per_cxn,
72 beiscsi_ep->
phba->params.wrbs_per_cxn);
74 cmds_max = beiscsi_ep->
phba->params.wrbs_per_cxn;
79 sizeof(*beiscsi_sess),
86 beiscsi_sess->
bhs_pool = pci_pool_create(
"beiscsi_bhs_pool",
112 pci_pool_destroy(beiscsi_sess->
bhs_pool);
136 "BS_%d : In beiscsi_conn_create ,cid"
137 "from iscsi layer=%d\n", cid);
146 beiscsi_conn->
phba = phba;
147 beiscsi_conn->
conn = conn;
160 static int beiscsi_bindconn_cid(
struct beiscsi_hba *phba,
166 "BS_%d : Connection table already occupied. Detected clash\n");
171 "BS_%d : phba->conn_table[%d]=%p(beiscsi_conn)\n",
192 struct beiscsi_conn *beiscsi_conn = conn->
dd_data;
207 if (beiscsi_ep->
phba != phba) {
209 "BS_%d : beiscsi_ep->hba=%p not equal to phba=%p\n",
210 beiscsi_ep->
phba, phba);
216 beiscsi_conn->
ep = beiscsi_ep;
217 beiscsi_ep->
conn = beiscsi_conn;
220 "BS_%d : beiscsi_conn=%p conn=%p ep_cid=%d\n",
221 beiscsi_conn, conn, beiscsi_ep->
ep_cid);
223 return beiscsi_bindconn_cid(phba, beiscsi_conn, beiscsi_ep->
ep_cid);
226 static int beiscsi_create_ipv4_iface(
struct beiscsi_hba *phba)
238 "create default IPv4 address.\n");
245 static int beiscsi_create_ipv6_iface(
struct beiscsi_hba *phba)
257 "create default IPv6 address.\n");
269 beiscsi_create_ipv4_iface(phba);
272 beiscsi_create_ipv6_iface(phba);
295 switch (iface_param->
param) {
299 iface_ip = nla_data(nla);
303 iface_subnet = nla_data(nla);
306 iface_ip = iface_param;
309 iface_subnet = nla_data(nla);
312 iface_subnet = iface_param;
315 iface_ip = nla_data(nla);
319 "BS_%d : Unsupported param %d\n",
323 if (!iface_ip || !iface_subnet) {
325 "BS_%d : IP and Subnet Mask required\n");
348 beiscsi_set_vlan_tag(
struct Scsi_Host *shost,
357 "BS_%d : Getting Interface Handle Failed\n");
361 switch (iface_param->
param) {
372 "BS_%d : Unkown Param Type : %d\n",
381 beiscsi_set_ipv4(
struct Scsi_Host *shost,
389 switch (iface_param->
param) {
398 ret = beiscsi_set_static_ip(shost, iface_param,
402 "BS_%d : Invalid BOOTPROTO: %d\n",
403 iface_param->
value[0]);
407 ret = beiscsi_create_ipv4_iface(phba);
413 ret = beiscsi_set_static_ip(shost, iface_param,
418 ret = beiscsi_set_vlan_tag(shost, iface_param);
422 "BS_%d : Param %d not supported\n",
430 beiscsi_set_ipv6(
struct Scsi_Host *shost,
437 switch (iface_param->
param) {
440 ret = beiscsi_create_ipv6_iface(phba);
452 "BS_%d : Param %d not supported\n",
469 iface_param = nla_data(attrib);
479 "BS_%d : Invalid iface_num %d."
480 "Only iface_num 0 is supported.\n",
488 ret = beiscsi_set_ipv4(shost, iface_param,
492 ret = beiscsi_set_ipv6(shost, iface_param,
497 "BS_%d : Invalid iface type :%d passed\n",
509 static int be2iscsi_get_if_param(
struct beiscsi_hba *phba,
516 memset(&if_info, 0,
sizeof(if_info));
527 len =
sprintf(buf,
"%pI4\n", &if_info.ip_addr.addr);
530 len =
sprintf(buf,
"%pI6\n", &if_info.ip_addr.addr);
533 if (!if_info.dhcp_state)
539 len =
sprintf(buf,
"%pI4\n", &if_info.ip_addr.subnet_mask);
544 ?
"Disabled" :
"Enabled");
551 (if_info.vlan_priority &
559 ((if_info.vlan_priority >> 13) &
571 int param,
char *buf)
586 len = be2iscsi_get_if_param(phba, iface, param, buf);
592 memset(&gateway, 0,
sizeof(gateway));
620 "BS_%d : In beiscsi_ep_get_param,"
621 " param= %d\n", param);
647 phba = ((
struct beiscsi_conn *)conn->
dd_data)->phba;
649 "BS_%d : In beiscsi_conn_set_param,"
650 " param= %d\n", param);
690 static int beiscsi_get_initname(
char *buf,
struct beiscsi_hba *phba)
693 unsigned int tag, wrb_num;
694 unsigned short status, extd_status;
702 "BS_%d : Getting Initiator Name Failed\n");
707 phba->
ctrl.mcc_numtag[tag]);
709 wrb_num = (phba->
ctrl.mcc_numtag[
tag] & 0x00FF0000) >> 16;
710 extd_status = (phba->
ctrl.mcc_numtag[
tag] & 0x0000FF00) >> 8;
711 status = phba->
ctrl.mcc_numtag[
tag] & 0x000000FF;
713 if (status || extd_status) {
716 "BS_%d : MailBox Command Failed with "
717 "status = %d extd_status = %d\n",
718 status, extd_status);
723 wrb = queue_get_wrb(mccq, wrb_num);
725 resp = embedded_payload(wrb);
736 static void beiscsi_get_port_state(
struct Scsi_Host *shost)
751 static int beiscsi_get_port_speed(
struct Scsi_Host *shost)
753 unsigned int tag, wrb_num;
754 unsigned short status, extd_status;
764 "BS_%d : Getting Port Speed Failed\n");
769 phba->
ctrl.mcc_numtag[tag]);
771 wrb_num = (phba->
ctrl.mcc_numtag[
tag] & 0x00FF0000) >> 16;
772 extd_status = (phba->
ctrl.mcc_numtag[
tag] & 0x0000FF00) >> 8;
773 status = phba->
ctrl.mcc_numtag[
tag] & 0x000000FF;
775 if (status || extd_status) {
778 "BS_%d : MailBox Command Failed with "
779 "status = %d extd_status = %d\n",
780 status, extd_status);
785 wrb = queue_get_wrb(mccq, wrb_num);
787 resp = embedded_payload(wrb);
823 "BS_%d : In beiscsi_get_host_param,"
824 " param= %d\n", param);
831 "BS_%d : beiscsi_get_macaddr Failed\n");
836 status = beiscsi_get_initname(buf, phba);
839 "BS_%d : Retreiving Initiator Name Failed\n");
844 beiscsi_get_port_state(shost);
848 status = beiscsi_get_port_speed(shost);
851 "BS_%d : Retreiving Port Speed Failed\n");
870 memset(&resp, 0,
sizeof(resp));
892 phba = ((
struct beiscsi_conn *)conn->
dd_data)->phba;
894 "BS_%d : In beiscsi_conn_get_stats\n");
908 strcpy(stats->custom[0].desc,
"eh_abort_cnt");
917 static void beiscsi_set_params_for_offld(
struct beiscsi_conn *beiscsi_conn,
926 max_send_data_segment_length, params,
951 struct beiscsi_conn *beiscsi_conn = conn->
dd_data;
957 "BS_%d : In beiscsi_conn_start\n");
960 beiscsi_ep = beiscsi_conn->
ep;
964 "BS_%d : In beiscsi_conn_start , no beiscsi_ep\n");
967 beiscsi_set_params_for_offld(beiscsi_conn, ¶ms);
977 static int beiscsi_get_cid(
struct beiscsi_hba *phba)
979 unsigned short cid = 0xFFFF;
996 static void beiscsi_put_cid(
struct beiscsi_hba *phba,
unsigned short cid)
1012 beiscsi_put_cid(phba, beiscsi_ep->
ep_cid);
1033 unsigned short status, extd_status;
1035 unsigned int tag, wrb_num;
1039 "BS_%d : In beiscsi_open_conn\n");
1041 beiscsi_ep->
ep_cid = beiscsi_get_cid(phba);
1042 if (beiscsi_ep->
ep_cid == 0xFFFF) {
1044 "BS_%d : No free cid available\n");
1049 "BS_%d : In beiscsi_open_conn, ep_cid=%d\n",
1055 phba->
params.cxns_per_ctrl * 2)) {
1058 "BS_%d : Failed in allocate iscsi cid\n");
1066 if (nonemb_cmd.va ==
NULL) {
1069 "BS_%d : Failed to allocate memory for"
1070 " mgmt_open_connection\n");
1072 beiscsi_put_cid(phba, beiscsi_ep->
ep_cid);
1076 memset(nonemb_cmd.va, 0, nonemb_cmd.size);
1080 "BS_%d : mgmt_open_connection Failed for cid=%d\n",
1083 beiscsi_put_cid(phba, beiscsi_ep->
ep_cid);
1085 nonemb_cmd.va, nonemb_cmd.dma);
1089 phba->
ctrl.mcc_numtag[tag]);
1091 wrb_num = (phba->
ctrl.mcc_numtag[
tag] & 0x00FF0000) >> 16;
1092 extd_status = (phba->
ctrl.mcc_numtag[
tag] & 0x0000FF00) >> 8;
1093 status = phba->
ctrl.mcc_numtag[
tag] & 0x000000FF;
1094 if (status || extd_status) {
1097 "BS_%d : mgmt_open_connection Failed"
1098 " status = %d extd_status = %d\n",
1099 status, extd_status);
1103 nonemb_cmd.va, nonemb_cmd.dma);
1106 wrb = queue_get_wrb(mccq, wrb_num);
1109 ptcpcnct_out = embedded_payload(wrb);
1114 "BS_%d : mgmt_open_connection Success\n");
1117 nonemb_cmd.va, nonemb_cmd.dma);
1121 beiscsi_free_ep(beiscsi_ep);
1147 "beiscsi_ep_connect shost is NULL\n");
1148 return ERR_PTR(ret);
1154 "BS_%d : The Adapter state is Not UP\n");
1155 return ERR_PTR(ret);
1161 return ERR_PTR(ret);
1165 beiscsi_ep->
phba = phba;
1167 ret = beiscsi_open_conn(ep,
NULL, dst_addr, non_blocking);
1170 "BS_%d : Failed in beiscsi_open_conn\n");
1178 return ERR_PTR(ret);
1193 "BS_%d : In beiscsi_ep_poll\n");
1215 "BS_%d : upload failed for cid 0x%x\n",
1221 phba->
ctrl.mcc_numtag[tag]);
1232 static int beiscsi_unbind_conn_to_cid(
struct beiscsi_hba *phba,
1239 "BS_%d : Connection table Not occupied.\n");
1253 struct beiscsi_conn *beiscsi_conn;
1257 uint8_t mgmt_invalidate_flag, tcp_upload_flag;
1261 phba = beiscsi_ep->
phba;
1263 "BS_%d : In beiscsi_ep_disconnect for ep_cid = %d\n",
1266 if (beiscsi_ep->
conn) {
1267 beiscsi_conn = beiscsi_ep->
conn;
1278 mgmt_invalidate_flag,
1282 "BS_%d : mgmt_invalidate_connection Failed for cid=%d\n",
1286 phba->
ctrl.mcc_numtag[tag]);
1290 beiscsi_close_conn(beiscsi_ep, tcp_upload_flag);
1291 beiscsi_free_ep(beiscsi_ep);
1292 beiscsi_unbind_conn_to_cid(phba, beiscsi_ep->
ep_cid);
1298 switch (param_type) {