Commit d48a0455 authored by Alessandro Rubini's avatar Alessandro Rubini

incompatible change: define addr_zio and use it in the control

This adds 4 bytes to the control (there are atill 16 free) to fit
a whole struct addr_zio (same as sockaddr_zio, to be defined when we
merge PF_ZIO). The structure was almost ready for that,
but we missed the sa_family 16-bit field.

This also changes the minor number for the ZIO control structure, and
all the few users of the address-related fields.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
parent d1909061
...@@ -46,6 +46,24 @@ struct zio_ctrl_attr { ...@@ -46,6 +46,24 @@ struct zio_ctrl_attr {
uint32_t ext_val[ZIO_MAX_EXT_ATTR]; uint32_t ext_val[ZIO_MAX_EXT_ATTR];
}; };
/*
* The sockaddr_zio structure is used for PF_ZIO operation. However,
* we don't want to include socket-specific headers here, so just
* know that sa_family is a 16-bit number. For this reason we don't
* call it sockaddr_zio, which will be defined elsewhere with correct types.
* This block of information uniquely identifies the channel.
*/
struct addr_zio {
uint16_t sa_family;
uint8_t host_type; /* 0 == local, 1 == MAC, ... */
uint8_t filler;
uint8_t hostid[8]; /* MAC or other info */
char devname[ZIO_OBJ_NAME_LEN];
uint32_t dev_id; /* Driver-specific id */
uint16_t cset; /* index of channel-set within device */
uint16_t chan; /* index of channel within cset */
};
/* /*
* The following data item is the control structure that is being exchanged * The following data item is the control structure that is being exchanged
* on the control device associated to each data device. The size of each * on the control device associated to each data device. The size of each
...@@ -70,30 +88,25 @@ struct zio_control { ...@@ -70,30 +88,25 @@ struct zio_control {
uint16_t nbits; /* sample-bits: number of valid bits */ uint16_t nbits; /* sample-bits: number of valid bits */
/* byte 20 */ /* byte 20 */
/* This block of information uniquely identifies the channel */ struct addr_zio addr;
uint8_t hostid[8]; /* Macaddress or whatever unique */
char devname[ZIO_OBJ_NAME_LEN];
uint32_t dev_id; /* Driver-specific id */
uint16_t cset_i; /* index of channel-set within device */
uint16_t chan_i; /* index of channel within cset */
/* byte 48 */ /* byte 52 */
struct zio_timestamp tstamp; struct zio_timestamp tstamp;
/* byte 72 */ /* byte 76 */
uint32_t mem_offset; /* position in mmap buffer of this block */ uint32_t mem_offset; /* position in mmap buffer of this block */
uint32_t reserved; /* possibly another offset, or space for 64b */ uint32_t reserved; /* possibly another offset, or space for 64b */
/* byte 80 */ /* byte 84 */
/* Each data block is associated with a trigger and its features */ /* Each data block is associated with a trigger and its features */
char triggername[ZIO_OBJ_NAME_LEN]; char triggername[ZIO_OBJ_NAME_LEN];
/* byte 92 */ /* byte 96 */
struct zio_ctrl_attr attr_channel; struct zio_ctrl_attr attr_channel;
struct zio_ctrl_attr attr_trigger; struct zio_ctrl_attr attr_trigger;
/* byte 492 */ /* byte 496 */
uint8_t __fill_end[ZIO_CONTROL_SIZE - 492]; uint8_t __fill_end[ZIO_CONTROL_SIZE - 496];
}; };
/* The following flags are used in the control structure */ /* The following flags are used in the control structure */
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* ZIO_VERSION: is a zio_class attribute to identify the framework version*/ /* ZIO_VERSION: is a zio_class attribute to identify the framework version*/
#define ZIO_MAJOR_VERSION 0 #define ZIO_MAJOR_VERSION 0
#define ZIO_MINOR_VERSION 5 #define ZIO_MINOR_VERSION 6
#define ZIO_OBJ_NAME_LEN 12 /* name for registered object and ctrl struct */ #define ZIO_OBJ_NAME_LEN 12 /* name for registered object and ctrl struct */
......
...@@ -65,8 +65,8 @@ void read_channel(int cfd, int dfd, FILE *log) ...@@ -65,8 +65,8 @@ void read_channel(int cfd, int dfd, FILE *log)
printf("Ctrl: version %i.%i, trigger %.16s, dev %.16s, " printf("Ctrl: version %i.%i, trigger %.16s, dev %.16s, "
"cset %i, chan %i\n", "cset %i, chan %i\n",
ctrl.major_version, ctrl.minor_version, ctrl.major_version, ctrl.minor_version,
ctrl.triggername, ctrl.devname, ctrl.cset_i, ctrl.triggername, ctrl.addr.devname, ctrl.addr.cset,
ctrl.chan_i); ctrl.addr.chan);
printf("Ctrl: seq %i, n %i, size %i, bits %i, " printf("Ctrl: seq %i, n %i, size %i, bits %i, "
"flags %08x (%s)\n", "flags %08x (%s)\n",
ctrl.seq_num, ctrl.seq_num,
......
...@@ -685,7 +685,7 @@ static int __zattr_chan_init_ctrl(struct zio_channel *chan, unsigned int start) ...@@ -685,7 +685,7 @@ static int __zattr_chan_init_ctrl(struct zio_channel *chan, unsigned int start)
cset = chan->cset; cset = chan->cset;
zdev = cset->zdev; zdev = cset->zdev;
ctrl = chan->current_ctrl; ctrl = chan->current_ctrl;
ctrl->dev_id = chan->cset->zdev->head.dev.id; ctrl->addr.dev_id = chan->cset->zdev->head.dev.id;
ctrl_attr_chan = &chan->current_ctrl->attr_channel; ctrl_attr_chan = &chan->current_ctrl->attr_channel;
if (!(start + chan->zattr_set.n_ext_attr < 32)) { if (!(start + chan->zattr_set.n_ext_attr < 32)) {
pr_err("%s: too many extended attribute in %s", pr_err("%s: too many extended attribute in %s",
...@@ -1680,9 +1680,11 @@ static int chan_register(struct zio_channel *chan, struct zio_channel *chan_t) ...@@ -1680,9 +1680,11 @@ static int chan_register(struct zio_channel *chan, struct zio_channel *chan_t)
err = -EINVAL; /* message already printed */ err = -EINVAL; /* message already printed */
goto out_ctrl_bits; goto out_ctrl_bits;
} }
ctrl->cset_i = chan->cset->index; /* ctrl->addr.family = PF_ZIO */
ctrl->chan_i = chan->index; ctrl->addr.cset = chan->cset->index;
strncpy(ctrl->devname, chan->cset->zdev->head.name, ZIO_OBJ_NAME_LEN); ctrl->addr.chan = chan->index;
strncpy(ctrl->addr.devname, chan->cset->zdev->head.name,
sizeof(ctrl->addr.devname));
ctrl->ssize = chan->cset->ssize; ctrl->ssize = chan->cset->ssize;
/* Trigger instance is already assigned so */ /* Trigger instance is already assigned so */
ctrl->nsamples = ctrl->nsamples =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment