diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-10-29 18:17:40 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-10-29 18:17:40 +0000 |
commit | 4816cdd619ff485d8a4b102aad4f40afa2f0b1ea (patch) | |
tree | 87ae162df693d2ed5c420115ea9301f585732e9f /sys | |
parent | 28daa884f67e95188a814f1592f95f9b7627f0a1 (diff) |
rearrange the function layout a bit
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/pci/if_oce.c | 4 | ||||
-rw-r--r-- | sys/dev/pci/oce.c | 160 | ||||
-rw-r--r-- | sys/dev/pci/ocevar.h | 8 |
3 files changed, 86 insertions, 86 deletions
diff --git a/sys/dev/pci/if_oce.c b/sys/dev/pci/if_oce.c index 08a942c0031..1603b3abc39 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.31 2012/10/29 18:14:28 mikeb Exp $ */ +/* $OpenBSD: if_oce.c,v 1.32 2012/10/29 18:17:39 mikeb Exp $ */ /* * Copyright (c) 2012 Mike Belopuhov @@ -254,7 +254,7 @@ oce_attach(struct device *parent, struct device *self, void *aux) } else sc->be3_native = 0; - if (oce_read_macaddr(sc, sc->macaddr)) { + if (oce_macaddr_get(sc, sc->macaddr)) { printf(": failed to fetch MAC address\n"); goto fail_1; } diff --git a/sys/dev/pci/oce.c b/sys/dev/pci/oce.c index 3fa05945078..8297a223905 100644 --- a/sys/dev/pci/oce.c +++ b/sys/dev/pci/oce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: oce.c,v 1.20 2012/10/29 18:14:28 mikeb Exp $ */ +/* $OpenBSD: oce.c,v 1.21 2012/10/29 18:17:39 mikeb Exp $ */ /* * Copyright (c) 2012 Mike Belopuhov @@ -158,76 +158,6 @@ oce_init_fw(struct oce_softc *sc) return (ENXIO); } -/** - * @brief Function for creating a network interface. - * @param sc software handle to the device - * @returns 0 on success, error otherwise - */ -int -oce_create_iface(struct oce_softc *sc, uint8_t *macaddr) -{ - struct mbx_create_common_iface fwcmd; - uint32_t capab_flags, capab_en_flags; - int err = 0; - - /* interface capabilities to give device when creating interface */ - capab_flags = OCE_CAPAB_FLAGS; - - /* capabilities to enable by default (others set dynamically) */ - capab_en_flags = OCE_CAPAB_ENABLE; - - if (IS_XE201(sc)) { - /* LANCER A0 workaround */ - capab_en_flags &= ~MBX_RX_IFACE_FLAGS_PASS_L3L4_ERR; - capab_flags &= ~MBX_RX_IFACE_FLAGS_PASS_L3L4_ERR; - } - - /* enable capabilities controlled via driver startup parameters */ - if (sc->rss_enable) - capab_en_flags |= MBX_RX_IFACE_FLAGS_RSS; - else { - capab_en_flags &= ~MBX_RX_IFACE_FLAGS_RSS; - capab_flags &= ~MBX_RX_IFACE_FLAGS_RSS; - } - - bzero(&fwcmd, sizeof(fwcmd)); - - fwcmd.params.req.version = 0; - fwcmd.params.req.cap_flags = htole32(capab_flags); - fwcmd.params.req.enable_flags = htole32(capab_en_flags); - if (macaddr != NULL) { - bcopy(macaddr, &fwcmd.params.req.mac_addr[0], ETH_ADDR_LEN); - fwcmd.params.req.mac_invalid = 0; - } else - fwcmd.params.req.mac_invalid = 1; - - err = oce_fw(sc, MBX_SUBSYSTEM_COMMON, OPCODE_COMMON_CREATE_IFACE, - OCE_MBX_VER_V0, &fwcmd, sizeof(fwcmd)); - if (err) - return (err); - - sc->if_id = letoh32(fwcmd.params.rsp.if_id); - - if (macaddr != NULL) - sc->pmac_id = letoh32(fwcmd.params.rsp.pmac_id); - - sc->nifs++; - - sc->if_cap_flags = capab_en_flags; - - /* Enable VLAN Promisc on HW */ - err = oce_config_vlan(sc, (uint8_t)sc->if_id, NULL, 0, 1, 1); - if (err) - return (err); - - /* set default flow control */ - err = oce_set_flow_control(sc, sc->flow_control); - if (err) - return (err); - - return 0; -} - static inline int oce_mbox_wait(struct oce_softc *sc) { @@ -405,22 +335,74 @@ oce_first_mcc(struct oce_softc *sc) OCE_WRITE_REG32(sc, db, PD_MQ_DB, reg_value); } +/** + * @brief Function for creating a network interface. + * @param sc software handle to the device + * @returns 0 on success, error otherwise + */ int -oce_read_macaddr(struct oce_softc *sc, uint8_t *macaddr) +oce_create_iface(struct oce_softc *sc, uint8_t *macaddr) { - struct mbx_query_common_iface_mac fwcmd; - int err; + struct mbx_create_common_iface fwcmd; + uint32_t capab_flags, capab_en_flags; + int err = 0; + + /* interface capabilities to give device when creating interface */ + capab_flags = OCE_CAPAB_FLAGS; + + /* capabilities to enable by default (others set dynamically) */ + capab_en_flags = OCE_CAPAB_ENABLE; + + if (IS_XE201(sc)) { + /* LANCER A0 workaround */ + capab_en_flags &= ~MBX_RX_IFACE_FLAGS_PASS_L3L4_ERR; + capab_flags &= ~MBX_RX_IFACE_FLAGS_PASS_L3L4_ERR; + } + + /* enable capabilities controlled via driver startup parameters */ + if (sc->rss_enable) + capab_en_flags |= MBX_RX_IFACE_FLAGS_RSS; + else { + capab_en_flags &= ~MBX_RX_IFACE_FLAGS_RSS; + capab_flags &= ~MBX_RX_IFACE_FLAGS_RSS; + } bzero(&fwcmd, sizeof(fwcmd)); - fwcmd.params.req.type = MAC_ADDRESS_TYPE_NETWORK; - fwcmd.params.req.permanent = 1; + fwcmd.params.req.version = 0; + fwcmd.params.req.cap_flags = htole32(capab_flags); + fwcmd.params.req.enable_flags = htole32(capab_en_flags); + if (macaddr != NULL) { + bcopy(macaddr, &fwcmd.params.req.mac_addr[0], ETH_ADDR_LEN); + fwcmd.params.req.mac_invalid = 0; + } else + fwcmd.params.req.mac_invalid = 1; - err = oce_fw(sc, MBX_SUBSYSTEM_COMMON, OPCODE_COMMON_QUERY_IFACE_MAC, + err = oce_fw(sc, MBX_SUBSYSTEM_COMMON, OPCODE_COMMON_CREATE_IFACE, OCE_MBX_VER_V0, &fwcmd, sizeof(fwcmd)); - if (err == 0) - bcopy(&fwcmd.params.rsp.mac.mac_addr[0], macaddr, ETH_ADDR_LEN); - return (err); + if (err) + return (err); + + sc->if_id = letoh32(fwcmd.params.rsp.if_id); + + if (macaddr != NULL) + sc->pmac_id = letoh32(fwcmd.params.rsp.pmac_id); + + sc->nifs++; + + sc->if_cap_flags = capab_en_flags; + + /* Enable VLAN Promisc on HW */ + err = oce_config_vlan(sc, (uint8_t)sc->if_id, NULL, 0, 1, 1); + if (err) + return (err); + + /* set default flow control */ + err = oce_set_flow_control(sc, sc->flow_control); + if (err) + return (err); + + return 0; } /** @@ -630,6 +612,24 @@ oce_get_link_status(struct oce_softc *sc) } int +oce_macaddr_get(struct oce_softc *sc, uint8_t *macaddr) +{ + struct mbx_query_common_iface_mac fwcmd; + int err; + + bzero(&fwcmd, sizeof(fwcmd)); + + fwcmd.params.req.type = MAC_ADDRESS_TYPE_NETWORK; + fwcmd.params.req.permanent = 1; + + err = oce_fw(sc, MBX_SUBSYSTEM_COMMON, OPCODE_COMMON_QUERY_IFACE_MAC, + OCE_MBX_VER_V0, &fwcmd, sizeof(fwcmd)); + if (err == 0) + bcopy(&fwcmd.params.rsp.mac.mac_addr[0], macaddr, ETH_ADDR_LEN); + return (err); +} + +int oce_macaddr_add(struct oce_softc *sc, uint8_t *enaddr, uint32_t if_id, uint32_t *pmac_id) { diff --git a/sys/dev/pci/ocevar.h b/sys/dev/pci/ocevar.h index 89532efc935..c750fadc53a 100644 --- a/sys/dev/pci/ocevar.h +++ b/sys/dev/pci/ocevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ocevar.h,v 1.22 2012/10/29 18:14:28 mikeb Exp $ */ +/* $OpenBSD: ocevar.h,v 1.23 2012/10/29 18:17:39 mikeb Exp $ */ /*- * Copyright (C) 2012 Emulex @@ -604,11 +604,11 @@ int oce_get_link_status(struct oce_softc *sc); int oce_set_promisc(struct oce_softc *sc, int enable); int oce_config_rss(struct oce_softc *sc, uint32_t if_id, int enable); -int oce_macaddr_del(struct oce_softc *sc, uint32_t if_id, - uint32_t pmac_id); +int oce_macaddr_get(struct oce_softc *sc, uint8_t *macaddr); int oce_macaddr_add(struct oce_softc *sc, uint8_t *macaddr, uint32_t if_id, uint32_t *pmac_id); -int oce_read_macaddr(struct oce_softc *sc, uint8_t *macaddr); +int oce_macaddr_del(struct oce_softc *sc, uint32_t if_id, + uint32_t pmac_id); int oce_new_rq(struct oce_softc *sc, struct oce_rq *rq); int oce_new_wq(struct oce_softc *sc, struct oce_wq *wq); |