Re: [RFC 6/6] target: add uasp fabric module [WIP]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2011-12-08 at 18:30 +0100, Sebastian Andrzej Siewior wrote:
> As of now it supports HS only (SS is not yet supported).
> Only commands are passed (read/write requests are handled but TASK
> MANAGEMENT functions and others from this category are not).
> 
> Temporary, it requires the transfer direction to be hardcoded.
> I need to figure out how to bypass informations to the gadget framework.
> Until then, enjoy the_only_tpg_I_currently_have.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
>  drivers/target/Kconfig           |    1 +
>  drivers/target/Makefile          |    1 +
>  drivers/target/uasp/Kconfig      |    6 +
>  drivers/target/uasp/Makefile     |    5 +
>  drivers/target/uasp/base.h       |   39 ++
>  drivers/target/uasp/configfs.c   |  518 +++++++++++++++++++++++++
>  drivers/target/uasp/configfs.h   |    7 +
>  drivers/target/uasp/fabric.c     |  407 ++++++++++++++++++++
>  drivers/target/uasp/fabric.h     |   39 ++
>  drivers/target/uasp/gadget.c     |  770 ++++++++++++++++++++++++++++++++++++++
>  drivers/target/uasp/gadget.h     |   81 ++++
>  drivers/target/uasp/gadget_ops.h |   13 +
>  drivers/usb/gadget/Kconfig       |    3 +
>  13 files changed, 1890 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/target/uasp/Kconfig
>  create mode 100644 drivers/target/uasp/Makefile
>  create mode 100644 drivers/target/uasp/base.h
>  create mode 100644 drivers/target/uasp/configfs.c
>  create mode 100644 drivers/target/uasp/configfs.h
>  create mode 100644 drivers/target/uasp/fabric.c
>  create mode 100644 drivers/target/uasp/fabric.h
>  create mode 100644 drivers/target/uasp/gadget.c
>  create mode 100644 drivers/target/uasp/gadget.h
>  create mode 100644 drivers/target/uasp/gadget_ops.h
> 

> diff --git a/drivers/target/uasp/fabric.c b/drivers/target/uasp/fabric.c
> new file mode 100644
> index 0000000..7f16709
> --- /dev/null
> +++ b/drivers/target/uasp/fabric.c
> @@ -0,0 +1,407 @@
> +#include <linux/slab.h>
> +#include <linux/kthread.h>
> +#include <linux/types.h>
> +#include <linux/list.h>
> +#include <linux/types.h>
> +#include <linux/string.h>
> +#include <linux/ctype.h>
> +#include <asm/unaligned.h>
> +#include <scsi/scsi.h>
> +#include <scsi/scsi_host.h>
> +#include <scsi/scsi_device.h>
> +#include <scsi/scsi_cmnd.h>
> +#include <scsi/libfc.h>
> +#include <scsi/scsi_tcq.h>
> +
> +#include <target/target_core_base.h>
> +#include <target/target_core_fabric.h>
> +#include <target/target_core_configfs.h>
> +
> +#include "base.h"
> +#include "fabric.h"
> +#include "gadget_ops.h"
> +#include "gadget.h"
> +
> +#define UAS_SIMPLE_TAG		0
> +#define UAS_HEAD_TAG		1
> +#define UAS_ORDERED_TAG		2
> +#define UAS_ACA			4
> +
> +extern struct uasp_tpg *the_only_tpg_I_currently_have;
> +
> +void uasp_submit_command(struct f_uas *fu, void *cmdbuf, unsigned int len)
> +{
> +	struct command_iu *cmd_iu = cmdbuf;
> +	struct uasp_cmd *cmd;
> +	struct uasp_tpg *tpg;
> +	struct se_session *se_sess;
> +	struct se_cmd *se_cmd;
> +	struct tcm_uasp_nexus *tv_nexus;
> +	u32 cmd_len;
> +	u32 prio;
> +	u32 unpacked_lun;
> +	int ret;
> +
> +	if (cmd_iu->iu_id != IU_ID_COMMAND) {
> +		pr_err("Unsupported type %d\n", cmd_iu->iu_id);
> +		return;
> +	}
> +
> +	cmd = kzalloc(sizeof *cmd, GFP_ATOMIC);
> +	if (!cmd)
> +		return;
> +
> +	cmd->fu = fu;
> +
> +	/* XXX until I figure out why I can't free in on complete */
> +	kref_init(&cmd->ref);
> +	kref_get(&cmd->ref);
> +
> +	tpg = the_only_tpg_I_currently_have;
> +

Mmmmm, not so good a setup for multiple endpoints.. ;)

Generally a fabric should make se_portal_group usage embedded into a
fabric dependent struct like uasp_tpg->se_tpg that is registered within
target_core_fabric_configfs.c generic callers.  A few fabrics use
target_core_fabric_ops->fabric_make_tpg() caller to walk an list of
entries that may be pre-registered for usage for the specific fabric
driver, and enabled during ->fabric_make_tpg() or ->fabric_make_wwn()
(eg: gadgets to register with tcm_uasp and enable gadget_connect)

So using a usb gadget list that is available to tcm_uasp at configfs
uasp_make_tpg() + uasp_drop_tpg() time is one option.  The other option
is to add a fabric endpoint specific pointer for each usb gadget that is
setup during uasp_make_tpg() (or gadget_connect) which is available for
uasp_submit_cmd() I/O path code usage.

--nab


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux