summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2012-11-26 18:58:12 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2012-11-26 18:58:12 +0000
commit75842bec12d2546540fc8fcc84450f5365488da8 (patch)
treef422d0826e97197dc4ebd9564f0a6d598e1b0676 /sys/dev
parentc5220012e8296faf338bb2219123f42d7f7600f8 (diff)
get rid of some useless bitfields in oce_mbx and mbx_hdr
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_oce.c55
-rw-r--r--sys/dev/pci/if_ocereg.h175
2 files changed, 70 insertions, 160 deletions
diff --git a/sys/dev/pci/if_oce.c b/sys/dev/pci/if_oce.c
index 45c0ab1fc3f..1df506e0f8e 100644
--- a/sys/dev/pci/if_oce.c
+++ b/sys/dev/pci/if_oce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_oce.c,v 1.64 2012/11/23 18:46:03 mikeb Exp $ */
+/* $OpenBSD: if_oce.c,v 1.65 2012/11/26 18:58:11 mikeb Exp $ */
/*
* Copyright (c) 2012 Mike Belopuhov
@@ -452,7 +452,7 @@ struct oce_ring *
oce_create_ring(struct oce_softc *, int nitems, int isize, int maxseg);
void oce_destroy_ring(struct oce_softc *, struct oce_ring *);
int oce_load_ring(struct oce_softc *, struct oce_ring *,
- struct phys_addr *, int max_segs);
+ struct oce_pa *, int max_segs);
static inline void *
oce_ring_get(struct oce_ring *);
static inline void *
@@ -950,7 +950,6 @@ oce_iff(struct oce_softc *sc)
oce_set_promisc(sc, promisc);
}
-
void
oce_link_status(struct oce_softc *sc)
{
@@ -2583,7 +2582,7 @@ oce_destroy_ring(struct oce_softc *sc, struct oce_ring *ring)
int
oce_load_ring(struct oce_softc *sc, struct oce_ring *ring,
- struct phys_addr *pa_list, int maxsegs)
+ struct oce_pa *pa, int maxsegs)
{
struct oce_dma_mem *dma = &ring->dma;
int i;
@@ -2595,17 +2594,15 @@ oce_load_ring(struct oce_softc *sc, struct oce_ring *ring,
}
if (dma->map->dm_nsegs > maxsegs) {
- printf("%s: too many segments", sc->sc_dev.dv_xname);
+ printf("%s: too many segments\n", sc->sc_dev.dv_xname);
return (0);
}
bus_dmamap_sync(dma->tag, dma->map, 0, dma->map->dm_mapsize,
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
- for (i = 0; i < dma->map->dm_nsegs; i++) {
- pa_list[i].lo = ADDR_LO(dma->map->dm_segs[i].ds_addr);
- pa_list[i].hi = ADDR_HI(dma->map->dm_segs[i].ds_addr);
- }
+ for (i = 0; i < dma->map->dm_nsegs; i++)
+ pa[i].addr = dma->map->dm_segs[i].ds_addr;
return (dma->map->dm_nsegs);
}
@@ -2828,26 +2825,26 @@ oce_cmd(struct oce_softc *sc, int subsys, int opcode, int version,
mbx->payload_length = length;
if (epayload) {
- mbx->u0.s.sge_count = 1;
+ mbx->flags = OCE_MBX_F_SGE;
oce_dma_sync(&sc->sc_pld, BUS_DMASYNC_PREREAD);
bcopy(payload, epayload, length);
- mbx->payload.u0.u1.sgl[0].paddr = OCE_MEM_DVA(&sc->sc_pld);
- mbx->payload.u0.u1.sgl[0].length = length;
+ mbx->pld.sgl[0].addr = OCE_MEM_DVA(&sc->sc_pld);
+ mbx->pld.sgl[0].length = length;
hdr = (struct mbx_hdr *)epayload;
} else {
- mbx->u0.s.embedded = 1;
- bcopy(payload, &mbx->payload, length);
- hdr = (struct mbx_hdr *)&mbx->payload;
+ mbx->flags = OCE_MBX_F_EMBED;
+ bcopy(payload, mbx->pld.data, length);
+ hdr = (struct mbx_hdr *)&mbx->pld.data;
}
- hdr->u0.req.opcode = opcode;
- hdr->u0.req.subsystem = subsys;
- hdr->u0.req.request_length = length - sizeof(*hdr);
- hdr->u0.req.version = version;
+ hdr->subsys = subsys;
+ hdr->opcode = opcode;
+ hdr->version = version;
+ hdr->length = length - sizeof(*hdr);
if (opcode == OPCODE_COMMON_FUNCTION_RESET)
- hdr->u0.req.timeout = 2 * OCE_MBX_TIMEOUT;
+ hdr->timeout = 2 * OCE_MBX_TIMEOUT;
else
- hdr->u0.req.timeout = OCE_MBX_TIMEOUT;
+ hdr->timeout = OCE_MBX_TIMEOUT;
if (epayload)
oce_dma_sync(&sc->sc_pld, BUS_DMASYNC_PREWRITE);
@@ -2858,7 +2855,7 @@ oce_cmd(struct oce_softc *sc, int subsys, int opcode, int version,
oce_dma_sync(&sc->sc_pld, BUS_DMASYNC_POSTWRITE);
bcopy(epayload, payload, length);
} else
- bcopy(&mbx->payload, payload, length);
+ bcopy(&mbx->pld.data, payload, length);
} else
printf("%s: mailbox timeout, subsys %d op %d ver %d "
"%spayload lenght %d\n", sc->sc_dev.dv_xname, subsys,
@@ -2885,16 +2882,16 @@ oce_first_mcc(struct oce_softc *sc)
mbx = oce_ring_get(mq->ring);
bzero(mbx, sizeof(struct oce_mbx));
- cmd = (struct mbx_get_common_fw_version *)&mbx->payload;
+ cmd = (struct mbx_get_common_fw_version *)&mbx->pld.data;
hdr = &cmd->hdr;
- hdr->u0.req.subsystem = SUBSYS_COMMON;
- hdr->u0.req.opcode = OPCODE_COMMON_GET_FW_VERSION;
- hdr->u0.req.version = OCE_MBX_VER_V0;
- hdr->u0.req.timeout = OCE_MBX_TIMEOUT;
- hdr->u0.req.request_length = sizeof(*cmd) - sizeof(*hdr);
+ hdr->subsys = SUBSYS_COMMON;
+ hdr->opcode = OPCODE_COMMON_GET_FW_VERSION;
+ hdr->version = OCE_MBX_VER_V0;
+ hdr->timeout = OCE_MBX_TIMEOUT;
+ hdr->length = sizeof(*cmd) - sizeof(*hdr);
- mbx->u0.s.embedded = 1;
+ mbx->flags = OCE_MBX_F_EMBED;
mbx->payload_length = sizeof(*cmd);
oce_dma_sync(&mq->ring->dma, BUS_DMASYNC_PREREAD |
BUS_DMASYNC_PREWRITE);
diff --git a/sys/dev/pci/if_ocereg.h b/sys/dev/pci/if_ocereg.h
index 2accfe78e24..e9fdbc9b201 100644
--- a/sys/dev/pci/if_ocereg.h
+++ b/sys/dev/pci/if_ocereg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ocereg.h,v 1.5 2012/11/09 15:38:47 mikeb Exp $ */
+/* $OpenBSD: if_ocereg.h,v 1.6 2012/11/26 18:58:11 mikeb Exp $ */
/*-
* Copyright (C) 2012 Emulex
@@ -158,68 +158,43 @@
#define PD_MPU_MBOX_DB_HI (1<<1)
#define PD_MPU_MBOX_DB_ADDR_SHIFT 2
-/* physical address structure to be used in MBX */
-struct phys_addr {
- /* dw0 */
- uint32_t lo;
- /* dw1 */
- uint32_t hi;
+struct oce_pa {
+ uint64_t addr;
} __packed;
-/*
- * Event Queue Entry
- */
-struct oce_eqe {
- uint32_t evnt;
-} __packed;
-
-/* MQ scatter gather entry. Array of these make an SGL */
-struct oce_mq_sge {
- uint64_t paddr;
- uint32_t length;
+struct oce_sge {
+ uint64_t addr;
+ uint32_t length;
} __packed;
-/*
- * payload can contain an SGL or an embedded array of upto 59 dwords
- */
-#define OCE_MBX_PAYLOAD 236
-struct oce_mbx_payload {
- union {
- union {
- struct oce_mq_sge sgl[MAX_MBX_SGE];
- uint8_t embedded[OCE_MBX_PAYLOAD];
- } u1;
- uint32_t dw[OCE_MBX_PAYLOAD / 4];
- } u0;
-} __packed;
+struct mbx_hdr {
+ uint8_t opcode;
+ uint8_t subsys;
+ uint8_t port;
+ uint8_t domain;
+ uint32_t timeout;
+ uint32_t length;
+ uint8_t version;
+#define OCE_MBX_VER_V2 0x0002
+#define OCE_MBX_VER_V1 0x0001
+#define OCE_MBX_VER_V0 0x0000
+ uint8_t _rsvd[3];
+} __packed;
+
+/* payload can contain an SGL or an embedded array of upto 59 dwords */
+#define OCE_MBX_PAYLOAD (59 * 4)
-/*
- * MQ MBX structure
- */
struct oce_mbx {
+ uint32_t flags;
+#define OCE_MBX_F_EMBED (1<<0)
+#define OCE_MBX_F_SGE (1<<3)
+ uint32_t payload_length;
+ uint32_t tag[2];
+ uint32_t _rsvd;
union {
- struct {
-#if _BYTE_ORDER == BIG_ENDIAN
- uint32_t special:8;
- uint32_t rsvd1:16;
- uint32_t sge_count:5;
- uint32_t rsvd0:2;
- uint32_t embedded:1;
-#else
- uint32_t embedded:1;
- uint32_t rsvd0:2;
- uint32_t sge_count:5;
- uint32_t rsvd1:16;
- uint32_t special:8;
-#endif
- } s;
- uint32_t dw0;
- } u0;
-
- uint32_t payload_length;
- uint32_t tag[2];
- uint32_t rsvd2[1];
- struct oce_mbx_payload payload;
+ struct oce_sge sgl[MAX_MBX_SGE];
+ uint8_t data[OCE_MBX_PAYLOAD];
+ } pld;
} __packed;
/* completion queue entry for MQ */
@@ -504,75 +479,6 @@ enum COMMON_SUBSYS_OPCODES {
OPCODE_COMMON_WRITE_OBJECT = 172
};
-/* common ioctl header */
-#define OCE_MBX_VER_V2 0x0002 /* Version V2 mailbox command */
-#define OCE_MBX_VER_V1 0x0001 /* Version V1 mailbox command */
-#define OCE_MBX_VER_V0 0x0000 /* Version V0 mailbox command */
-struct mbx_hdr {
- union {
- uint32_t dw[4];
- struct {
-#if _BYTE_ORDER == BIG_ENDIAN
- /* dw 0 */
- uint32_t domain:8;
- uint32_t port_number:8;
- uint32_t subsystem:8;
- uint32_t opcode:8;
- /* dw 1 */
- uint32_t timeout;
- /* dw 2 */
- uint32_t request_length;
- /* dw 3 */
- uint32_t rsvd0:24;
- uint32_t version:8;
-#else
- /* dw 0 */
- uint32_t opcode:8;
- uint32_t subsystem:8;
- uint32_t port_number:8;
- uint32_t domain:8;
- /* dw 1 */
- uint32_t timeout;
- /* dw 2 */
- uint32_t request_length;
- /* dw 3 */
- uint32_t version:8;
- uint32_t rsvd0:24;
-#endif
- } req;
- struct {
-#if _BYTE_ORDER == BIG_ENDIAN
- /* dw 0 */
- uint32_t domain:8;
- uint32_t rsvd0:8;
- uint32_t subsystem:8;
- uint32_t opcode:8;
- /* dw 1 */
- uint32_t rsvd1:16;
- uint32_t additional_status:8;
- uint32_t status:8;
-#else
- /* dw 0 */
- uint32_t opcode:8;
- uint32_t subsystem:8;
- uint32_t rsvd0:8;
- uint32_t domain:8;
- /* dw 1 */
- uint32_t status:8;
- uint32_t additional_status:8;
- uint32_t rsvd1:16;
-#endif
- uint32_t rsp_length;
- uint32_t actual_rsp_length;
- } rsp;
- } u0;
-} __packed;
-
-#define OCE_BMBX_RHDR_SZ 20
-#define OCE_MBX_RRHDR_SZ sizeof (struct mbx_hdr)
-#define OCE_MBX_ADDL_STATUS(_MHDR) ((_MHDR)->u0.rsp.additional_status)
-#define OCE_MBX_STATUS(_MHDR) ((_MHDR)->u0.rsp.status)
-
/* [05] OPCODE_COMMON_QUERY_LINK_CONFIG */
struct mbx_query_common_link_config {
struct mbx_hdr hdr;
@@ -761,6 +667,13 @@ struct mbx_destroy_common_iface {
} params;
} __packed;
+/*
+ * Event Queue Entry
+ */
+struct oce_eqe {
+ uint32_t evnt;
+} __packed;
+
/* event queue context structure */
struct oce_eq_ctx {
#if _BYTE_ORDER == BIG_ENDIAN
@@ -810,7 +723,7 @@ struct mbx_create_common_eq {
union {
struct {
struct oce_eq_ctx ctx;
- struct phys_addr pages[8];
+ struct oce_pa pages[8];
} req;
struct {
@@ -943,7 +856,7 @@ struct mbx_create_common_cq {
union {
struct {
union oce_cq_ctx cq_ctx;
- struct phys_addr pages[4];
+ struct oce_pa pages[4];
} req;
struct {
@@ -1024,7 +937,7 @@ struct mbx_create_common_mq {
union {
struct {
union oce_mq_ctx context;
- struct phys_addr pages[8];
+ struct oce_pa pages[8];
} req;
struct {
@@ -1039,7 +952,7 @@ struct mbx_create_common_mq_ex {
union {
struct {
union oce_mq_ext_ctx context;
- struct phys_addr pages[8];
+ struct oce_pa pages[8];
} req;
struct {
@@ -2094,7 +2007,7 @@ struct mbx_create_nic_wq {
uint16_t cq_id;
uint16_t rsvd3;
uint32_t rsvd4[13];
- struct phys_addr pages[8];
+ struct oce_pa pages[8];
} req;
struct {
@@ -2136,7 +2049,7 @@ struct mbx_create_nic_rq {
uint16_t cq_id;
uint8_t frag_size;
uint8_t num_pages;
- struct phys_addr pages[2];
+ struct oce_pa pages[2];
uint32_t if_id;
uint16_t max_frame_size;
uint16_t page_size;