drivers/net/ethernet/qlogic/qed/qed_nvmetcp_fw_funcs.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qlogic/qed/qed_nvmetcp_fw_funcs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/qlogic/qed/qed_nvmetcp_fw_funcs.c
Extension
.c
Size
13363 bytes
Lines
376
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (task_params->tx_io_size) {
			if (task_params->send_write_incapsule)
				buf_size = calc_rw_task_size(task_params, task_type);

			if (nvmetcp_is_slow_sgl(sgl_task_params->num_sges,
						sgl_task_params->small_mid_sge))
				num_sges = NVMETCP_WQE_NUM_SGES_SLOWIO;
			else
				num_sges = min((u16)sgl_task_params->num_sges,
					       (u16)SCSI_NUM_SGES_SLOW_SGL_THR);
		}
		SET_FIELD(task_params->sqe->flags, NVMETCP_WQE_NUM_SGES, num_sges);
		SET_FIELD(task_params->sqe->contlen_cdbsize, NVMETCP_WQE_CONT_LEN, buf_size);
	} break;

	case NVMETCP_TASK_TYPE_HOST_READ: {
		SET_FIELD(task_params->sqe->flags, NVMETCP_WQE_WQE_TYPE,
			  NVMETCP_WQE_TYPE_NORMAL);
		SET_FIELD(task_params->sqe->contlen_cdbsize,
			  NVMETCP_WQE_CDB_SIZE_OR_NVMETCP_CMD, 1);
	} break;

	case NVMETCP_TASK_TYPE_INIT_CONN_REQUEST: {
		SET_FIELD(task_params->sqe->flags, NVMETCP_WQE_WQE_TYPE,
			  NVMETCP_WQE_TYPE_MIDDLE_PATH);

		if (task_params->tx_io_size) {
			SET_FIELD(task_params->sqe->contlen_cdbsize, NVMETCP_WQE_CONT_LEN,
				  task_params->tx_io_size);
			SET_FIELD(task_params->sqe->flags, NVMETCP_WQE_NUM_SGES,
				  min((u16)sgl_task_params->num_sges,
				      (u16)SCSI_NUM_SGES_SLOW_SGL_THR));
		}
	} break;

	case NVMETCP_TASK_TYPE_CLEANUP:
		SET_FIELD(task_params->sqe->flags, NVMETCP_WQE_WQE_TYPE,
			  NVMETCP_WQE_TYPE_TASK_CLEANUP);

	default:
		break;
	}
}

/* The following function initializes of NVMeTCP task params */
static inline void
init_nvmetcp_task_params(struct e5_nvmetcp_task_context *context,
			 struct nvmetcp_task_params *task_params,
			 enum nvmetcp_task_type task_type)
{
	context->ystorm_st_context.state.cccid = task_params->host_cccid;
	SET_FIELD(context->ustorm_st_context.error_flags, USTORM_NVMETCP_TASK_ST_CTX_NVME_TCP, 1);
	context->ustorm_st_context.nvme_tcp_opaque_lo = cpu_to_le32(task_params->opq.lo);
	context->ustorm_st_context.nvme_tcp_opaque_hi = cpu_to_le32(task_params->opq.hi);
}

/* The following function initializes default values to all tasks */
static inline void
init_default_nvmetcp_task(struct nvmetcp_task_params *task_params,
			  void *pdu_header, void *nvme_cmd,
			  enum nvmetcp_task_type task_type)
{
	struct e5_nvmetcp_task_context *context = task_params->context;
	const u8 val_byte = context->mstorm_ag_context.cdu_validation;
	u8 dw_index;

	memset(context, 0, sizeof(*context));
	init_nvmetcp_task_params(context, task_params,
				 (enum nvmetcp_task_type)task_type);

	/* Swapping requirements used below, will be removed in future FW versions */
	if (task_type == NVMETCP_TASK_TYPE_HOST_WRITE ||
	    task_type == NVMETCP_TASK_TYPE_HOST_READ) {
		for (dw_index = 0;
		     dw_index < QED_NVMETCP_CMN_HDR_SIZE / sizeof(u32);
		     dw_index++)
			context->ystorm_st_context.pdu_hdr.task_hdr.reg[dw_index] =
				cpu_to_le32(__swab32(((u32 *)pdu_header)[dw_index]));

		for (dw_index = QED_NVMETCP_CMN_HDR_SIZE / sizeof(u32);
		     dw_index < QED_NVMETCP_CMD_HDR_SIZE / sizeof(u32);
		     dw_index++)
			context->ystorm_st_context.pdu_hdr.task_hdr.reg[dw_index] =
				cpu_to_le32(__swab32(((u32 *)nvme_cmd)[dw_index - 2]));
	} else {
		for (dw_index = 0;
		     dw_index < QED_NVMETCP_NON_IO_HDR_SIZE / sizeof(u32);
		     dw_index++)
			context->ystorm_st_context.pdu_hdr.task_hdr.reg[dw_index] =
				cpu_to_le32(__swab32(((u32 *)pdu_header)[dw_index]));

Annotation

Implementation Notes