[PATCH v2 1/4] IB/core: Add inline function to get sg mr type

Sagi Grimberg sagi at grimberg.me
Thu Apr 20 04:24:15 PDT 2017


> +/**
> + * ib_get_sg_mr_type() - check if the device support arbitrary
> + *                       sg mapping and return a suitable mr type.
> + * @device: The device on which to check support.
> + *
> + * Return: IB_MR_TYPE_SG_GAPS if the device support.
> + *         Otherwise, return IB_MR_TYPE_MEM_REG.
> + */
> +static inline enum ib_mr_type ib_get_sg_mr_type(struct ib_device *device)
> +{
> +	if (device->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)
> +		return IB_MR_TYPE_SG_GAPS;
> +	else
> +		return IB_MR_TYPE_MEM_REG;
> +
> +}
> +

It does eliminate some code duplication, but will everyone prefer
the GAPS type? I guess they can just not use it, maybe the naming
should reflect that GAPS is preferred? (it doesn't come for free
as the device might need more resources to support GAPS)

Not sure...



More information about the Linux-nvme mailing list