diff options
author | Michael Chan <mchan@broadcom.com> | 2007-05-03 16:24:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-05-03 16:24:23 -0400 |
commit | da3e4fbed21a5d7edab10ffb77a8c04a725f9eff (patch) | |
tree | be2adcd6a722399d3f1c406b79d372b03bfb9f08 /drivers | |
parent | 1b8227c48e164655f02aa0eff55862af2d05da51 (diff) |
[BNX2]: Restructure PHY event handling.
Restructure by adding bnx2_phy_event_is_set() to make code cleaner
and easier to understand.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bnx2.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index cb74f122138c..f072028e3e3b 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -1942,25 +1942,33 @@ bnx2_alloc_rx_skb(struct bnx2 *bp, u16 index) | |||
1942 | return 0; | 1942 | return 0; |
1943 | } | 1943 | } |
1944 | 1944 | ||
1945 | static void | 1945 | static int |
1946 | bnx2_phy_int(struct bnx2 *bp) | 1946 | bnx2_phy_event_is_set(struct bnx2 *bp, u32 event) |
1947 | { | 1947 | { |
1948 | struct status_block *sblk = bp->status_blk; | ||
1948 | u32 new_link_state, old_link_state; | 1949 | u32 new_link_state, old_link_state; |
1950 | int is_set = 1; | ||
1949 | 1951 | ||
1950 | new_link_state = bp->status_blk->status_attn_bits & | 1952 | new_link_state = sblk->status_attn_bits & event; |
1951 | STATUS_ATTN_BITS_LINK_STATE; | 1953 | old_link_state = sblk->status_attn_bits_ack & event; |
1952 | old_link_state = bp->status_blk->status_attn_bits_ack & | ||
1953 | STATUS_ATTN_BITS_LINK_STATE; | ||
1954 | if (new_link_state != old_link_state) { | 1954 | if (new_link_state != old_link_state) { |
1955 | if (new_link_state) { | 1955 | if (new_link_state) |
1956 | REG_WR(bp, BNX2_PCICFG_STATUS_BIT_SET_CMD, | 1956 | REG_WR(bp, BNX2_PCICFG_STATUS_BIT_SET_CMD, event); |
1957 | STATUS_ATTN_BITS_LINK_STATE); | 1957 | else |
1958 | } | 1958 | REG_WR(bp, BNX2_PCICFG_STATUS_BIT_CLEAR_CMD, event); |
1959 | else { | 1959 | } else |
1960 | REG_WR(bp, BNX2_PCICFG_STATUS_BIT_CLEAR_CMD, | 1960 | is_set = 0; |
1961 | STATUS_ATTN_BITS_LINK_STATE); | 1961 | |
1962 | } | 1962 | return is_set; |
1963 | } | ||
1964 | |||
1965 | static void | ||
1966 | bnx2_phy_int(struct bnx2 *bp) | ||
1967 | { | ||
1968 | if (bnx2_phy_event_is_set(bp, STATUS_ATTN_BITS_LINK_STATE)) { | ||
1969 | spin_lock(&bp->phy_lock); | ||
1963 | bnx2_set_link(bp); | 1970 | bnx2_set_link(bp); |
1971 | spin_unlock(&bp->phy_lock); | ||
1964 | } | 1972 | } |
1965 | } | 1973 | } |
1966 | 1974 | ||
@@ -2283,6 +2291,8 @@ bnx2_interrupt(int irq, void *dev_instance) | |||
2283 | return IRQ_HANDLED; | 2291 | return IRQ_HANDLED; |
2284 | } | 2292 | } |
2285 | 2293 | ||
2294 | #define STATUS_ATTN_EVENTS STATUS_ATTN_BITS_LINK_STATE | ||
2295 | |||
2286 | static inline int | 2296 | static inline int |
2287 | bnx2_has_work(struct bnx2 *bp) | 2297 | bnx2_has_work(struct bnx2 *bp) |
2288 | { | 2298 | { |
@@ -2292,8 +2302,8 @@ bnx2_has_work(struct bnx2 *bp) | |||
2292 | (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)) | 2302 | (sblk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)) |
2293 | return 1; | 2303 | return 1; |
2294 | 2304 | ||
2295 | if ((sblk->status_attn_bits & STATUS_ATTN_BITS_LINK_STATE) != | 2305 | if ((sblk->status_attn_bits & STATUS_ATTN_EVENTS) != |
2296 | (sblk->status_attn_bits_ack & STATUS_ATTN_BITS_LINK_STATE)) | 2306 | (sblk->status_attn_bits_ack & STATUS_ATTN_EVENTS)) |
2297 | return 1; | 2307 | return 1; |
2298 | 2308 | ||
2299 | return 0; | 2309 | return 0; |
@@ -2303,15 +2313,14 @@ static int | |||
2303 | bnx2_poll(struct net_device *dev, int *budget) | 2313 | bnx2_poll(struct net_device *dev, int *budget) |
2304 | { | 2314 | { |
2305 | struct bnx2 *bp = netdev_priv(dev); | 2315 | struct bnx2 *bp = netdev_priv(dev); |
2316 | struct status_block *sblk = bp->status_blk; | ||
2317 | u32 status_attn_bits = sblk->status_attn_bits; | ||
2318 | u32 status_attn_bits_ack = sblk->status_attn_bits_ack; | ||
2306 | 2319 | ||
2307 | if ((bp->status_blk->status_attn_bits & | 2320 | if ((status_attn_bits & STATUS_ATTN_EVENTS) != |
2308 | STATUS_ATTN_BITS_LINK_STATE) != | 2321 | (status_attn_bits_ack & STATUS_ATTN_EVENTS)) { |
2309 | (bp->status_blk->status_attn_bits_ack & | ||
2310 | STATUS_ATTN_BITS_LINK_STATE)) { | ||
2311 | 2322 | ||
2312 | spin_lock(&bp->phy_lock); | ||
2313 | bnx2_phy_int(bp); | 2323 | bnx2_phy_int(bp); |
2314 | spin_unlock(&bp->phy_lock); | ||
2315 | 2324 | ||
2316 | /* This is needed to take care of transient status | 2325 | /* This is needed to take care of transient status |
2317 | * during link changes. | 2326 | * during link changes. |
@@ -3760,7 +3769,7 @@ bnx2_init_chip(struct bnx2 *bp) | |||
3760 | /* Clear internal stats counters. */ | 3769 | /* Clear internal stats counters. */ |
3761 | REG_WR(bp, BNX2_HC_COMMAND, BNX2_HC_COMMAND_CLR_STAT_NOW); | 3770 | REG_WR(bp, BNX2_HC_COMMAND, BNX2_HC_COMMAND_CLR_STAT_NOW); |
3762 | 3771 | ||
3763 | REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_BITS_LINK_STATE); | 3772 | REG_WR(bp, BNX2_HC_ATTN_BITS_ENABLE, STATUS_ATTN_EVENTS); |
3764 | 3773 | ||
3765 | if (REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_FEATURE) & | 3774 | if (REG_RD_IND(bp, bp->shmem_base + BNX2_PORT_FEATURE) & |
3766 | BNX2_PORT_FEATURE_ASF_ENABLED) | 3775 | BNX2_PORT_FEATURE_ASF_ENABLED) |