Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/ctld/kernel.c
Show First 20 Lines • Show All 892 Lines • ▼ Show 20 Lines | req.data.handoff.portal_group_tag = | ||||
conn->conn_portal->p_portal_group->pg_tag; | conn->conn_portal->p_portal_group->pg_tag; | ||||
if (conn->conn_header_digest == CONN_DIGEST_CRC32C) | if (conn->conn_header_digest == CONN_DIGEST_CRC32C) | ||||
req.data.handoff.header_digest = CTL_ISCSI_DIGEST_CRC32C; | req.data.handoff.header_digest = CTL_ISCSI_DIGEST_CRC32C; | ||||
if (conn->conn_data_digest == CONN_DIGEST_CRC32C) | if (conn->conn_data_digest == CONN_DIGEST_CRC32C) | ||||
req.data.handoff.data_digest = CTL_ISCSI_DIGEST_CRC32C; | req.data.handoff.data_digest = CTL_ISCSI_DIGEST_CRC32C; | ||||
req.data.handoff.cmdsn = conn->conn_cmdsn; | req.data.handoff.cmdsn = conn->conn_cmdsn; | ||||
req.data.handoff.statsn = conn->conn_statsn; | req.data.handoff.statsn = conn->conn_statsn; | ||||
req.data.handoff.max_recv_data_segment_length = | req.data.handoff.max_recv_data_segment_length = | ||||
conn->conn_max_data_segment_length; | conn->conn_max_recv_data_segment_length; | ||||
req.data.handoff.max_send_data_segment_length = | |||||
conn->conn_max_send_data_segment_length; | |||||
req.data.handoff.max_burst_length = conn->conn_max_burst_length; | req.data.handoff.max_burst_length = conn->conn_max_burst_length; | ||||
req.data.handoff.first_burst_length = conn->conn_first_burst_length; | req.data.handoff.first_burst_length = conn->conn_first_burst_length; | ||||
req.data.handoff.immediate_data = conn->conn_immediate_data; | req.data.handoff.immediate_data = conn->conn_immediate_data; | ||||
if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1) { | if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1) { | ||||
log_err(1, "error issuing CTL_ISCSI ioctl; " | log_err(1, "error issuing CTL_ISCSI ioctl; " | ||||
"dropping connection"); | "dropping connection"); | ||||
} | } | ||||
if (req.status != CTL_ISCSI_OK) { | if (req.status != CTL_ISCSI_OK) { | ||||
log_errx(1, "error returned from CTL iSCSI handoff request: " | log_errx(1, "error returned from CTL iSCSI handoff request: " | ||||
"%s; dropping connection", req.error_str); | "%s; dropping connection", req.error_str); | ||||
} | } | ||||
} | } | ||||
void | void | ||||
kernel_limits(const char *offload, size_t *max_data_segment_length) | kernel_limits(const char *offload, int *max_recv_dsl, int *max_send_dsl, | ||||
int *max_burst_length, int *first_burst_length) | |||||
{ | { | ||||
struct ctl_iscsi req; | struct ctl_iscsi req; | ||||
struct ctl_iscsi_limits_params *cilp; | |||||
bzero(&req, sizeof(req)); | bzero(&req, sizeof(req)); | ||||
req.type = CTL_ISCSI_LIMITS; | req.type = CTL_ISCSI_LIMITS; | ||||
cilp = (struct ctl_iscsi_limits_params *)&(req.data.limits); | |||||
if (offload != NULL) { | if (offload != NULL) { | ||||
strlcpy(req.data.limits.offload, offload, | strlcpy(cilp->offload, offload, sizeof(cilp->offload)); | ||||
sizeof(req.data.limits.offload)); | |||||
} | } | ||||
if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1) { | if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1) { | ||||
log_err(1, "error issuing CTL_ISCSI ioctl; " | log_err(1, "error issuing CTL_ISCSI ioctl; " | ||||
"dropping connection"); | "dropping connection"); | ||||
} | } | ||||
if (req.status != CTL_ISCSI_OK) { | if (req.status != CTL_ISCSI_OK) { | ||||
log_errx(1, "error returned from CTL iSCSI limits request: " | log_errx(1, "error returned from CTL iSCSI limits request: " | ||||
"%s; dropping connection", req.error_str); | "%s; dropping connection", req.error_str); | ||||
} | } | ||||
*max_data_segment_length = req.data.limits.data_segment_limit; | if (cilp->max_recv_data_segment_length != 0) { | ||||
*max_recv_dsl = cilp->max_recv_data_segment_length; | |||||
*max_send_dsl = cilp->max_recv_data_segment_length; | |||||
} | |||||
if (cilp->max_send_data_segment_length != 0) | |||||
*max_send_dsl = cilp->max_send_data_segment_length; | |||||
if (cilp->max_burst_length != 0) | |||||
*max_burst_length = cilp->max_burst_length; | |||||
if (cilp->first_burst_length != 0) | |||||
*first_burst_length = cilp->first_burst_length; | |||||
if (*max_burst_length < *first_burst_length) | |||||
*first_burst_length = *max_burst_length; | |||||
if (offload != NULL) { | if (offload != NULL) { | ||||
log_debugx("MaxRecvDataSegment kernel limit for offload " | log_debugx("Kernel limits for offload \"%s\" are " | ||||
"\"%s\" is %zd", offload, *max_data_segment_length); | "MaxRecvDataSegment=%d, max_send_dsl=%d, " | ||||
"MaxBurstLength=%d, FirstBurstLength=%d", | |||||
offload, *max_recv_dsl, *max_send_dsl, *max_burst_length, | |||||
*first_burst_length); | |||||
} else { | } else { | ||||
log_debugx("MaxRecvDataSegment kernel limit is %zd", | log_debugx("Kernel limits are " | ||||
*max_data_segment_length); | "MaxRecvDataSegment=%d, max_send_dsl=%d, " | ||||
"MaxBurstLength=%d, FirstBurstLength=%d", | |||||
*max_recv_dsl, *max_send_dsl, *max_burst_length, | |||||
*first_burst_length); | |||||
} | } | ||||
} | } | ||||
int | int | ||||
kernel_port_add(struct port *port) | kernel_port_add(struct port *port) | ||||
{ | { | ||||
struct option *o; | struct option *o; | ||||
struct ctl_port_entry entry; | struct ctl_port_entry entry; | ||||
▲ Show 20 Lines • Show All 257 Lines • ▼ Show 20 Lines | if (req.status != CTL_ISCSI_OK) { | ||||
log_errx(1, "error returned from CTL iSCSI send: " | log_errx(1, "error returned from CTL iSCSI send: " | ||||
"%s; dropping connection", req.error_str); | "%s; dropping connection", req.error_str); | ||||
} | } | ||||
} | } | ||||
void | void | ||||
kernel_receive(struct pdu *pdu) | kernel_receive(struct pdu *pdu) | ||||
{ | { | ||||
struct connection *conn; | |||||
struct ctl_iscsi req; | struct ctl_iscsi req; | ||||
pdu->pdu_data = malloc(MAX_DATA_SEGMENT_LENGTH); | conn = pdu->pdu_connection; | ||||
pdu->pdu_data = malloc(conn->conn_max_recv_data_segment_length); | |||||
if (pdu->pdu_data == NULL) | if (pdu->pdu_data == NULL) | ||||
log_err(1, "malloc"); | log_err(1, "malloc"); | ||||
bzero(&req, sizeof(req)); | bzero(&req, sizeof(req)); | ||||
req.type = CTL_ISCSI_RECEIVE; | req.type = CTL_ISCSI_RECEIVE; | ||||
req.data.receive.connection_id = pdu->pdu_connection->conn_socket; | req.data.receive.connection_id = conn->conn_socket; | ||||
req.data.receive.bhs = pdu->pdu_bhs; | req.data.receive.bhs = pdu->pdu_bhs; | ||||
req.data.receive.data_segment_len = MAX_DATA_SEGMENT_LENGTH; | req.data.receive.data_segment_len = | ||||
conn->conn_max_recv_data_segment_length; | |||||
req.data.receive.data_segment = pdu->pdu_data; | req.data.receive.data_segment = pdu->pdu_data; | ||||
if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1) { | if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1) { | ||||
log_err(1, "error issuing CTL_ISCSI ioctl; " | log_err(1, "error issuing CTL_ISCSI ioctl; " | ||||
"dropping connection"); | "dropping connection"); | ||||
} | } | ||||
if (req.status != CTL_ISCSI_OK) { | if (req.status != CTL_ISCSI_OK) { | ||||
Show All 38 Lines |