AnsweredAssumed Answered

Problems with UTP on Linux (sg driver)

Question asked by Magnus Therning on Jul 30, 2014
Latest reply on Aug 4, 2014 by Magnus Therning

I've been looking into UTP and am currently trying to experiment with an implementation in Linux.  With a few hints from the source code of Mfg tool and documents in various versions of Mfg tool I've put together the following code to generate a poll command:

struct __attribute__ (( packed )) utp_cmd
{
     uint8_t oc;
     uint8_t cmd;
     uint32_t tag;
     uint64_t lparam;
     uint8_t res[2];
};
struct utp_cmd poll =
{
     .oc = 0xf0,
     .cmd = 0x00,
     .tag = 0x1,
     .lparam = 0,
};

I then put together the data to pass to sg like this:

uint8_t sbuf[128];
struct sg_io_hdr scsi_hdr = {
    .interface_id = 'S',
    .timeout = 2000,

    .cmdp = (unsigned char *)&poll,
    .cmd_len = sizeof(struct utp_cmd),

    .sbp = sbuf,
    .mx_sb_len = 128,

    .dxfer_direction = SG_DXFER_TO_DEV,
};

Then I pass it all off to sg like this:

int res = ioctl(dev, SG_IO, &scsi_hdr);

This fails though though with the rather cryptic error "Bad address" (errno set to 14).  Anyone who's encountered this and solved it already?

Outcomes