diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-11-09 18:53:05 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2012-11-09 18:53:05 +0000 |
commit | af84905fb288b26508e29f92a916cfbfc3b876a0 (patch) | |
tree | 95611c9d13fb4bf1deaef88036a56a58217e732e /sys/dev | |
parent | 20035e93e475bfa5a20258dd5246e801b7ff8351 (diff) |
improve flow control code
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/if_oce.c | 42 | ||||
-rw-r--r-- | sys/dev/pci/if_ocevar.h | 10 |
2 files changed, 29 insertions, 23 deletions
diff --git a/sys/dev/pci/if_oce.c b/sys/dev/pci/if_oce.c index 4300b3b087b..541505a3d0b 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.50 2012/11/09 18:40:12 mikeb Exp $ */ +/* $OpenBSD: if_oce.c,v 1.51 2012/11/09 18:53:04 mikeb Exp $ */ /* * Copyright (c) 2012 Mike Belopuhov @@ -215,7 +215,7 @@ int oce_check_native_mode(struct oce_softc *sc); int oce_create_iface(struct oce_softc *sc, uint8_t *macaddr); int oce_config_vlan(struct oce_softc *sc, struct normal_vlan *vtags, int nvtags, int untagged, int promisc); -int oce_set_flow_control(struct oce_softc *sc, uint32_t flow_control); +int oce_set_flow_control(struct oce_softc *sc, uint flags); int oce_config_rss(struct oce_softc *sc, uint32_t if_id, int enable); int oce_update_mcast(struct oce_softc *sc, uint8_t multi[][ETHER_ADDR_LEN], int naddr); @@ -298,7 +298,6 @@ oce_attach(struct device *parent, struct device *self, void *aux) sc->tx_ring_size = OCE_TX_RING_SIZE; sc->rx_ring_size = OCE_RX_RING_SIZE; sc->rx_frag_size = OCE_RQ_BUF_SIZE; - sc->flow_control = OCE_FC_TX | OCE_FC_RX; /* create the bootstrap mailbox */ if (oce_dma_alloc(sc, sizeof(struct oce_bmbx), &sc->bsmbx)) { @@ -797,10 +796,10 @@ oce_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) break; } - if (sc->flow_control & OCE_FC_TX) - ifmr->ifm_active |= IFM_FLOW | IFM_ETH_TXPAUSE; - if (sc->flow_control & OCE_FC_RX) + if (sc->flow_flags & IFM_ETH_RXPAUSE) ifmr->ifm_active |= IFM_FLOW | IFM_ETH_RXPAUSE; + if (sc->flow_flags & IFM_ETH_TXPAUSE) + ifmr->ifm_active |= IFM_FLOW | IFM_ETH_TXPAUSE; } int @@ -1564,7 +1563,7 @@ oce_init(void *arg) if (oce_config_vlan(sc, NULL, 0, 1, 1)) goto error; - if (oce_set_flow_control(sc, sc->flow_control)) + if (oce_set_flow_control(sc, IFM_ETH_RXPAUSE | IFM_ETH_TXPAUSE)) goto error; for_all_rq_queues(sc, rq, i) { @@ -2788,23 +2787,36 @@ oce_config_vlan(struct oce_softc *sc, struct normal_vlan *vtags, int nvtags, /** * @brief Function to set flow control capability in the hardware * @param sc software handle to the device - * @param flow_control flow control flags to set + * @param flags flow control flags to set * @returns 0 on success, EIO on failure */ int -oce_set_flow_control(struct oce_softc *sc, uint32_t flow_control) +oce_set_flow_control(struct oce_softc *sc, uint flags) { struct mbx_common_get_set_flow_control cmd; + int err; bzero(&cmd, sizeof(cmd)); - if (flow_control & OCE_FC_TX) - cmd.tx_flow_control = 1; - if (flow_control & OCE_FC_RX) - cmd.rx_flow_control = 1; + cmd.rx_flow_control = flags & IFM_ETH_RXPAUSE ? 1 : 0; + cmd.tx_flow_control = flags & IFM_ETH_TXPAUSE ? 1 : 0; - return (oce_cmd(sc, SUBSYS_COMMON, OPCODE_COMMON_SET_FLOW_CONTROL, - OCE_MBX_VER_V0, &cmd, sizeof(cmd))); + err = oce_cmd(sc, SUBSYS_COMMON, OPCODE_COMMON_SET_FLOW_CONTROL, + OCE_MBX_VER_V0, &cmd, sizeof(cmd)); + if (err) + return (err); + + bzero(&cmd, sizeof(cmd)); + + err = oce_cmd(sc, SUBSYS_COMMON, OPCODE_COMMON_GET_FLOW_CONTROL, + OCE_MBX_VER_V0, &cmd, sizeof(cmd)); + if (err) + return (err); + + sc->flow_flags = cmd.rx_flow_control ? IFM_ETH_RXPAUSE : 0; + sc->flow_flags |= cmd.tx_flow_control ? IFM_ETH_TXPAUSE : 0; + + return (0); } #ifdef OCE_RSS diff --git a/sys/dev/pci/if_ocevar.h b/sys/dev/pci/if_ocevar.h index b228a4c6a3f..efad621c94b 100644 --- a/sys/dev/pci/if_ocevar.h +++ b/sys/dev/pci/if_ocevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ocevar.h,v 1.9 2012/11/09 18:40:13 mikeb Exp $ */ +/* $OpenBSD: if_ocevar.h,v 1.10 2012/11/09 18:53:04 mikeb Exp $ */ /*- * Copyright (C) 2012 Emulex @@ -68,11 +68,6 @@ #define OCE_RSS_IPV6 0x4 #define OCE_RSS_TCP_IPV6 0x8 -/* flow control definitions */ -#define OCE_FC_NONE 0x00000000 -#define OCE_FC_TX 0x00000001 -#define OCE_FC_RX 0x00000002 - #define BSWAP_8(x) ((x) & 0xff) #define BSWAP_16(x) ((BSWAP_8(x) << 8) | BSWAP_8((x) >> 8)) #define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16)) @@ -271,6 +266,7 @@ struct oce_softc { struct ifmedia media; ushort link_up; ushort link_speed; + uint flow_flags; struct oce_dma_mem bsmbx; @@ -297,8 +293,6 @@ struct oce_softc { uint32_t pmac_id; /* PMAC id */ char macaddr[ETHER_ADDR_LEN]; - uint32_t flow_control; - uint32_t pvid; uint64_t rx_errors; |