Commit b14cb744 authored by Bart Van Assche's avatar Bart Van Assche Committed by Doug Ledford

IB/srpt: Introduce srpt_format_guid()

Introduce a function for converting a GUID into an ASCII string. This
patch does not change any functionality.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 3fa7f0e9
...@@ -524,6 +524,15 @@ static void srpt_mad_recv_handler(struct ib_mad_agent *mad_agent, ...@@ -524,6 +524,15 @@ static void srpt_mad_recv_handler(struct ib_mad_agent *mad_agent,
ib_free_recv_mad(mad_wc); ib_free_recv_mad(mad_wc);
} }
static int srpt_format_guid(char *buf, unsigned int size, const __be64 *guid)
{
const __be16 *g = (const __be16 *)guid;
return snprintf(buf, size, "%04x:%04x:%04x:%04x",
be16_to_cpu(g[0]), be16_to_cpu(g[1]),
be16_to_cpu(g[2]), be16_to_cpu(g[3]));
}
/** /**
* srpt_refresh_port - configure a HCA port * srpt_refresh_port - configure a HCA port
* @sport: SRPT HCA port. * @sport: SRPT HCA port.
...@@ -539,7 +548,6 @@ static int srpt_refresh_port(struct srpt_port *sport) ...@@ -539,7 +548,6 @@ static int srpt_refresh_port(struct srpt_port *sport)
struct ib_mad_reg_req reg_req; struct ib_mad_reg_req reg_req;
struct ib_port_modify port_modify; struct ib_port_modify port_modify;
struct ib_port_attr port_attr; struct ib_port_attr port_attr;
__be16 *guid;
int ret; int ret;
memset(&port_modify, 0, sizeof(port_modify)); memset(&port_modify, 0, sizeof(port_modify));
...@@ -563,11 +571,8 @@ static int srpt_refresh_port(struct srpt_port *sport) ...@@ -563,11 +571,8 @@ static int srpt_refresh_port(struct srpt_port *sport)
goto err_query_port; goto err_query_port;
sport->port_guid_wwn.priv = sport; sport->port_guid_wwn.priv = sport;
guid = (__be16 *)&sport->gid.global.interface_id; srpt_format_guid(sport->port_guid, sizeof(sport->port_guid),
snprintf(sport->port_guid, sizeof(sport->port_guid), &sport->gid.global.interface_id);
"%04x:%04x:%04x:%04x",
be16_to_cpu(guid[0]), be16_to_cpu(guid[1]),
be16_to_cpu(guid[2]), be16_to_cpu(guid[3]));
sport->port_gid_wwn.priv = sport; sport->port_gid_wwn.priv = sport;
snprintf(sport->port_gid, sizeof(sport->port_gid), snprintf(sport->port_gid, sizeof(sport->port_gid),
"0x%016llx%016llx", "0x%016llx%016llx",
...@@ -1998,7 +2003,6 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, ...@@ -1998,7 +2003,6 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
struct srp_login_rej *rej; struct srp_login_rej *rej;
struct ib_cm_rep_param *rep_param; struct ib_cm_rep_param *rep_param;
struct srpt_rdma_ch *ch, *tmp_ch; struct srpt_rdma_ch *ch, *tmp_ch;
__be16 *guid;
u32 it_iu_len; u32 it_iu_len;
int i, ret = 0; int i, ret = 0;
...@@ -2150,10 +2154,8 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, ...@@ -2150,10 +2154,8 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id,
goto destroy_ib; goto destroy_ib;
} }
guid = (__be16 *)&param->primary_path->dgid.global.interface_id; srpt_format_guid(ch->ini_guid, sizeof(ch->ini_guid),
snprintf(ch->ini_guid, sizeof(ch->ini_guid), "%04x:%04x:%04x:%04x", &param->primary_path->dgid.global.interface_id);
be16_to_cpu(guid[0]), be16_to_cpu(guid[1]),
be16_to_cpu(guid[2]), be16_to_cpu(guid[3]));
snprintf(ch->sess_name, sizeof(ch->sess_name), "0x%016llx%016llx", snprintf(ch->sess_name, sizeof(ch->sess_name), "0x%016llx%016llx",
be64_to_cpu(*(__be64 *)ch->i_port_id), be64_to_cpu(*(__be64 *)ch->i_port_id),
be64_to_cpu(*(__be64 *)(ch->i_port_id + 8))); be64_to_cpu(*(__be64 *)(ch->i_port_id + 8)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment