From 288379f050284087578b77e04f040b57db3db3f8 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 19 Jan 2009 16:43:59 -0800 Subject: net: Remove redundant NAPI functions Following the removal of the unused struct net_device * parameter from the NAPI functions named *netif_rx_* in commit 908a7a1, they are exactly equivalent to the corresponding *napi_* functions and are therefore redundant. Signed-off-by: Ben Hutchings Acked-by: Neil Horman Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index d854f07ef4d..1139e637f5d 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -1631,7 +1631,7 @@ static int netxen_nic_poll(struct napi_struct *napi, int budget) } if ((work_done < budget) && tx_complete) { - netif_rx_complete(&adapter->napi); + napi_complete(&adapter->napi); netxen_nic_enable_int(adapter); } -- cgit v1.2.3-70-g09d2 From 09640e6365c679b5642b1c41b6d7078f51689ddf Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sun, 1 Feb 2009 00:45:17 -0800 Subject: net: replace uses of __constant_{endian} Base versions handle constant folding now. Signed-off-by: Harvey Harrison Signed-off-by: David S. Miller --- drivers/net/arcnet/arc-rawmode.c | 2 +- drivers/net/arcnet/capmode.c | 4 ++-- drivers/net/bonding/bond_3ad.h | 2 +- drivers/net/bonding/bond_alb.c | 4 ++-- drivers/net/e1000/e1000_main.c | 4 ++-- drivers/net/e1000e/netdev.c | 4 ++-- drivers/net/enic/enic_main.c | 4 ++-- drivers/net/hamachi.c | 8 ++++---- drivers/net/hamradio/bpqether.c | 2 +- drivers/net/igb/igb_main.c | 4 ++-- drivers/net/ixgbe/ixgbe_main.c | 4 ++-- drivers/net/myri_sbus.c | 2 +- drivers/net/netxen/netxen_nic_main.c | 8 ++++---- drivers/net/niu.c | 4 ++-- drivers/net/pppoe.c | 8 ++++---- drivers/net/ps3_gelic_net.c | 2 +- drivers/net/sfc/bitfield.h | 4 ++-- drivers/net/tun.c | 2 +- drivers/net/usb/hso.c | 3 +-- drivers/net/via-velocity.h | 6 +++--- drivers/net/wan/hdlc.c | 2 +- drivers/net/wan/hdlc_cisco.c | 16 ++++++++-------- drivers/net/wan/hdlc_fr.c | 16 ++++++++-------- drivers/net/wan/hdlc_ppp.c | 4 ++-- drivers/net/wan/hdlc_raw.c | 2 +- drivers/net/wan/lapbether.c | 2 +- net/802/psnap.c | 2 +- net/8021q/vlan.c | 2 +- net/appletalk/ddp.c | 4 ++-- net/ax25/af_ax25.c | 2 +- net/bridge/br_netfilter.c | 2 +- net/can/af_can.c | 2 +- net/decnet/af_decnet.c | 2 +- net/decnet/dn_route.c | 2 +- net/dsa/mv88e6123_61_65.c | 2 +- net/dsa/mv88e6131.c | 2 +- net/dsa/tag_dsa.c | 2 +- net/dsa/tag_edsa.c | 2 +- net/dsa/tag_trailer.c | 2 +- net/econet/af_econet.c | 2 +- net/ipv4/af_inet.c | 2 +- net/ipv4/arp.c | 2 +- net/ipv4/ipconfig.c | 8 ++++---- net/ipv4/netfilter/nf_nat_snmp_basic.c | 4 ++-- net/ipv4/route.c | 4 ++-- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/af_inet6.c | 2 +- net/ipv6/route.c | 4 ++-- net/ipv6/xfrm6_policy.c | 2 +- net/ipx/af_ipx.c | 4 ++-- net/irda/irmod.c | 2 +- net/llc/llc_core.c | 4 ++-- net/netfilter/ipvs/ip_vs_sync.c | 4 ++-- net/netfilter/nf_conntrack_amanda.c | 4 ++-- net/netfilter/nf_conntrack_h323_main.c | 8 ++++---- net/netfilter/nf_conntrack_netbios_ns.c | 2 +- net/netfilter/nf_conntrack_pptp.c | 2 +- net/phonet/af_phonet.c | 2 +- net/sctp/output.c | 2 +- net/sctp/sm_make_chunk.c | 4 ++-- net/x25/af_x25.c | 2 +- 61 files changed, 111 insertions(+), 112 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c index da017cbb5f6..646dfc5f50c 100644 --- a/drivers/net/arcnet/arc-rawmode.c +++ b/drivers/net/arcnet/arc-rawmode.c @@ -122,7 +122,7 @@ static void rx(struct net_device *dev, int bufnum, BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx"); - skb->protocol = __constant_htons(ETH_P_ARCNET); + skb->protocol = cpu_to_be16(ETH_P_ARCNET); ; netif_rx(skb); } diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c index 1613929ff30..083e21094b2 100644 --- a/drivers/net/arcnet/capmode.c +++ b/drivers/net/arcnet/capmode.c @@ -148,7 +148,7 @@ static void rx(struct net_device *dev, int bufnum, BUGLVL(D_SKB) arcnet_dump_skb(dev, skb, "rx"); - skb->protocol = __constant_htons(ETH_P_ARCNET); + skb->protocol = cpu_to_be16(ETH_P_ARCNET); ; netif_rx(skb); } @@ -282,7 +282,7 @@ static int ack_tx(struct net_device *dev, int acked) BUGMSG(D_PROTO, "Ackknowledge for cap packet %x.\n", *((int*)&ackpkt->soft.cap.cookie[0])); - ackskb->protocol = __constant_htons(ETH_P_ARCNET); + ackskb->protocol = cpu_to_be16(ETH_P_ARCNET); BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv"); netif_rx(ackskb); diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h index 8a83eb283c2..a306230381c 100644 --- a/drivers/net/bonding/bond_3ad.h +++ b/drivers/net/bonding/bond_3ad.h @@ -29,7 +29,7 @@ // General definitions #define BOND_ETH_P_LACPDU 0x8809 -#define PKT_TYPE_LACPDU __constant_htons(BOND_ETH_P_LACPDU) +#define PKT_TYPE_LACPDU cpu_to_be16(BOND_ETH_P_LACPDU) #define AD_TIMER_INTERVAL 100 /*msec*/ #define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02} diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 27fb7f5c21c..409b1407427 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c @@ -822,7 +822,7 @@ static int rlb_initialize(struct bonding *bond) _unlock_rx_hashtbl(bond); /*initialize packet type*/ - pk_type->type = __constant_htons(ETH_P_ARP); + pk_type->type = cpu_to_be16(ETH_P_ARP); pk_type->dev = NULL; pk_type->func = rlb_arp_recv; @@ -892,7 +892,7 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[]) memset(&pkt, 0, size); memcpy(pkt.mac_dst, mac_addr, ETH_ALEN); memcpy(pkt.mac_src, mac_addr, ETH_ALEN); - pkt.type = __constant_htons(ETH_P_LOOP); + pkt.type = cpu_to_be16(ETH_P_LOOP); for (i = 0; i < MAX_LP_BURST; i++) { struct sk_buff *skb; diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index c4a303023b3..40db34deebd 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c @@ -2860,11 +2860,11 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter, return false; switch (skb->protocol) { - case __constant_htons(ETH_P_IP): + case cpu_to_be16(ETH_P_IP): if (ip_hdr(skb)->protocol == IPPROTO_TCP) cmd_len |= E1000_TXD_CMD_TCP; break; - case __constant_htons(ETH_P_IPV6): + case cpu_to_be16(ETH_P_IPV6): /* XXX not handling all IPV6 headers */ if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) cmd_len |= E1000_TXD_CMD_TCP; diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c index e04b392c9a5..c425b19e336 100644 --- a/drivers/net/e1000e/netdev.c +++ b/drivers/net/e1000e/netdev.c @@ -3770,11 +3770,11 @@ static bool e1000_tx_csum(struct e1000_adapter *adapter, struct sk_buff *skb) return 0; switch (skb->protocol) { - case __constant_htons(ETH_P_IP): + case cpu_to_be16(ETH_P_IP): if (ip_hdr(skb)->protocol == IPPROTO_TCP) cmd_len |= E1000_TXD_CMD_TCP; break; - case __constant_htons(ETH_P_IPV6): + case cpu_to_be16(ETH_P_IPV6): /* XXX not handling all IPV6 headers */ if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) cmd_len |= E1000_TXD_CMD_TCP; diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 4617956821c..5dd11563553 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -570,11 +570,11 @@ static inline void enic_queue_wq_skb_tso(struct enic *enic, * to each TCP segment resulting from the TSO. */ - if (skb->protocol == __constant_htons(ETH_P_IP)) { + if (skb->protocol == cpu_to_be16(ETH_P_IP)) { ip_hdr(skb)->check = 0; tcp_hdr(skb)->check = ~csum_tcpudp_magic(ip_hdr(skb)->saddr, ip_hdr(skb)->daddr, 0, IPPROTO_TCP, 0); - } else if (skb->protocol == __constant_htons(ETH_P_IPV6)) { + } else if (skb->protocol == cpu_to_be16(ETH_P_IPV6)) { tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr, 0, IPPROTO_TCP, 0); } diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index 7e8b3c59a7d..455641f8677 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c @@ -1244,7 +1244,7 @@ do { \ csum_add(sum, (ih)->saddr & 0xffff); \ csum_add(sum, (ih)->daddr >> 16); \ csum_add(sum, (ih)->daddr & 0xffff); \ - csum_add(sum, __constant_htons(IPPROTO_UDP)); \ + csum_add(sum, cpu_to_be16(IPPROTO_UDP)); \ csum_add(sum, (uh)->len); \ } while (0) @@ -1255,7 +1255,7 @@ do { \ csum_add(sum, (ih)->saddr & 0xffff); \ csum_add(sum, (ih)->daddr >> 16); \ csum_add(sum, (ih)->daddr & 0xffff); \ - csum_add(sum, __constant_htons(IPPROTO_TCP)); \ + csum_add(sum, cpu_to_be16(IPPROTO_TCP)); \ csum_add(sum, htons(len)); \ } while (0) #endif @@ -1296,7 +1296,7 @@ static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev) /* tack on checksum tag */ u32 tagval = 0; struct ethhdr *eh = (struct ethhdr *)skb->data; - if (eh->h_proto == __constant_htons(ETH_P_IP)) { + if (eh->h_proto == cpu_to_be16(ETH_P_IP)) { struct iphdr *ih = (struct iphdr *)((char *)eh + ETH_HLEN); if (ih->protocol == IPPROTO_UDP) { struct udphdr *uh @@ -1605,7 +1605,7 @@ static int hamachi_rx(struct net_device *dev) */ if (ntohs(ih->tot_len) >= 46){ /* don't worry about frags */ - if (!(ih->frag_off & __constant_htons(IP_MF|IP_OFFSET))) { + if (!(ih->frag_off & cpu_to_be16(IP_MF|IP_OFFSET))) { u32 inv = *(u32 *) &buf_addr[data_size - 16]; u32 *p = (u32 *) &buf_addr[data_size - 20]; register u32 crc, p_r, p_r1; diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index 1f65d1edf13..2c619bc99ae 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c @@ -97,7 +97,7 @@ static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, static int bpq_device_event(struct notifier_block *, unsigned long, void *); static struct packet_type bpq_packet_type = { - .type = __constant_htons(ETH_P_BPQ), + .type = cpu_to_be16(ETH_P_BPQ), .func = bpq_rcv, }; diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index bd166803671..cd794bac8b8 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c @@ -2749,12 +2749,12 @@ static inline bool igb_tx_csum_adv(struct igb_adapter *adapter, if (skb->ip_summed == CHECKSUM_PARTIAL) { switch (skb->protocol) { - case __constant_htons(ETH_P_IP): + case cpu_to_be16(ETH_P_IP): tu_cmd |= E1000_ADVTXD_TUCMD_IPV4; if (ip_hdr(skb)->protocol == IPPROTO_TCP) tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP; break; - case __constant_htons(ETH_P_IPV6): + case cpu_to_be16(ETH_P_IPV6): /* XXX what about other V6 headers?? */ if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) tu_cmd |= E1000_ADVTXD_TUCMD_L4T_TCP; diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index fe4a4d17c4b..88615f69976 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c @@ -3567,13 +3567,13 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter, if (skb->ip_summed == CHECKSUM_PARTIAL) { switch (skb->protocol) { - case __constant_htons(ETH_P_IP): + case cpu_to_be16(ETH_P_IP): type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_IPV4; if (ip_hdr(skb)->protocol == IPPROTO_TCP) type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_TCP; break; - case __constant_htons(ETH_P_IPV6): + case cpu_to_be16(ETH_P_IPV6): /* XXX what about other V6 headers?? */ if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) type_tucmd_mlhl |= diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index 899ed065a14..88b52883ace 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c @@ -748,7 +748,7 @@ static int myri_rebuild_header(struct sk_buff *skb) switch (eth->h_proto) { #ifdef CONFIG_INET - case __constant_htons(ETH_P_IP): + case cpu_to_be16(ETH_P_IP): return arp_find(eth->h_dest, skb); #endif diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index cc06cc5429f..ada462e94c9 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -1170,7 +1170,7 @@ static bool netxen_tso_check(struct net_device *netdev, __be16 protocol = skb->protocol; u16 flags = 0; - if (protocol == __constant_htons(ETH_P_8021Q)) { + if (protocol == cpu_to_be16(ETH_P_8021Q)) { struct vlan_ethhdr *vh = (struct vlan_ethhdr *)skb->data; protocol = vh->h_vlan_encapsulated_proto; flags = FLAGS_VLAN_TAGGED; @@ -1183,21 +1183,21 @@ static bool netxen_tso_check(struct net_device *netdev, desc->total_hdr_length = skb_transport_offset(skb) + tcp_hdrlen(skb); - opcode = (protocol == __constant_htons(ETH_P_IPV6)) ? + opcode = (protocol == cpu_to_be16(ETH_P_IPV6)) ? TX_TCP_LSO6 : TX_TCP_LSO; tso = true; } else if (skb->ip_summed == CHECKSUM_PARTIAL) { u8 l4proto; - if (protocol == __constant_htons(ETH_P_IP)) { + if (protocol == cpu_to_be16(ETH_P_IP)) { l4proto = ip_hdr(skb)->protocol; if (l4proto == IPPROTO_TCP) opcode = TX_TCP_PKT; else if(l4proto == IPPROTO_UDP) opcode = TX_UDP_PKT; - } else if (protocol == __constant_htons(ETH_P_IPV6)) { + } else if (protocol == cpu_to_be16(ETH_P_IPV6)) { l4proto = ipv6_hdr(skb)->nexthdr; if (l4proto == IPPROTO_TCP) diff --git a/drivers/net/niu.c b/drivers/net/niu.c index 2346ca6bf5b..c26325ded20 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c @@ -6447,11 +6447,11 @@ static u64 niu_compute_tx_flags(struct sk_buff *skb, struct ethhdr *ehdr, ipv6 = ihl = 0; switch (skb->protocol) { - case __constant_htons(ETH_P_IP): + case cpu_to_be16(ETH_P_IP): ip_proto = ip_hdr(skb)->protocol; ihl = ip_hdr(skb)->ihl; break; - case __constant_htons(ETH_P_IPV6): + case cpu_to_be16(ETH_P_IPV6): ip_proto = ipv6_hdr(skb)->nexthdr; ihl = (40 >> 2); ipv6 = 1; diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 074803a78fc..1011fd64108 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c @@ -514,12 +514,12 @@ out: } static struct packet_type pppoes_ptype = { - .type = __constant_htons(ETH_P_PPP_SES), + .type = cpu_to_be16(ETH_P_PPP_SES), .func = pppoe_rcv, }; static struct packet_type pppoed_ptype = { - .type = __constant_htons(ETH_P_PPP_DISC), + .type = cpu_to_be16(ETH_P_PPP_DISC), .func = pppoe_disc_rcv, }; @@ -877,7 +877,7 @@ static int pppoe_sendmsg(struct kiocb *iocb, struct socket *sock, skb->dev = dev; skb->priority = sk->sk_priority; - skb->protocol = __constant_htons(ETH_P_PPP_SES); + skb->protocol = cpu_to_be16(ETH_P_PPP_SES); ph = (struct pppoe_hdr *)skb_put(skb, total_len + sizeof(struct pppoe_hdr)); start = (char *)&ph->tag[0]; @@ -937,7 +937,7 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb) ph->sid = po->num; ph->length = htons(data_len); - skb->protocol = __constant_htons(ETH_P_PPP_SES); + skb->protocol = cpu_to_be16(ETH_P_PPP_SES); skb->dev = dev; dev_hard_header(skb, dev, ETH_P_PPP_SES, diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c index 06649d0c209..30900b30d53 100644 --- a/drivers/net/ps3_gelic_net.c +++ b/drivers/net/ps3_gelic_net.c @@ -745,7 +745,7 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb, /* Move the mac addresses to the top of buffer */ memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN); - veth->h_vlan_proto = __constant_htons(ETH_P_8021Q); + veth->h_vlan_proto = cpu_to_be16(ETH_P_8021Q); veth->h_vlan_TCI = htons(tag); return skb; diff --git a/drivers/net/sfc/bitfield.h b/drivers/net/sfc/bitfield.h index d95c2182801..d54d84c267b 100644 --- a/drivers/net/sfc/bitfield.h +++ b/drivers/net/sfc/bitfield.h @@ -543,7 +543,7 @@ typedef union efx_oword { /* Static initialiser */ #define EFX_OWORD32(a, b, c, d) \ - { .u32 = { __constant_cpu_to_le32(a), __constant_cpu_to_le32(b), \ - __constant_cpu_to_le32(c), __constant_cpu_to_le32(d) } } + { .u32 = { cpu_to_le32(a), cpu_to_le32(b), \ + cpu_to_le32(c), cpu_to_le32(d) } } #endif /* EFX_BITFIELD_H */ diff --git a/drivers/net/tun.c b/drivers/net/tun.c index e9bcbdfe015..457f2d7430c 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -543,7 +543,7 @@ static struct sk_buff *tun_alloc_skb(size_t prepad, size_t len, size_t linear, /* Get packet from user space buffer */ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv, size_t count) { - struct tun_pi pi = { 0, __constant_htons(ETH_P_IP) }; + struct tun_pi pi = { 0, cpu_to_be16(ETH_P_IP) }; struct sk_buff *skb; size_t len = count, align = 0; struct virtio_net_hdr gso = { 0 }; diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 0d0fa91c025..806cc5da56c 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -934,8 +934,7 @@ static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt, if (!odev->rx_buf_missing) { /* Packet is complete. Inject into stack. */ /* We have IP packet here */ - odev->skb_rx_buf->protocol = - __constant_htons(ETH_P_IP); + odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); /* don't check it */ odev->skb_rx_buf->ip_summed = CHECKSUM_UNNECESSARY; diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h index 29a33090d3d..ea43e1832af 100644 --- a/drivers/net/via-velocity.h +++ b/drivers/net/via-velocity.h @@ -183,7 +183,7 @@ struct rdesc1 { }; enum { - RX_INTEN = __constant_cpu_to_le16(0x8000) + RX_INTEN = cpu_to_le16(0x8000) }; struct rx_desc { @@ -210,7 +210,7 @@ struct tdesc1 { } __attribute__ ((__packed__)); enum { - TD_QUEUE = __constant_cpu_to_le16(0x8000) + TD_QUEUE = cpu_to_le16(0x8000) }; struct td_buf { @@ -242,7 +242,7 @@ struct velocity_td_info { enum velocity_owner { OWNED_BY_HOST = 0, - OWNED_BY_NIC = __constant_cpu_to_le16(0x8000) + OWNED_BY_NIC = cpu_to_le16(0x8000) }; diff --git a/drivers/net/wan/hdlc.c b/drivers/net/wan/hdlc.c index 43da8bd7297..5ce43720555 100644 --- a/drivers/net/wan/hdlc.c +++ b/drivers/net/wan/hdlc.c @@ -349,7 +349,7 @@ EXPORT_SYMBOL(attach_hdlc_protocol); EXPORT_SYMBOL(detach_hdlc_protocol); static struct packet_type hdlc_packet_type = { - .type = __constant_htons(ETH_P_HDLC), + .type = cpu_to_be16(ETH_P_HDLC), .func = hdlc_rcv, }; diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c index af3fd4fead8..cf5fd17ad70 100644 --- a/drivers/net/wan/hdlc_cisco.c +++ b/drivers/net/wan/hdlc_cisco.c @@ -117,7 +117,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type, data->type = htonl(type); data->par1 = par1; data->par2 = par2; - data->rel = __constant_htons(0xFFFF); + data->rel = cpu_to_be16(0xFFFF); /* we will need do_div here if 1000 % HZ != 0 */ data->time = htonl((jiffies - INITIAL_JIFFIES) * (1000 / HZ)); @@ -136,20 +136,20 @@ static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev) struct hdlc_header *data = (struct hdlc_header*)skb->data; if (skb->len < sizeof(struct hdlc_header)) - return __constant_htons(ETH_P_HDLC); + return cpu_to_be16(ETH_P_HDLC); if (data->address != CISCO_MULTICAST && data->address != CISCO_UNICAST) - return __constant_htons(ETH_P_HDLC); + return cpu_to_be16(ETH_P_HDLC); switch(data->protocol) { - case __constant_htons(ETH_P_IP): - case __constant_htons(ETH_P_IPX): - case __constant_htons(ETH_P_IPV6): + case cpu_to_be16(ETH_P_IP): + case cpu_to_be16(ETH_P_IPX): + case cpu_to_be16(ETH_P_IPV6): skb_pull(skb, sizeof(struct hdlc_header)); return data->protocol; default: - return __constant_htons(ETH_P_HDLC); + return cpu_to_be16(ETH_P_HDLC); } } @@ -194,7 +194,7 @@ static int cisco_rx(struct sk_buff *skb) case CISCO_ADDR_REQ: /* Stolen from syncppp.c :-) */ in_dev = dev->ip_ptr; addr = 0; - mask = __constant_htonl(~0); /* is the mask correct? */ + mask = ~cpu_to_be32(0); /* is the mask correct? */ if (in_dev != NULL) { struct in_ifaddr **ifap = &in_dev->ifa_list; diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index 70e57cebc95..80053010109 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -278,31 +278,31 @@ static int fr_hard_header(struct sk_buff **skb_p, u16 dlci) struct sk_buff *skb = *skb_p; switch (skb->protocol) { - case __constant_htons(NLPID_CCITT_ANSI_LMI): + case cpu_to_be16(NLPID_CCITT_ANSI_LMI): head_len = 4; skb_push(skb, head_len); skb->data[3] = NLPID_CCITT_ANSI_LMI; break; - case __constant_htons(NLPID_CISCO_LMI): + case cpu_to_be16(NLPID_CISCO_LMI): head_len = 4; skb_push(skb, head_len); skb->data[3] = NLPID_CISCO_LMI; break; - case __constant_htons(ETH_P_IP): + case cpu_to_be16(ETH_P_IP): head_len = 4; skb_push(skb, head_len); skb->data[3] = NLPID_IP; break; - case __constant_htons(ETH_P_IPV6): + case cpu_to_be16(ETH_P_IPV6): head_len = 4; skb_push(skb, head_len); skb->data[3] = NLPID_IPV6; break; - case __constant_htons(ETH_P_802_3): + case cpu_to_be16(ETH_P_802_3): head_len = 10; if (skb_headroom(skb) < head_len) { struct sk_buff *skb2 = skb_realloc_headroom(skb, @@ -426,7 +426,7 @@ static int pvc_xmit(struct sk_buff *skb, struct net_device *dev) skb_put(skb, pad); memset(skb->data + len, 0, pad); } - skb->protocol = __constant_htons(ETH_P_802_3); + skb->protocol = cpu_to_be16(ETH_P_802_3); } if (!fr_hard_header(&skb, pvc->dlci)) { dev->stats.tx_bytes += skb->len; @@ -496,10 +496,10 @@ static void fr_lmi_send(struct net_device *dev, int fullrep) memset(skb->data, 0, len); skb_reserve(skb, 4); if (lmi == LMI_CISCO) { - skb->protocol = __constant_htons(NLPID_CISCO_LMI); + skb->protocol = cpu_to_be16(NLPID_CISCO_LMI); fr_hard_header(&skb, LMI_CISCO_DLCI); } else { - skb->protocol = __constant_htons(NLPID_CCITT_ANSI_LMI); + skb->protocol = cpu_to_be16(NLPID_CCITT_ANSI_LMI); fr_hard_header(&skb, LMI_CCITT_ANSI_DLCI); } data = skb_tail_pointer(skb); diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c index 7b8a5eae201..72a7cdab424 100644 --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c @@ -150,11 +150,11 @@ static __be16 ppp_type_trans(struct sk_buff *skb, struct net_device *dev) return htons(ETH_P_HDLC); switch (data->protocol) { - case __constant_htons(PID_IP): + case cpu_to_be16(PID_IP): skb_pull(skb, sizeof(struct hdlc_header)); return htons(ETH_P_IP); - case __constant_htons(PID_IPV6): + case cpu_to_be16(PID_IPV6): skb_pull(skb, sizeof(struct hdlc_header)); return htons(ETH_P_IPV6); diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c index 6e92c64ebd0..19f51fdd552 100644 --- a/drivers/net/wan/hdlc_raw.c +++ b/drivers/net/wan/hdlc_raw.c @@ -27,7 +27,7 @@ static int raw_ioctl(struct net_device *dev, struct ifreq *ifr); static __be16 raw_type_trans(struct sk_buff *skb, struct net_device *dev) { - return __constant_htons(ETH_P_IP); + return cpu_to_be16(ETH_P_IP); } static struct hdlc_proto proto = { diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c index 5b61b3eef45..da9dcf59de2 100644 --- a/drivers/net/wan/lapbether.c +++ b/drivers/net/wan/lapbether.c @@ -422,7 +422,7 @@ static int lapbeth_device_event(struct notifier_block *this, /* ------------------------------------------------------------------------ */ static struct packet_type lapbeth_packet_type = { - .type = __constant_htons(ETH_P_DEC), + .type = cpu_to_be16(ETH_P_DEC), .func = lapbeth_rcv, }; diff --git a/net/802/psnap.c b/net/802/psnap.c index 70980baeb68..6ed711748f2 100644 --- a/net/802/psnap.c +++ b/net/802/psnap.c @@ -51,7 +51,7 @@ static int snap_rcv(struct sk_buff *skb, struct net_device *dev, int rc = 1; struct datalink_proto *proto; static struct packet_type snap_packet_type = { - .type = __constant_htons(ETH_P_SNAP), + .type = cpu_to_be16(ETH_P_SNAP), }; if (unlikely(!pskb_may_pull(skb, 5))) diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 41e8f65bd3f..4163ea65bf4 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c @@ -52,7 +52,7 @@ static const char vlan_copyright[] = "Ben Greear "; static const char vlan_buggyright[] = "David S. Miller "; static struct packet_type vlan_packet_type = { - .type = __constant_htons(ETH_P_8021Q), + .type = cpu_to_be16(ETH_P_8021Q), .func = vlan_skb_recv, /* VLAN receive method */ }; diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 5abce07fb50..510a6782da8 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c @@ -1861,12 +1861,12 @@ static struct notifier_block ddp_notifier = { }; static struct packet_type ltalk_packet_type = { - .type = __constant_htons(ETH_P_LOCALTALK), + .type = cpu_to_be16(ETH_P_LOCALTALK), .func = ltalk_rcv, }; static struct packet_type ppptalk_packet_type = { - .type = __constant_htons(ETH_P_PPPTALK), + .type = cpu_to_be16(ETH_P_PPPTALK), .func = atalk_rcv, }; diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 00d9e5e1315..d127fd3ba5c 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -1986,7 +1986,7 @@ static const struct proto_ops ax25_proto_ops = { * Called by socket.c on kernel start up */ static struct packet_type ax25_packet_type = { - .type = __constant_htons(ETH_P_AX25), + .type = cpu_to_be16(ETH_P_AX25), .dev = NULL, /* All devices */ .func = ax25_kiss_rcv, }; diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index cf754ace0b7..3953ac4214c 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c @@ -107,7 +107,7 @@ static void fake_update_pmtu(struct dst_entry *dst, u32 mtu) static struct dst_ops fake_dst_ops = { .family = AF_INET, - .protocol = __constant_htons(ETH_P_IP), + .protocol = cpu_to_be16(ETH_P_IP), .update_pmtu = fake_update_pmtu, .entries = ATOMIC_INIT(0), }; diff --git a/net/can/af_can.c b/net/can/af_can.c index fa417ca6cbe..d90e8dd975f 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c @@ -828,7 +828,7 @@ static int can_notifier(struct notifier_block *nb, unsigned long msg, */ static struct packet_type can_packet __read_mostly = { - .type = __constant_htons(ETH_P_CAN), + .type = cpu_to_be16(ETH_P_CAN), .dev = NULL, .func = can_rcv, }; diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c index cf0e1849929..12bf7d4c16c 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c @@ -2113,7 +2113,7 @@ static struct notifier_block dn_dev_notifier = { extern int dn_route_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); static struct packet_type dn_dix_packet_type = { - .type = __constant_htons(ETH_P_DNA_RT), + .type = cpu_to_be16(ETH_P_DNA_RT), .dev = NULL, /* All devices */ .func = dn_route_rcv, }; diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index c754670b7fc..5130dee0b38 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c @@ -124,7 +124,7 @@ int decnet_dst_gc_interval = 2; static struct dst_ops dn_dst_ops = { .family = PF_DECnet, - .protocol = __constant_htons(ETH_P_DNA_RT), + .protocol = cpu_to_be16(ETH_P_DNA_RT), .gc_thresh = 128, .gc = dn_dst_gc, .check = dn_dst_check, diff --git a/net/dsa/mv88e6123_61_65.c b/net/dsa/mv88e6123_61_65.c index ec8c6a0482d..10031872221 100644 --- a/net/dsa/mv88e6123_61_65.c +++ b/net/dsa/mv88e6123_61_65.c @@ -394,7 +394,7 @@ static int mv88e6123_61_65_get_sset_count(struct dsa_switch *ds) } static struct dsa_switch_driver mv88e6123_61_65_switch_driver = { - .tag_protocol = __constant_htons(ETH_P_EDSA), + .tag_protocol = cpu_to_be16(ETH_P_EDSA), .priv_size = sizeof(struct mv88e6xxx_priv_state), .probe = mv88e6123_61_65_probe, .setup = mv88e6123_61_65_setup, diff --git a/net/dsa/mv88e6131.c b/net/dsa/mv88e6131.c index 374d46a0126..70fae2444cb 100644 --- a/net/dsa/mv88e6131.c +++ b/net/dsa/mv88e6131.c @@ -353,7 +353,7 @@ static int mv88e6131_get_sset_count(struct dsa_switch *ds) } static struct dsa_switch_driver mv88e6131_switch_driver = { - .tag_protocol = __constant_htons(ETH_P_DSA), + .tag_protocol = cpu_to_be16(ETH_P_DSA), .priv_size = sizeof(struct mv88e6xxx_priv_state), .probe = mv88e6131_probe, .setup = mv88e6131_setup, diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index f99a019b939..63e532a69fd 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -176,7 +176,7 @@ out: } static struct packet_type dsa_packet_type = { - .type = __constant_htons(ETH_P_DSA), + .type = cpu_to_be16(ETH_P_DSA), .func = dsa_rcv, }; diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c index 328ec957f78..6197f9a7ef4 100644 --- a/net/dsa/tag_edsa.c +++ b/net/dsa/tag_edsa.c @@ -195,7 +195,7 @@ out: } static struct packet_type edsa_packet_type = { - .type = __constant_htons(ETH_P_EDSA), + .type = cpu_to_be16(ETH_P_EDSA), .func = edsa_rcv, }; diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index b59132878ad..d7e7f424ff0 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c @@ -112,7 +112,7 @@ out: } static struct packet_type trailer_packet_type = { - .type = __constant_htons(ETH_P_TRAILER), + .type = cpu_to_be16(ETH_P_TRAILER), .func = trailer_rcv, }; diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 8789d2bb1b0..7bf35582f65 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c @@ -1103,7 +1103,7 @@ drop: } static struct packet_type econet_packet_type = { - .type = __constant_htons(ETH_P_ECONET), + .type = cpu_to_be16(ETH_P_ECONET), .func = econet_rcv, }; diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index d6770f295d5..957cd054732 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1501,7 +1501,7 @@ static int ipv4_proc_init(void); */ static struct packet_type ip_packet_type = { - .type = __constant_htons(ETH_P_IP), + .type = cpu_to_be16(ETH_P_IP), .func = ip_rcv, .gso_send_check = inet_gso_send_check, .gso_segment = inet_gso_segment, diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 29a74c01d8d..3f6b7354699 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1226,7 +1226,7 @@ void arp_ifdown(struct net_device *dev) */ static struct packet_type arp_packet_type = { - .type = __constant_htons(ETH_P_ARP), + .type = cpu_to_be16(ETH_P_ARP), .func = arp_rcv, }; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index d722013c1ca..90d22ae0a41 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -100,8 +100,8 @@ #define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers - '3' from resolv.h */ -#define NONE __constant_htonl(INADDR_NONE) -#define ANY __constant_htonl(INADDR_ANY) +#define NONE cpu_to_be32(INADDR_NONE) +#define ANY cpu_to_be32(INADDR_ANY) /* * Public IP configuration @@ -406,7 +406,7 @@ static int __init ic_defaults(void) static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); static struct packet_type rarp_packet_type __initdata = { - .type = __constant_htons(ETH_P_RARP), + .type = cpu_to_be16(ETH_P_RARP), .func = ic_rarp_recv, }; @@ -568,7 +568,7 @@ struct bootp_pkt { /* BOOTP packet format */ static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev); static struct packet_type bootp_packet_type __initdata = { - .type = __constant_htons(ETH_P_IP), + .type = cpu_to_be16(ETH_P_IP), .func = ic_bootp_recv, }; diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf_nat_snmp_basic.c index 182f845de92..d9521f6f9ed 100644 --- a/net/ipv4/netfilter/nf_nat_snmp_basic.c +++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c @@ -1292,7 +1292,7 @@ static struct nf_conntrack_helper snmp_helper __read_mostly = { .expect_policy = &snmp_exp_policy, .name = "snmp", .tuple.src.l3num = AF_INET, - .tuple.src.u.udp.port = __constant_htons(SNMP_PORT), + .tuple.src.u.udp.port = cpu_to_be16(SNMP_PORT), .tuple.dst.protonum = IPPROTO_UDP, }; @@ -1302,7 +1302,7 @@ static struct nf_conntrack_helper snmp_trap_helper __read_mostly = { .expect_policy = &snmp_exp_policy, .name = "snmp_trap", .tuple.src.l3num = AF_INET, - .tuple.src.u.udp.port = __constant_htons(SNMP_TRAP_PORT), + .tuple.src.u.udp.port = cpu_to_be16(SNMP_TRAP_PORT), .tuple.dst.protonum = IPPROTO_UDP, }; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 6a9e204c802..5caee609be0 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -151,7 +151,7 @@ static void rt_emergency_hash_rebuild(struct net *net); static struct dst_ops ipv4_dst_ops = { .family = AF_INET, - .protocol = __constant_htons(ETH_P_IP), + .protocol = cpu_to_be16(ETH_P_IP), .gc = rt_garbage_collect, .check = ipv4_dst_check, .destroy = ipv4_dst_destroy, @@ -2696,7 +2696,7 @@ static void ipv4_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) static struct dst_ops ipv4_dst_blackhole_ops = { .family = AF_INET, - .protocol = __constant_htons(ETH_P_IP), + .protocol = cpu_to_be16(ETH_P_IP), .destroy = ipv4_dst_destroy, .check = ipv4_dst_check, .update_pmtu = ipv4_rt_blackhole_update_pmtu, diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 2ad24ba31f9..60d918c96a4 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -241,7 +241,7 @@ static void xfrm4_dst_ifdown(struct dst_entry *dst, struct net_device *dev, static struct dst_ops xfrm4_dst_ops = { .family = AF_INET, - .protocol = __constant_htons(ETH_P_IP), + .protocol = cpu_to_be16(ETH_P_IP), .gc = xfrm4_garbage_collect, .update_pmtu = xfrm4_update_pmtu, .destroy = xfrm4_dst_destroy, diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index bd91eadcbe3..fa2ac7ee662 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -890,7 +890,7 @@ out_unlock: } static struct packet_type ipv6_packet_type = { - .type = __constant_htons(ETH_P_IPV6), + .type = cpu_to_be16(ETH_P_IPV6), .func = ipv6_rcv, .gso_send_check = ipv6_gso_send_check, .gso_segment = ipv6_gso_segment, diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 9c574235c90..c3d486a3eda 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -98,7 +98,7 @@ static struct rt6_info *rt6_get_route_info(struct net *net, static struct dst_ops ip6_dst_ops_template = { .family = AF_INET6, - .protocol = __constant_htons(ETH_P_IPV6), + .protocol = cpu_to_be16(ETH_P_IPV6), .gc = ip6_dst_gc, .gc_thresh = 1024, .check = ip6_dst_check, @@ -117,7 +117,7 @@ static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) static struct dst_ops ip6_dst_blackhole_ops = { .family = AF_INET6, - .protocol = __constant_htons(ETH_P_IPV6), + .protocol = cpu_to_be16(ETH_P_IPV6), .destroy = ip6_dst_destroy, .check = ip6_dst_check, .update_pmtu = ip6_rt_blackhole_update_pmtu, diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 97ab068e8cc..b4b16a43f27 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c @@ -272,7 +272,7 @@ static void xfrm6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, static struct dst_ops xfrm6_dst_ops = { .family = AF_INET6, - .protocol = __constant_htons(ETH_P_IPV6), + .protocol = cpu_to_be16(ETH_P_IPV6), .gc = xfrm6_garbage_collect, .update_pmtu = xfrm6_update_pmtu, .destroy = xfrm6_dst_destroy, diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index b6e70f92e7f..43d0ffc6d56 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -1959,12 +1959,12 @@ static const struct proto_ops SOCKOPS_WRAPPED(ipx_dgram_ops) = { SOCKOPS_WRAP(ipx_dgram, PF_IPX); static struct packet_type ipx_8023_packet_type = { - .type = __constant_htons(ETH_P_802_3), + .type = cpu_to_be16(ETH_P_802_3), .func = ipx_rcv, }; static struct packet_type ipx_dix_packet_type = { - .type = __constant_htons(ETH_P_IPX), + .type = cpu_to_be16(ETH_P_IPX), .func = ipx_rcv, }; diff --git a/net/irda/irmod.c b/net/irda/irmod.c index 4c487a88372..1bb607f2f5c 100644 --- a/net/irda/irmod.c +++ b/net/irda/irmod.c @@ -56,7 +56,7 @@ EXPORT_SYMBOL(irda_debug); * Tell the kernel how IrDA packets should be handled. */ static struct packet_type irda_packet_type = { - .type = __constant_htons(ETH_P_IRDA), + .type = cpu_to_be16(ETH_P_IRDA), .func = irlap_driver_rcv, /* Packet type handler irlap_frame.c */ }; diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c index 50d5b10e23a..a7fe1adc378 100644 --- a/net/llc/llc_core.c +++ b/net/llc/llc_core.c @@ -148,12 +148,12 @@ void llc_sap_close(struct llc_sap *sap) } static struct packet_type llc_packet_type = { - .type = __constant_htons(ETH_P_802_2), + .type = cpu_to_be16(ETH_P_802_2), .func = llc_rcv, }; static struct packet_type llc_tr_packet_type = { - .type = __constant_htons(ETH_P_TR_802_2), + .type = cpu_to_be16(ETH_P_TR_802_2), .func = llc_rcv, }; diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c index 6be5d4efa51..5c48378a852 100644 --- a/net/netfilter/ipvs/ip_vs_sync.c +++ b/net/netfilter/ipvs/ip_vs_sync.c @@ -149,8 +149,8 @@ static struct task_struct *sync_backup_thread; /* multicast addr */ static struct sockaddr_in mcast_addr = { .sin_family = AF_INET, - .sin_port = __constant_htons(IP_VS_SYNC_PORT), - .sin_addr.s_addr = __constant_htonl(IP_VS_SYNC_GROUP), + .sin_port = cpu_to_be16(IP_VS_SYNC_PORT), + .sin_addr.s_addr = cpu_to_be32(IP_VS_SYNC_GROUP), }; diff --git a/net/netfilter/nf_conntrack_amanda.c b/net/netfilter/nf_conntrack_amanda.c index 4f8fcf49854..07d9d8857e5 100644 --- a/net/netfilter/nf_conntrack_amanda.c +++ b/net/netfilter/nf_conntrack_amanda.c @@ -177,7 +177,7 @@ static struct nf_conntrack_helper amanda_helper[2] __read_mostly = { .me = THIS_MODULE, .help = amanda_help, .tuple.src.l3num = AF_INET, - .tuple.src.u.udp.port = __constant_htons(10080), + .tuple.src.u.udp.port = cpu_to_be16(10080), .tuple.dst.protonum = IPPROTO_UDP, .expect_policy = &amanda_exp_policy, }, @@ -186,7 +186,7 @@ static struct nf_conntrack_helper amanda_helper[2] __read_mostly = { .me = THIS_MODULE, .help = amanda_help, .tuple.src.l3num = AF_INET6, - .tuple.src.u.udp.port = __constant_htons(10080), + .tuple.src.u.udp.port = cpu_to_be16(10080), .tuple.dst.protonum = IPPROTO_UDP, .expect_policy = &amanda_exp_policy, }, diff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c index 687bd633c3d..66369490230 100644 --- a/net/netfilter/nf_conntrack_h323_main.c +++ b/net/netfilter/nf_conntrack_h323_main.c @@ -1167,7 +1167,7 @@ static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = { .name = "Q.931", .me = THIS_MODULE, .tuple.src.l3num = AF_INET, - .tuple.src.u.tcp.port = __constant_htons(Q931_PORT), + .tuple.src.u.tcp.port = cpu_to_be16(Q931_PORT), .tuple.dst.protonum = IPPROTO_TCP, .help = q931_help, .expect_policy = &q931_exp_policy, @@ -1176,7 +1176,7 @@ static struct nf_conntrack_helper nf_conntrack_helper_q931[] __read_mostly = { .name = "Q.931", .me = THIS_MODULE, .tuple.src.l3num = AF_INET6, - .tuple.src.u.tcp.port = __constant_htons(Q931_PORT), + .tuple.src.u.tcp.port = cpu_to_be16(Q931_PORT), .tuple.dst.protonum = IPPROTO_TCP, .help = q931_help, .expect_policy = &q931_exp_policy, @@ -1741,7 +1741,7 @@ static struct nf_conntrack_helper nf_conntrack_helper_ras[] __read_mostly = { .name = "RAS", .me = THIS_MODULE, .tuple.src.l3num = AF_INET, - .tuple.src.u.udp.port = __constant_htons(RAS_PORT), + .tuple.src.u.udp.port = cpu_to_be16(RAS_PORT), .tuple.dst.protonum = IPPROTO_UDP, .help = ras_help, .expect_policy = &ras_exp_policy, @@ -1750,7 +1750,7 @@ static struct nf_conntrack_helper nf_conntrack_helper_ras[] __read_mostly = { .name = "RAS", .me = THIS_MODULE, .tuple.src.l3num = AF_INET6, - .tuple.src.u.udp.port = __constant_htons(RAS_PORT), + .tuple.src.u.udp.port = cpu_to_be16(RAS_PORT), .tuple.dst.protonum = IPPROTO_UDP, .help = ras_help, .expect_policy = &ras_exp_policy, diff --git a/net/netfilter/nf_conntrack_netbios_ns.c b/net/netfilter/nf_conntrack_netbios_ns.c index 5af4273b466..8a3875e36ec 100644 --- a/net/netfilter/nf_conntrack_netbios_ns.c +++ b/net/netfilter/nf_conntrack_netbios_ns.c @@ -105,7 +105,7 @@ static struct nf_conntrack_expect_policy exp_policy = { static struct nf_conntrack_helper helper __read_mostly = { .name = "netbios-ns", .tuple.src.l3num = AF_INET, - .tuple.src.u.udp.port = __constant_htons(NMBD_PORT), + .tuple.src.u.udp.port = cpu_to_be16(NMBD_PORT), .tuple.dst.protonum = IPPROTO_UDP, .me = THIS_MODULE, .help = help, diff --git a/net/netfilter/nf_conntrack_pptp.c b/net/netfilter/nf_conntrack_pptp.c index 9e169ef2e85..72cca638a82 100644 --- a/net/netfilter/nf_conntrack_pptp.c +++ b/net/netfilter/nf_conntrack_pptp.c @@ -591,7 +591,7 @@ static struct nf_conntrack_helper pptp __read_mostly = { .name = "pptp", .me = THIS_MODULE, .tuple.src.l3num = AF_INET, - .tuple.src.u.tcp.port = __constant_htons(PPTP_CONTROL_PORT), + .tuple.src.u.tcp.port = cpu_to_be16(PPTP_CONTROL_PORT), .tuple.dst.protonum = IPPROTO_TCP, .help = conntrack_pptp_help, .destroy = pptp_destroy_siblings, diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index 95bc49ddb8b..81795ea8779 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -383,7 +383,7 @@ out: } static struct packet_type phonet_packet_type = { - .type = __constant_htons(ETH_P_PHONET), + .type = cpu_to_be16(ETH_P_PHONET), .dev = NULL, .func = phonet_rcv, }; diff --git a/net/sctp/output.c b/net/sctp/output.c index 73639355157..47bfba6c03e 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c @@ -367,7 +367,7 @@ int sctp_packet_transmit(struct sctp_packet *packet) struct sctp_transport *tp = packet->transport; struct sctp_association *asoc = tp->asoc; struct sctphdr *sh; - __be32 crc32 = __constant_cpu_to_be32(0); + __be32 crc32 = cpu_to_be32(0); struct sk_buff *nskb; struct sctp_chunk *chunk, *tmp; struct sock *sk; diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index fd8acb48c3f..b40e95f9851 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -100,11 +100,11 @@ int sctp_chunk_iif(const struct sctp_chunk *chunk) */ static const struct sctp_paramhdr ecap_param = { SCTP_PARAM_ECN_CAPABLE, - __constant_htons(sizeof(struct sctp_paramhdr)), + cpu_to_be16(sizeof(struct sctp_paramhdr)), }; static const struct sctp_paramhdr prsctp_param = { SCTP_PARAM_FWD_TSN_SUPPORT, - __constant_htons(sizeof(struct sctp_paramhdr)), + cpu_to_be16(sizeof(struct sctp_paramhdr)), }; /* A helper to initialize to initialize an op error inside a diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 9fc5b023d11..8f76f4009c2 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c @@ -1609,7 +1609,7 @@ static const struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = { SOCKOPS_WRAP(x25_proto, AF_X25); static struct packet_type x25_packet_type = { - .type = __constant_htons(ETH_P_X25), + .type = cpu_to_be16(ETH_P_X25), .func = x25_lapb_receive_frame, }; -- cgit v1.2.3-70-g09d2 From ef38fa77786584c630f5da6696111a6a558c7f23 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Tue, 17 Feb 2009 20:26:22 -0800 Subject: netxen: remove superfluous doorbell map For NX3031 pci doorbells are not used. If unnecessary mapping of doorbell space fails, pci probe bails out. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 4fe20ecdbc6..74017790f4a 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -482,7 +482,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) u8 __iomem *db_ptr = NULL; - unsigned long mem_base, mem_len, db_base, db_len, pci_len0 = 0; + unsigned long mem_base, mem_len, db_base, db_len = 0, pci_len0 = 0; int i = 0, err; int first_driver, first_boot; u32 val; @@ -611,6 +611,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); + if (NX_IS_REVISION_P3(revision_id)) + goto skip_doorbell; + db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ db_len = pci_resource_len(pdev, 4); @@ -620,8 +623,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = -EIO; goto err_out_iounmap; } - DPRINTK(INFO, "doorbell ioremap from %lx a size of %lx\n", db_base, - db_len); db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES); if (!db_ptr) { @@ -630,8 +631,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = -EIO; goto err_out_iounmap; } - DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); +skip_doorbell: adapter->ahw.pci_base0 = mem_ptr0; adapter->ahw.pci_len0 = pci_len0; adapter->ahw.first_page_group_start = first_page_group_start; @@ -941,8 +942,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) if (adapter->flags & NETXEN_NIC_MSI_ENABLED) pci_disable_msi(pdev); - iounmap(adapter->ahw.db_base); iounmap(adapter->ahw.pci_base0); + if (adapter->ahw.db_base != NULL) + iounmap(adapter->ahw.db_base); if (adapter->ahw.pci_base1 != NULL) iounmap(adapter->ahw.pci_base1); if (adapter->ahw.pci_base2 != NULL) -- cgit v1.2.3-70-g09d2 From ba599d4f0d2071abc049cb6345eab510a8a3643e Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Tue, 24 Feb 2009 16:38:22 -0800 Subject: netxen: firmware download support Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 9 ++ drivers/net/netxen/netxen_nic_hdr.h | 3 + drivers/net/netxen/netxen_nic_hw.c | 175 ++++++++++++++++++++++++++++++++--- drivers/net/netxen/netxen_nic_main.c | 125 +++++++++++++------------ 4 files changed, 238 insertions(+), 74 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index f4dd9acb687..b7261823189 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -712,6 +712,15 @@ typedef enum { NETXEN_FIXED_START = 0x3F0000 /* backup of crbinit */ } netxen_flash_map_t; +#define NX_FW_VERSION_OFFSET (NETXEN_USER_START+0x408) +#define NX_FW_SIZE_OFFSET (NETXEN_USER_START+0x40c) +#define NX_BIOS_VERSION_OFFSET (NETXEN_USER_START+0x83c) +#define NX_FW_MAGIC_OFFSET (NETXEN_BRDCFG_START+0x128) +#define NX_FW_MIN_SIZE (0x3fffff) +#define NX_P2_MN_ROMIMAGE "nxromimg.bin" +#define NX_P3_CT_ROMIMAGE "nx3fwct.bin" +#define NX_P3_MN_ROMIMAGE "nx3fwmn.bin" + #define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */ #define NETXEN_FLASH_START (NETXEN_CRBINIT_START) diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index e80f9e3e597..269a1f70688 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h @@ -858,6 +858,9 @@ enum { #define NETXEN_PORT_MODE_ADDR (NETXEN_CAM_RAM(0x24)) #define NETXEN_WOL_PORT_MODE (NETXEN_CAM_RAM(0x198)) +#define NX_PEG_TUNE_MN_PRESENT 0x1 +#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c)) + #define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14) #define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC))) diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index b2f67b98c93..aef39e7a5e2 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -35,7 +35,7 @@ #include "netxen_nic_hw.h" #include "netxen_nic_phan_reg.h" - +#include #include #define MASK(n) ((1ULL<<(n))-1) @@ -951,24 +951,69 @@ netxen_nic_pci_set_crbwindow_2M(struct netxen_adapter *adapter, ulong *off) (ulong)adapter->ahw.pci_base0; } -int netxen_load_firmware(struct netxen_adapter *adapter) +static int +netxen_do_load_firmware(struct netxen_adapter *adapter, const char *fwname, + const struct firmware *fw) { - int i; - u32 data, size = 0; - u32 flashaddr = NETXEN_BOOTLD_START; + u64 *ptr64; + u32 i, flashaddr, size; + struct pci_dev *pdev = adapter->pdev; - size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START)/4; + if (fw) + dev_info(&pdev->dev, "loading firmware from file %s\n", fwname); + else + dev_info(&pdev->dev, "loading firmware from flash\n"); if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) adapter->pci_write_normalize(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1); - for (i = 0; i < size; i++) { - if (netxen_rom_fast_read(adapter, flashaddr, (int *)&data) != 0) - return -EIO; + if (fw) { + __le64 data; + + size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START) / 8; + + ptr64 = (u64 *)&fw->data[NETXEN_BOOTLD_START]; + flashaddr = NETXEN_BOOTLD_START; + + for (i = 0; i < size; i++) { + data = cpu_to_le64(ptr64[i]); + adapter->pci_mem_write(adapter, flashaddr, &data, 8); + flashaddr += 8; + } + + size = *(u32 *)&fw->data[NX_FW_SIZE_OFFSET]; + size = (__force u32)cpu_to_le32(size) / 8; + + ptr64 = (u64 *)&fw->data[NETXEN_IMAGE_START]; + flashaddr = NETXEN_IMAGE_START; + + for (i = 0; i < size; i++) { + data = cpu_to_le64(ptr64[i]); + + if (adapter->pci_mem_write(adapter, + flashaddr, &data, 8)) + return -EIO; + + flashaddr += 8; + } + } else { + u32 data; + + size = (NETXEN_IMAGE_START - NETXEN_BOOTLD_START) / 4; + flashaddr = NETXEN_BOOTLD_START; - adapter->pci_mem_write(adapter, flashaddr, &data, 4); - flashaddr += 4; + for (i = 0; i < size; i++) { + if (netxen_rom_fast_read(adapter, + flashaddr, (int *)&data) != 0) + return -EIO; + + if (adapter->pci_mem_write(adapter, + flashaddr, &data, 4)) + return -EIO; + + flashaddr += 4; + } } msleep(1); @@ -985,6 +1030,114 @@ int netxen_load_firmware(struct netxen_adapter *adapter) return 0; } +static int +netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname, + const struct firmware *fw) +{ + __le32 val; + u32 major, minor, build, ver, min_ver, bios; + struct pci_dev *pdev = adapter->pdev; + + if (fw->size < NX_FW_MIN_SIZE) + return -EINVAL; + + val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_MAGIC_OFFSET]); + if ((__force u32)val != NETXEN_BDINFO_MAGIC) + return -EINVAL; + + val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]); + major = (__force u32)val & 0xff; + minor = ((__force u32)val >> 8) & 0xff; + build = (__force u32)val >> 16; + + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) + min_ver = NETXEN_VERSION_CODE(4, 0, 216); + else + min_ver = NETXEN_VERSION_CODE(3, 4, 216); + + ver = NETXEN_VERSION_CODE(major, minor, build); + + if ((major > _NETXEN_NIC_LINUX_MAJOR) || (ver < min_ver)) { + dev_err(&pdev->dev, + "%s: firmware version %d.%d.%d unsupported\n", + fwname, major, minor, build); + return -EINVAL; + } + + val = cpu_to_le32(*(u32 *)&fw->data[NX_BIOS_VERSION_OFFSET]); + netxen_rom_fast_read(adapter, NX_BIOS_VERSION_OFFSET, (int *)&bios); + if ((__force u32)val != bios) { + dev_err(&pdev->dev, "%s: firmware bios is incompatible\n", + fwname); + return -EINVAL; + } + + netxen_nic_reg_write(adapter, NETXEN_CAM_RAM(0x1fc), + NETXEN_BDINFO_MAGIC); + return 0; +} + +int netxen_load_firmware(struct netxen_adapter *adapter) +{ + u32 capability, flashed_ver; + const struct firmware *fw; + char *fw_name = NULL; + struct pci_dev *pdev = adapter->pdev; + int rc = 0; + + if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { + fw_name = NX_P2_MN_ROMIMAGE; + goto request_fw; + } + + capability = 0; + + netxen_rom_fast_read(adapter, + NX_FW_VERSION_OFFSET, (int *)&flashed_ver); + if (flashed_ver >= NETXEN_VERSION_CODE(4, 0, 220)) { + adapter->hw_read_wx(adapter, + NX_PEG_TUNE_CAPABILITY, &capability, 4); + if (capability & NX_PEG_TUNE_MN_PRESENT) { + fw_name = NX_P3_MN_ROMIMAGE; + goto request_fw; + } + } + +request_ct: + fw_name = NX_P3_CT_ROMIMAGE; + +request_fw: + rc = request_firmware(&fw, fw_name, &pdev->dev); + if (rc != 0) { + if (fw_name == NX_P3_MN_ROMIMAGE) { + msleep(1); + goto request_ct; + } + + fw = NULL; + goto load_fw; + } + + rc = netxen_validate_firmware(adapter, fw_name, fw); + if (rc != 0) { + release_firmware(fw); + + if (fw_name == NX_P3_MN_ROMIMAGE) { + msleep(1); + goto request_ct; + } + + fw = NULL; + } + +load_fw: + rc = netxen_do_load_firmware(adapter, fw_name, fw); + + if (fw) + release_firmware(fw); + return rc; +} + int netxen_nic_hw_write_wx_128M(struct netxen_adapter *adapter, ulong off, void *data, int len) diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 2648e902672..9d6e68fe0c9 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -457,18 +457,65 @@ static const struct net_device_ops netxen_netdev_ops = { #endif }; -/* - * netxen_nic_probe() - * - * The Linux system will invoke this after identifying the vendor ID and - * device Id in the pci_tbl supported by this module. - * - * A quad port card has one operational PCI config space, (function 0), - * which is used to access all four ports. - * - * This routine will initialize the adapter, and setup the global parameters - * along with the port's specific structure. - */ +static int +netxen_start_firmware(struct netxen_adapter *adapter) +{ + int val, err, first_boot; + struct pci_dev *pdev = adapter->pdev; + + first_boot = adapter->pci_read_normalize(adapter, + NETXEN_CAM_RAM(0x1fc)); + + err = netxen_check_hw_init(adapter, first_boot); + if (err) { + dev_err(&pdev->dev, "error in init HW init sequence\n"); + return err; + } + + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) + netxen_set_port_mode(adapter); + + if (first_boot != 0x55555555) { + adapter->pci_write_normalize(adapter, + CRB_CMDPEG_STATE, 0); + netxen_pinit_from_rom(adapter, 0); + msleep(1); + } + netxen_load_firmware(adapter); + + if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { + + /* Initialize multicast addr pool owners */ + val = 0x7654; + if (adapter->ahw.board_type == NETXEN_NIC_XGBE) + val |= 0x0f000000; + netxen_crb_writelit_adapter(adapter, + NETXEN_MAC_ADDR_CNTL_REG, val); + + } + + err = netxen_initialize_adapter_offload(adapter); + if (err) + return err; + + /* + * Tell the hardware our version number. + */ + val = (_NETXEN_NIC_LINUX_MAJOR << 16) + | ((_NETXEN_NIC_LINUX_MINOR << 8)) + | (_NETXEN_NIC_LINUX_SUBVERSION); + adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, val); + + /* Handshake with the card before we register the devices. */ + err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); + if (err) { + netxen_free_adapter_offload(adapter); + return err; + } + + return 0; +} + static int __devinit netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -484,7 +531,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) u8 __iomem *db_ptr = NULL; unsigned long mem_base, mem_len, db_base, db_len = 0, pci_len0 = 0; int i = 0, err; - int first_driver, first_boot; + int first_driver; u32 val; int pci_func_id = PCI_FUNC(pdev->devfn); struct netxen_legacy_intr_set *legacy_intrp; @@ -736,56 +783,10 @@ skip_doorbell: } if (first_driver) { - first_boot = adapter->pci_read_normalize(adapter, - NETXEN_CAM_RAM(0x1fc)); - - err = netxen_check_hw_init(adapter, first_boot); - if (err) { - printk(KERN_ERR "%s: error in init HW init sequence\n", - netxen_nic_driver_name); - goto err_out_iounmap; - } - - if (NX_IS_REVISION_P3(revision_id)) - netxen_set_port_mode(adapter); - - if (first_boot != 0x55555555) { - adapter->pci_write_normalize(adapter, - CRB_CMDPEG_STATE, 0); - netxen_pinit_from_rom(adapter, 0); - msleep(1); - } - netxen_load_firmware(adapter); - - if (NX_IS_REVISION_P2(revision_id)) { - - /* Initialize multicast addr pool owners */ - val = 0x7654; - if (adapter->ahw.board_type == NETXEN_NIC_XGBE) - val |= 0x0f000000; - netxen_crb_writelit_adapter(adapter, - NETXEN_MAC_ADDR_CNTL_REG, val); - - } - - err = netxen_initialize_adapter_offload(adapter); + err = netxen_start_firmware(adapter); if (err) goto err_out_iounmap; - - /* - * Tell the hardware our version number. - */ - i = (_NETXEN_NIC_LINUX_MAJOR << 16) - | ((_NETXEN_NIC_LINUX_MINOR << 8)) - | (_NETXEN_NIC_LINUX_SUBVERSION); - adapter->pci_write_normalize(adapter, CRB_DRIVER_VERSION, i); - - /* Handshake with the card before we register the devices. */ - err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); - if (err) - goto err_out_free_offload; - - } /* first_driver */ + } netxen_nic_flash_print(adapter); @@ -890,14 +891,12 @@ err_out_disable_msi: if (adapter->flags & NETXEN_NIC_MSI_ENABLED) pci_disable_msi(pdev); -err_out_free_offload: if (first_driver) netxen_free_adapter_offload(adapter); err_out_iounmap: if (db_ptr) iounmap(db_ptr); - if (mem_ptr0) iounmap(mem_ptr0); if (mem_ptr1) -- cgit v1.2.3-70-g09d2 From 97daee83b0fd2361cc70be6f3d6ecda69def2103 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Tue, 24 Feb 2009 16:39:21 -0800 Subject: netxen: refactor pci probe Split pci probe function into smaller logical blocks. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic_main.c | 384 ++++++++++++++++++----------------- 1 file changed, 203 insertions(+), 181 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 9d6e68fe0c9..c2b551fd711 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -457,6 +457,202 @@ static const struct net_device_ops netxen_netdev_ops = { #endif }; +static void +netxen_setup_intr(struct netxen_adapter *adapter) +{ + struct netxen_legacy_intr_set *legacy_intrp; + struct pci_dev *pdev = adapter->pdev; + + adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED); + adapter->intr_scheme = -1; + adapter->msi_mode = -1; + + if (adapter->ahw.revision_id >= NX_P3_B0) + legacy_intrp = &legacy_intr[adapter->ahw.pci_func]; + else + legacy_intrp = &legacy_intr[0]; + adapter->legacy_intr.int_vec_bit = legacy_intrp->int_vec_bit; + adapter->legacy_intr.tgt_status_reg = legacy_intrp->tgt_status_reg; + adapter->legacy_intr.tgt_mask_reg = legacy_intrp->tgt_mask_reg; + adapter->legacy_intr.pci_int_reg = legacy_intrp->pci_int_reg; + + netxen_set_msix_bit(pdev, 0); + + if (adapter->msix_supported) { + + netxen_init_msix_entries(adapter); + if (pci_enable_msix(pdev, adapter->msix_entries, + MSIX_ENTRIES_PER_ADAPTER)) + goto request_msi; + + adapter->flags |= NETXEN_NIC_MSIX_ENABLED; + netxen_set_msix_bit(pdev, 1); + dev_info(&pdev->dev, "using msi-x interrupts\n"); + + } else { +request_msi: + if (use_msi && !pci_enable_msi(pdev)) { + adapter->flags |= NETXEN_NIC_MSI_ENABLED; + dev_info(&pdev->dev, "using msi interrupts\n"); + } else + dev_info(&pdev->dev, "using legacy interrupts\n"); + } +} + +static void +netxen_teardown_intr(struct netxen_adapter *adapter) +{ + if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) + pci_disable_msix(adapter->pdev); + if (adapter->flags & NETXEN_NIC_MSI_ENABLED) + pci_disable_msi(adapter->pdev); +} + +static void +netxen_cleanup_pci_map(struct netxen_adapter *adapter) +{ + if (adapter->ahw.db_base != NULL) + iounmap(adapter->ahw.db_base); + if (adapter->ahw.pci_base0 != NULL) + iounmap(adapter->ahw.pci_base0); + if (adapter->ahw.pci_base1 != NULL) + iounmap(adapter->ahw.pci_base1); + if (adapter->ahw.pci_base2 != NULL) + iounmap(adapter->ahw.pci_base2); +} + +static int +netxen_setup_pci_map(struct netxen_adapter *adapter) +{ + void __iomem *mem_ptr0 = NULL; + void __iomem *mem_ptr1 = NULL; + void __iomem *mem_ptr2 = NULL; + void __iomem *db_ptr = NULL; + + unsigned long first_page_group_end; + unsigned long first_page_group_start; + unsigned long mem_base, mem_len, db_base, db_len = 0, pci_len0 = 0; + + struct pci_dev *pdev = adapter->pdev; + int pci_func = adapter->ahw.pci_func; + + int err = 0; + + /* + * Set the CRB window to invalid. If any register in window 0 is + * accessed it should set the window to 0 and then reset it to 1. + */ + adapter->curr_window = 255; + adapter->ahw.qdr_sn_window = -1; + adapter->ahw.ddr_mn_window = -1; + + /* remap phys address */ + mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ + mem_len = pci_resource_len(pdev, 0); + pci_len0 = 0; + + adapter->hw_write_wx = netxen_nic_hw_write_wx_128M; + adapter->hw_read_wx = netxen_nic_hw_read_wx_128M; + adapter->pci_read_immediate = netxen_nic_pci_read_immediate_128M; + adapter->pci_write_immediate = netxen_nic_pci_write_immediate_128M; + adapter->pci_read_normalize = netxen_nic_pci_read_normalize_128M; + adapter->pci_write_normalize = netxen_nic_pci_write_normalize_128M; + adapter->pci_set_window = netxen_nic_pci_set_window_128M; + adapter->pci_mem_read = netxen_nic_pci_mem_read_128M; + adapter->pci_mem_write = netxen_nic_pci_mem_write_128M; + + /* 128 Meg of memory */ + if (mem_len == NETXEN_PCI_128MB_SIZE) { + mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); + mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, + SECOND_PAGE_GROUP_SIZE); + mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, + THIRD_PAGE_GROUP_SIZE); + first_page_group_start = FIRST_PAGE_GROUP_START; + first_page_group_end = FIRST_PAGE_GROUP_END; + } else if (mem_len == NETXEN_PCI_32MB_SIZE) { + mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); + mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - + SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); + first_page_group_start = 0; + first_page_group_end = 0; + } else if (mem_len == NETXEN_PCI_2MB_SIZE) { + adapter->hw_write_wx = netxen_nic_hw_write_wx_2M; + adapter->hw_read_wx = netxen_nic_hw_read_wx_2M; + adapter->pci_read_immediate = netxen_nic_pci_read_immediate_2M; + adapter->pci_write_immediate = + netxen_nic_pci_write_immediate_2M; + adapter->pci_read_normalize = netxen_nic_pci_read_normalize_2M; + adapter->pci_write_normalize = + netxen_nic_pci_write_normalize_2M; + adapter->pci_set_window = netxen_nic_pci_set_window_2M; + adapter->pci_mem_read = netxen_nic_pci_mem_read_2M; + adapter->pci_mem_write = netxen_nic_pci_mem_write_2M; + + mem_ptr0 = pci_ioremap_bar(pdev, 0); + if (mem_ptr0 == NULL) { + dev_err(&pdev->dev, "failed to map PCI bar 0\n"); + return -EIO; + } + pci_len0 = mem_len; + first_page_group_start = 0; + first_page_group_end = 0; + + adapter->ahw.ddr_mn_window = 0; + adapter->ahw.qdr_sn_window = 0; + + adapter->ahw.mn_win_crb = 0x100000 + PCIX_MN_WINDOW + + (pci_func * 0x20); + adapter->ahw.ms_win_crb = 0x100000 + PCIX_SN_WINDOW; + if (pci_func < 4) + adapter->ahw.ms_win_crb += (pci_func * 0x20); + else + adapter->ahw.ms_win_crb += + 0xA0 + ((pci_func - 4) * 0x10); + } else { + return -EIO; + } + + dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); + + adapter->ahw.pci_base0 = mem_ptr0; + adapter->ahw.pci_len0 = pci_len0; + adapter->ahw.first_page_group_start = first_page_group_start; + adapter->ahw.first_page_group_end = first_page_group_end; + adapter->ahw.pci_base1 = mem_ptr1; + adapter->ahw.pci_base2 = mem_ptr2; + + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) + goto skip_doorbell; + + db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ + db_len = pci_resource_len(pdev, 4); + + if (db_len == 0) { + printk(KERN_ERR "%s: doorbell is disabled\n", + netxen_nic_driver_name); + err = -EIO; + goto err_out; + } + + db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES); + if (!db_ptr) { + printk(KERN_ERR "%s: Failed to allocate doorbell map.", + netxen_nic_driver_name); + err = -EIO; + goto err_out; + } + +skip_doorbell: + adapter->ahw.db_base = db_ptr; + adapter->ahw.db_len = db_len; + return 0; + +err_out: + netxen_cleanup_pci_map(adapter); + return err; +} + static int netxen_start_firmware(struct netxen_adapter *adapter) { @@ -521,20 +717,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct net_device *netdev = NULL; struct netxen_adapter *adapter = NULL; - void __iomem *mem_ptr0 = NULL; - void __iomem *mem_ptr1 = NULL; - void __iomem *mem_ptr2 = NULL; - unsigned long first_page_group_end; - unsigned long first_page_group_start; - - - u8 __iomem *db_ptr = NULL; - unsigned long mem_base, mem_len, db_base, db_len = 0, pci_len0 = 0; int i = 0, err; int first_driver; u32 val; int pci_func_id = PCI_FUNC(pdev->devfn); - struct netxen_legacy_intr_set *legacy_intrp; uint8_t revision_id; if (pci_func_id == 0) @@ -589,128 +775,14 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_free_netdev; rwlock_init(&adapter->adapter_lock); - adapter->ahw.qdr_sn_window = -1; - adapter->ahw.ddr_mn_window = -1; - - /* remap phys address */ - mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ - mem_len = pci_resource_len(pdev, 0); - pci_len0 = 0; - - adapter->hw_write_wx = netxen_nic_hw_write_wx_128M; - adapter->hw_read_wx = netxen_nic_hw_read_wx_128M; - adapter->pci_read_immediate = netxen_nic_pci_read_immediate_128M; - adapter->pci_write_immediate = netxen_nic_pci_write_immediate_128M; - adapter->pci_read_normalize = netxen_nic_pci_read_normalize_128M; - adapter->pci_write_normalize = netxen_nic_pci_write_normalize_128M; - adapter->pci_set_window = netxen_nic_pci_set_window_128M; - adapter->pci_mem_read = netxen_nic_pci_mem_read_128M; - adapter->pci_mem_write = netxen_nic_pci_mem_write_128M; - - /* 128 Meg of memory */ - if (mem_len == NETXEN_PCI_128MB_SIZE) { - mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); - mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, - SECOND_PAGE_GROUP_SIZE); - mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, - THIRD_PAGE_GROUP_SIZE); - first_page_group_start = FIRST_PAGE_GROUP_START; - first_page_group_end = FIRST_PAGE_GROUP_END; - } else if (mem_len == NETXEN_PCI_32MB_SIZE) { - mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); - mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - - SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); - first_page_group_start = 0; - first_page_group_end = 0; - } else if (mem_len == NETXEN_PCI_2MB_SIZE) { - adapter->hw_write_wx = netxen_nic_hw_write_wx_2M; - adapter->hw_read_wx = netxen_nic_hw_read_wx_2M; - adapter->pci_read_immediate = netxen_nic_pci_read_immediate_2M; - adapter->pci_write_immediate = - netxen_nic_pci_write_immediate_2M; - adapter->pci_read_normalize = netxen_nic_pci_read_normalize_2M; - adapter->pci_write_normalize = - netxen_nic_pci_write_normalize_2M; - adapter->pci_set_window = netxen_nic_pci_set_window_2M; - adapter->pci_mem_read = netxen_nic_pci_mem_read_2M; - adapter->pci_mem_write = netxen_nic_pci_mem_write_2M; - mem_ptr0 = pci_ioremap_bar(pdev, 0); - if (mem_ptr0 == NULL) { - dev_err(&pdev->dev, "failed to map PCI bar 0\n"); - return -EIO; - } - - pci_len0 = mem_len; - first_page_group_start = 0; - first_page_group_end = 0; - - adapter->ahw.ddr_mn_window = 0; - adapter->ahw.qdr_sn_window = 0; - - adapter->ahw.mn_win_crb = 0x100000 + PCIX_MN_WINDOW + - (pci_func_id * 0x20); - adapter->ahw.ms_win_crb = 0x100000 + PCIX_SN_WINDOW; - if (pci_func_id < 4) - adapter->ahw.ms_win_crb += (pci_func_id * 0x20); - else - adapter->ahw.ms_win_crb += - 0xA0 + ((pci_func_id - 4) * 0x10); - } else { - err = -EIO; + err = netxen_setup_pci_map(adapter); + if (err) goto err_out_free_netdev; - } - - dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); - - if (NX_IS_REVISION_P3(revision_id)) - goto skip_doorbell; - - db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ - db_len = pci_resource_len(pdev, 4); - - if (db_len == 0) { - printk(KERN_ERR "%s: doorbell is disabled\n", - netxen_nic_driver_name); - err = -EIO; - goto err_out_iounmap; - } - - db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES); - if (!db_ptr) { - printk(KERN_ERR "%s: Failed to allocate doorbell map.", - netxen_nic_driver_name); - err = -EIO; - goto err_out_iounmap; - } - -skip_doorbell: - adapter->ahw.pci_base0 = mem_ptr0; - adapter->ahw.pci_len0 = pci_len0; - adapter->ahw.first_page_group_start = first_page_group_start; - adapter->ahw.first_page_group_end = first_page_group_end; - adapter->ahw.pci_base1 = mem_ptr1; - adapter->ahw.pci_base2 = mem_ptr2; - adapter->ahw.db_base = db_ptr; - adapter->ahw.db_len = db_len; netif_napi_add(netdev, &adapter->napi, netxen_nic_poll, NETXEN_NETDEV_WEIGHT); - if (revision_id >= NX_P3_B0) - legacy_intrp = &legacy_intr[pci_func_id]; - else - legacy_intrp = &legacy_intr[0]; - - adapter->legacy_intr.int_vec_bit = legacy_intrp->int_vec_bit; - adapter->legacy_intr.tgt_status_reg = legacy_intrp->tgt_status_reg; - adapter->legacy_intr.tgt_mask_reg = legacy_intrp->tgt_mask_reg; - adapter->legacy_intr.pci_int_reg = legacy_intrp->pci_int_reg; - - /* this will be read from FW later */ - adapter->intr_scheme = -1; - adapter->msi_mode = -1; - /* This will be reset for mezz cards */ adapter->portnum = pci_func_id; adapter->status &= ~NETXEN_NETDEV_STATUS; @@ -741,12 +813,6 @@ skip_doorbell: netdev->vlan_features |= NETIF_F_HIGHDMA; } - /* - * Set the CRB window to invalid. If any register in window 0 is - * accessed it should set the window to 0 and then reset it to 1. - */ - adapter->curr_window = 255; - if (netxen_nic_get_board_info(adapter) != 0) { printk("%s: Error getting board config info.\n", netxen_nic_driver_name); @@ -813,32 +879,7 @@ skip_doorbell: netxen_set_msix_bit(pdev, 0); - if (NX_IS_REVISION_P3(revision_id)) { - if ((mem_len != NETXEN_PCI_128MB_SIZE) && - mem_len != NETXEN_PCI_2MB_SIZE) - adapter->msix_supported = 0; - } - - if (adapter->msix_supported) { - - netxen_init_msix_entries(adapter); - - if (pci_enable_msix(pdev, adapter->msix_entries, - MSIX_ENTRIES_PER_ADAPTER)) - goto request_msi; - - adapter->flags |= NETXEN_NIC_MSIX_ENABLED; - netxen_set_msix_bit(pdev, 1); - dev_info(&pdev->dev, "using msi-x interrupts\n"); - - } else { -request_msi: - if (use_msi && !pci_enable_msi(pdev)) { - adapter->flags |= NETXEN_NIC_MSI_ENABLED; - dev_info(&pdev->dev, "using msi interrupts\n"); - } else - dev_info(&pdev->dev, "using legacy interrupts\n"); - } + netxen_setup_intr(adapter); if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) netdev->irq = adapter->msix_entries[0].vector; @@ -886,23 +927,13 @@ request_msi: return 0; err_out_disable_msi: - if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) - pci_disable_msix(pdev); - if (adapter->flags & NETXEN_NIC_MSI_ENABLED) - pci_disable_msi(pdev); + netxen_teardown_intr(adapter); if (first_driver) netxen_free_adapter_offload(adapter); err_out_iounmap: - if (db_ptr) - iounmap(db_ptr); - if (mem_ptr0) - iounmap(mem_ptr0); - if (mem_ptr1) - iounmap(mem_ptr1); - if (mem_ptr2) - iounmap(mem_ptr2); + netxen_cleanup_pci_map(adapter); err_out_free_netdev: free_netdev(netdev); @@ -944,18 +975,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) if (adapter->irq) free_irq(adapter->irq, adapter); - if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) - pci_disable_msix(pdev); - if (adapter->flags & NETXEN_NIC_MSI_ENABLED) - pci_disable_msi(pdev); + netxen_teardown_intr(adapter); - iounmap(adapter->ahw.pci_base0); - if (adapter->ahw.db_base != NULL) - iounmap(adapter->ahw.db_base); - if (adapter->ahw.pci_base1 != NULL) - iounmap(adapter->ahw.pci_base1); - if (adapter->ahw.pci_base2 != NULL) - iounmap(adapter->ahw.pci_base2); + netxen_cleanup_pci_map(adapter); pci_release_regions(pdev); pci_disable_device(pdev); -- cgit v1.2.3-70-g09d2 From 5d242f1cee2c85721bbe9d8205e98c1c01f5d805 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Wed, 25 Feb 2009 15:57:56 +0000 Subject: netxen: update copyright Extend copyright into 2009 and update address. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/Makefile | 9 ++++----- drivers/net/netxen/netxen_nic.h | 9 +++++---- drivers/net/netxen/netxen_nic_ctx.c | 8 ++++---- drivers/net/netxen/netxen_nic_ethtool.c | 11 ++++------- drivers/net/netxen/netxen_nic_hdr.h | 9 +++++---- drivers/net/netxen/netxen_nic_hw.c | 11 ++++------- drivers/net/netxen/netxen_nic_hw.h | 11 ++++------- drivers/net/netxen/netxen_nic_init.c | 11 ++++------- drivers/net/netxen/netxen_nic_main.c | 11 ++++------- drivers/net/netxen/netxen_nic_niu.c | 11 ++++------- drivers/net/netxen/netxen_nic_phan_reg.h | 9 +++++---- 11 files changed, 47 insertions(+), 63 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/Makefile b/drivers/net/netxen/Makefile index 8e7c4c910d2..cf01a9130c9 100644 --- a/drivers/net/netxen/Makefile +++ b/drivers/net/netxen/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 2003 - 2006 NetXen, Inc. +# Copyright (C) 2003 - 2009 NetXen, Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or @@ -21,11 +21,10 @@ # # Contact Information: # info@netxen.com -# NetXen, -# 3965 Freedom Circle, Fourth floor, -# Santa Clara, CA 95054 +# NetXen Inc, +# 18922 Forge Drive +# Cupertino, CA 95014-0701 # -# Makefile for the NetXen NIC Driver # diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index b7261823189..bbdd8f2d152 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,9 +22,10 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 + * */ #ifndef _NETXEN_NIC_H_ diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c index 746bdb47041..3e437065023 100644 --- a/drivers/net/netxen/netxen_nic_ctx.c +++ b/drivers/net/netxen/netxen_nic_ctx.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2008 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,9 +22,9 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 * */ diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 87803f1b2fa..6b25121cfc1 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,12 +22,9 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 - * - * - * ethtool support for netxen nic + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 * */ diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index 4695246072f..e589d4bbd9b 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,9 +22,10 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 + * */ #ifndef __NETXEN_NIC_HDR_H_ diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index b6b777e62e7..b15246c19da 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,12 +22,9 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 - * - * - * Source file for NIC routines to access the Phantom hardware + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 * */ diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h index 9dcfb3223d8..9fb51627ee5 100644 --- a/drivers/net/netxen/netxen_nic_hw.h +++ b/drivers/net/netxen/netxen_nic_hw.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,12 +22,9 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 - * - * - * Structures, enums, and macros for the MAC + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 * */ diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 688f8807843..f323cee1b95 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,12 +22,9 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 - * - * - * Source file for NIC routines to initialize the Phantom Hardware + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 * */ diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index c2b551fd711..02f5240245b 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,12 +22,9 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 - * - * - * Main source file for NetXen NIC Driver on Linux + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 * */ diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c index 3851a677fd5..d85203203d4 100644 --- a/drivers/net/netxen/netxen_nic_niu.c +++ b/drivers/net/netxen/netxen_nic_niu.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,12 +22,9 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 - * - * - * Provides access to the Network Interface Unit h/w block. + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 * */ diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h index b293adcc95a..2a368f284da 100644 --- a/drivers/net/netxen/netxen_nic_phan_reg.h +++ b/drivers/net/netxen/netxen_nic_phan_reg.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003 - 2006 NetXen, Inc. + * Copyright (C) 2003 - 2009 NetXen, Inc. * All rights reserved. * * This program is free software; you can redistribute it and/or @@ -22,9 +22,10 @@ * * Contact Information: * info@netxen.com - * NetXen, - * 3965 Freedom Circle, Fourth floor, - * Santa Clara, CA 95054 + * NetXen Inc, + * 18922 Forge Drive + * Cupertino, CA 95014-0701 + * */ #ifndef __NIC_PHAN_REG_H_ -- cgit v1.2.3-70-g09d2 From 1f434f638457712732238329dfdf089eab25e5b3 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Mon, 2 Mar 2009 16:02:16 +0000 Subject: netxen: support larger dma addressing Support larger dma mask if firmware indicates capability to handle larger addresses. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 2 - drivers/net/netxen/netxen_nic_main.c | 76 +++++++++++++++++++------------- drivers/net/netxen/netxen_nic_phan_reg.h | 1 + 3 files changed, 46 insertions(+), 33 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index bbdd8f2d152..bd5fbb4ce86 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -1256,8 +1256,6 @@ struct netxen_adapter { u32 crb_win; rwlock_t adapter_lock; - uint64_t dma_mask; - u32 cmd_producer; __le32 *cmd_consumer; u32 last_cmd_consumer; diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 02f5240245b..0ce7cf0dc99 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -166,50 +166,61 @@ static inline void netxen_nic_enable_int(struct netxen_adapter *adapter) static int nx_set_dma_mask(struct netxen_adapter *adapter, uint8_t revision_id) { struct pci_dev *pdev = adapter->pdev; - int err; - uint64_t mask; - -#ifdef CONFIG_IA64 - adapter->dma_mask = DMA_32BIT_MASK; -#else - if (revision_id >= NX_P3_B0) { - /* should go to DMA_64BIT_MASK */ - adapter->dma_mask = DMA_39BIT_MASK; - mask = DMA_39BIT_MASK; - } else if (revision_id == NX_P3_A2) { - adapter->dma_mask = DMA_39BIT_MASK; - mask = DMA_39BIT_MASK; - } else if (revision_id == NX_P2_C1) { - adapter->dma_mask = DMA_35BIT_MASK; - mask = DMA_35BIT_MASK; - } else { - adapter->dma_mask = DMA_32BIT_MASK; - mask = DMA_32BIT_MASK; - goto set_32_bit_mask; - } + uint64_t mask, cmask; + + adapter->pci_using_dac = 0; + mask = DMA_32BIT_MASK; /* * Consistent DMA mask is set to 32 bit because it cannot be set to * 35 bits. For P3 also leave it at 32 bits for now. Only the rings * come off this pool. */ + cmask = DMA_32BIT_MASK; + +#ifndef CONFIG_IA64 + if (revision_id >= NX_P3_B0) + mask = DMA_39BIT_MASK; + else if (revision_id == NX_P2_C1) + mask = DMA_35BIT_MASK; +#endif if (pci_set_dma_mask(pdev, mask) == 0 && - pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK) == 0) { + pci_set_consistent_dma_mask(pdev, cmask) == 0) { adapter->pci_using_dac = 1; return 0; } -set_32_bit_mask: -#endif /* CONFIG_IA64 */ - err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); - if (!err) - err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); - if (err) { - DPRINTK(ERR, "No usable DMA configuration, aborting:%d\n", err); - return err; + return -EIO; +} + +/* Update addressable range if firmware supports it */ +static int +nx_update_dma_mask(struct netxen_adapter *adapter) +{ + int change, shift, err; + uint64_t mask, old_mask; + struct pci_dev *pdev = adapter->pdev; + + change = 0; + + shift = netxen_nic_reg_read(adapter, CRB_DMA_SHIFT); + if (shift >= 32) + return 0; + + if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && (shift > 9)) + change = 1; + else if ((adapter->ahw.revision_id == NX_P2_C1) && (shift <= 4)) + change = 1; + + if (change) { + old_mask = pdev->dma_mask; + mask = (1ULL<<(32+shift)) - 1; + + err = pci_set_dma_mask(pdev, mask); + if (err) + return pci_set_dma_mask(pdev, old_mask); } - adapter->pci_using_dac = 0; return 0; } @@ -674,6 +685,7 @@ netxen_start_firmware(struct netxen_adapter *adapter) netxen_pinit_from_rom(adapter, 0); msleep(1); } + netxen_nic_reg_write(adapter, CRB_DMA_SHIFT, 0x55555555); netxen_load_firmware(adapter); if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { @@ -851,6 +863,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_iounmap; } + nx_update_dma_mask(adapter); + netxen_nic_flash_print(adapter); if (NX_IS_REVISION_P3(revision_id)) { diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h index 2a368f284da..50183335e43 100644 --- a/drivers/net/netxen/netxen_nic_phan_reg.h +++ b/drivers/net/netxen/netxen_nic_phan_reg.h @@ -91,6 +91,7 @@ #define CRB_RX_LRO_START_NUM NETXEN_NIC_REG(0xc0) #define CRB_MPORT_MODE NETXEN_NIC_REG(0xc4) /* Multiport Mode */ #define CRB_CMD_RING_SIZE NETXEN_NIC_REG(0xc8) +#define CRB_DMA_SHIFT NETXEN_NIC_REG(0xcc) #define CRB_INT_VECTOR NETXEN_NIC_REG(0xd4) #define CRB_CTX_RESET NETXEN_NIC_REG(0xd8) #define CRB_HOST_STS_PROD NETXEN_NIC_REG(0xdc) -- cgit v1.2.3-70-g09d2 From 567c6c4e2b92f4b8632b043f9395b216b7e7c3ce Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Mon, 2 Mar 2009 16:02:17 +0000 Subject: netxen: firmware download improvements o set port mode after resetting device. o prefer cut-through firmware (doesn't require on-card memory). o load flashed firmware if newer. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic_hw.c | 27 ++++++++++++++++++++------- drivers/net/netxen/netxen_nic_main.c | 7 ++++--- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index b15246c19da..b564d69cfa4 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -1069,6 +1069,16 @@ netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname, return -EINVAL; } + /* check if flashed firmware is newer */ + if (netxen_rom_fast_read(adapter, + NX_FW_VERSION_OFFSET, (int *)&val)) + return -EIO; + major = (__force u32)val & 0xff; + minor = ((__force u32)val >> 8) & 0xff; + build = (__force u32)val >> 16; + if (NETXEN_VERSION_CODE(major, minor, build) > ver) + return -EINVAL; + netxen_nic_reg_write(adapter, NETXEN_CAM_RAM(0x1fc), NETXEN_BDINFO_MAGIC); return 0; @@ -1087,6 +1097,12 @@ int netxen_load_firmware(struct netxen_adapter *adapter) goto request_fw; } + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { + fw_name = NX_P3_CT_ROMIMAGE; + goto request_fw; + } + +request_mn: capability = 0; netxen_rom_fast_read(adapter, @@ -1100,15 +1116,12 @@ int netxen_load_firmware(struct netxen_adapter *adapter) } } -request_ct: - fw_name = NX_P3_CT_ROMIMAGE; - request_fw: rc = request_firmware(&fw, fw_name, &pdev->dev); if (rc != 0) { - if (fw_name == NX_P3_MN_ROMIMAGE) { + if (fw_name == NX_P3_CT_ROMIMAGE) { msleep(1); - goto request_ct; + goto request_mn; } fw = NULL; @@ -1119,9 +1132,9 @@ request_fw: if (rc != 0) { release_firmware(fw); - if (fw_name == NX_P3_MN_ROMIMAGE) { + if (fw_name == NX_P3_CT_ROMIMAGE) { msleep(1); - goto request_ct; + goto request_mn; } fw = NULL; diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 0ce7cf0dc99..dfd66eaed1a 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -676,16 +676,17 @@ netxen_start_firmware(struct netxen_adapter *adapter) return err; } - if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) - netxen_set_port_mode(adapter); - if (first_boot != 0x55555555) { adapter->pci_write_normalize(adapter, CRB_CMDPEG_STATE, 0); netxen_pinit_from_rom(adapter, 0); msleep(1); } + netxen_nic_reg_write(adapter, CRB_DMA_SHIFT, 0x55555555); + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) + netxen_set_port_mode(adapter); + netxen_load_firmware(adapter); if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { -- cgit v1.2.3-70-g09d2 From d32cc3d24eace8a271a39ffe8aeae1861f400d2d Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Mon, 9 Mar 2009 08:50:53 +0000 Subject: netxen: small xmit optimizations Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 5 +---- drivers/net/netxen/netxen_nic_init.c | 2 ++ drivers/net/netxen/netxen_nic_main.c | 22 ++++++++++++++-------- 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 73cb1164457..b5c0d66daf7 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -358,10 +358,7 @@ struct cmd_desc_type0 { __le64 addr_buffer1; }; - __le16 buffer1_length; - __le16 buffer2_length; - __le16 buffer3_length; - __le16 buffer4_length; + __le16 buffer_length[4]; union { struct { diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index f8164345e3b..72aba634554 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -955,6 +955,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) int done = 0; last_consumer = adapter->last_cmd_consumer; + barrier(); /* cmd_consumer can change underneath */ consumer = le32_to_cpu(*(adapter->cmd_consumer)); while (last_consumer != consumer) { @@ -1005,6 +1006,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) * There is still a possible race condition and the host could miss an * interrupt. The card has to take care of this. */ + barrier(); /* cmd_consumer can change underneath */ consumer = le32_to_cpu(*(adapter->cmd_consumer)); done = (last_consumer == consumer); diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index dfd66eaed1a..c9519843f8c 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -1212,7 +1212,16 @@ netxen_clean_tx_dma_mapping(struct pci_dev *pdev, } } -static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) +static inline void +netxen_clear_cmddesc(u64 *desc) +{ + int i; + for (i = 0; i < 8; i++) + desc[i] = 0ULL; +} + +static int +netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); struct netxen_hardware_context *hw = &adapter->ahw; @@ -1245,7 +1254,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) /* Copy the descriptors into the hardware */ hwdesc = &hw->cmd_desc_head[producer]; - memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); + netxen_clear_cmddesc((u64 *)hwdesc); /* Take skb->data itself */ pbuf = &adapter->cmd_buf_arr[producer]; @@ -1264,7 +1273,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) netxen_set_tx_frags_len(hwdesc, frag_count, skb->len); netxen_set_tx_port(hwdesc, adapter->portnum); - hwdesc->buffer1_length = cpu_to_le16(first_seg_len); + hwdesc->buffer_length[0] = cpu_to_le16(first_seg_len); hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); for (i = 1, k = 1; i < frag_count; i++, k++) { @@ -1277,7 +1286,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) k = 0; producer = get_next_index(producer, num_txd); hwdesc = &hw->cmd_desc_head[producer]; - memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); + netxen_clear_cmddesc((u64 *)hwdesc); pbuf = &adapter->cmd_buf_arr[producer]; pbuf->skb = NULL; } @@ -1297,21 +1306,18 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) buffrag->dma = temp_dma; buffrag->length = temp_len; + hwdesc->buffer_length[k] = cpu_to_le16(temp_len); switch (k) { case 0: - hwdesc->buffer1_length = cpu_to_le16(temp_len); hwdesc->addr_buffer1 = cpu_to_le64(temp_dma); break; case 1: - hwdesc->buffer2_length = cpu_to_le16(temp_len); hwdesc->addr_buffer2 = cpu_to_le64(temp_dma); break; case 2: - hwdesc->buffer3_length = cpu_to_le16(temp_len); hwdesc->addr_buffer3 = cpu_to_le64(temp_dma); break; case 3: - hwdesc->buffer4_length = cpu_to_le16(temp_len); hwdesc->addr_buffer4 = cpu_to_le64(temp_dma); break; } -- cgit v1.2.3-70-g09d2 From 9f5bc7f1908665d7cf379f698c7bdc53bc10da85 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Mon, 9 Mar 2009 08:50:54 +0000 Subject: netxen: refactor netdev open close rearrange open and close into hardware attach(), detach() and nic up() and down(). this will be used for suspend/resume subsequently. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic_main.c | 302 +++++++++++++++++++---------------- 1 file changed, 166 insertions(+), 136 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index c9519843f8c..2953a83bc85 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -94,20 +94,6 @@ static struct pci_device_id netxen_pci_tbl[] __devinitdata = { MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); -/* - * In netxen_nic_down(), we must wait for any pending callback requests into - * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be - * reenabled right after it is deleted in netxen_nic_down(). - * FLUSH_SCHEDULED_WORK() does this synchronization. - * - * Normally, schedule_work()/flush_scheduled_work() could have worked, but - * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off() - * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a - * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause - * linkwatch_event() to be executed which also attempts to acquire the rtnl - * lock thus causing a deadlock. - */ - static struct workqueue_struct *netxen_workq; #define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp) #define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq) @@ -722,6 +708,163 @@ netxen_start_firmware(struct netxen_adapter *adapter) return 0; } +static int +netxen_nic_request_irq(struct netxen_adapter *adapter) +{ + irq_handler_t handler; + unsigned long flags = IRQF_SAMPLE_RANDOM; + struct net_device *netdev = adapter->netdev; + + if ((adapter->msi_mode != MSI_MODE_MULTIFUNC) || + (adapter->intr_scheme != INTR_SCHEME_PERPORT)) { + printk(KERN_ERR "%s: Firmware interrupt scheme is " + "incompatible with driver\n", + netdev->name); + adapter->driver_mismatch = 1; + return -EINVAL; + } + + if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) + handler = netxen_msix_intr; + else if (adapter->flags & NETXEN_NIC_MSI_ENABLED) + handler = netxen_msi_intr; + else { + flags |= IRQF_SHARED; + handler = netxen_intr; + } + adapter->irq = netdev->irq; + + return request_irq(adapter->irq, handler, + flags, netdev->name, adapter); +} + +static int +netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) +{ + int err; + + err = adapter->init_port(adapter, adapter->physical_port); + if (err) { + printk(KERN_ERR "%s: Failed to initialize port %d\n", + netxen_nic_driver_name, adapter->portnum); + return err; + } + adapter->macaddr_set(adapter, netdev->dev_addr); + + netxen_nic_set_link_parameters(adapter); + + netxen_set_multicast_list(netdev); + if (adapter->set_mtu) + adapter->set_mtu(adapter, netdev->mtu); + + adapter->ahw.linkup = 0; + mod_timer(&adapter->watchdog_timer, jiffies); + + napi_enable(&adapter->napi); + netxen_nic_enable_int(adapter); + + return 0; +} + +static void +netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) +{ + netif_carrier_off(netdev); + netif_stop_queue(netdev); + napi_disable(&adapter->napi); + + if (adapter->stop_port) + adapter->stop_port(adapter); + + netxen_nic_disable_int(adapter); + + netxen_release_tx_buffers(adapter); + + FLUSH_SCHEDULED_WORK(); + del_timer_sync(&adapter->watchdog_timer); +} + + +static int +netxen_nic_attach(struct netxen_adapter *adapter) +{ + struct net_device *netdev = adapter->netdev; + struct pci_dev *pdev = adapter->pdev; + int err, ctx, ring; + + err = netxen_init_firmware(adapter); + if (err != 0) { + printk(KERN_ERR "Failed to init firmware\n"); + return -EIO; + } + + if (adapter->fw_major < 4) + adapter->max_rds_rings = 3; + else + adapter->max_rds_rings = 2; + + err = netxen_alloc_sw_resources(adapter); + if (err) { + printk(KERN_ERR "%s: Error in setting sw resources\n", + netdev->name); + return err; + } + + netxen_nic_clear_stats(adapter); + + err = netxen_alloc_hw_resources(adapter); + if (err) { + printk(KERN_ERR "%s: Error in setting hw resources\n", + netdev->name); + goto err_out_free_sw; + } + + if (adapter->fw_major < 4) { + adapter->crb_addr_cmd_producer = + crb_cmd_producer[adapter->portnum]; + adapter->crb_addr_cmd_consumer = + crb_cmd_consumer[adapter->portnum]; + + netxen_nic_update_cmd_producer(adapter, 0); + netxen_nic_update_cmd_consumer(adapter, 0); + } + + for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { + for (ring = 0; ring < adapter->max_rds_rings; ring++) + netxen_post_rx_buffers(adapter, ctx, ring); + } + + err = netxen_nic_request_irq(adapter); + if (err) { + dev_err(&pdev->dev, "%s: failed to setup interrupt\n", + netdev->name); + goto err_out_free_rxbuf; + } + + adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; + return 0; + +err_out_free_rxbuf: + netxen_release_rx_buffers(adapter); + netxen_free_hw_resources(adapter); +err_out_free_sw: + netxen_free_sw_resources(adapter); + return err; +} + +static void +netxen_nic_detach(struct netxen_adapter *adapter) +{ + if (adapter->irq) + free_irq(adapter->irq, adapter); + + netxen_release_rx_buffers(adapter); + netxen_free_hw_resources(adapter); + netxen_free_sw_resources(adapter); + + adapter->is_up = 0; +} + static int __devinit netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -973,9 +1116,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) unregister_netdev(netdev); if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) { - netxen_free_hw_resources(adapter); - netxen_release_rx_buffers(adapter); - netxen_free_sw_resources(adapter); + netxen_nic_detach(adapter); if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) netxen_p3_free_mac_list(adapter); @@ -984,9 +1125,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) if (adapter->portnum == 0) netxen_free_adapter_offload(adapter); - if (adapter->irq) - free_irq(adapter->irq, adapter); - netxen_teardown_intr(adapter); netxen_cleanup_pci_map(adapter); @@ -998,125 +1136,30 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) free_netdev(netdev); } -/* - * Called when a network interface is made active - * @returns 0 on success, negative value on failure - */ static int netxen_nic_open(struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); int err = 0; - int ctx, ring; - irq_handler_t handler; - unsigned long flags = IRQF_SAMPLE_RANDOM; if (adapter->driver_mismatch) return -EIO; if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) { - err = netxen_init_firmware(adapter); - if (err != 0) { - printk(KERN_ERR "Failed to init firmware\n"); - return -EIO; - } - - if (adapter->fw_major < 4) - adapter->max_rds_rings = 3; - else - adapter->max_rds_rings = 2; - - err = netxen_alloc_sw_resources(adapter); - if (err) { - printk(KERN_ERR "%s: Error in setting sw resources\n", - netdev->name); + err = netxen_nic_attach(adapter); + if (err) return err; - } - - netxen_nic_clear_stats(adapter); - - err = netxen_alloc_hw_resources(adapter); - if (err) { - printk(KERN_ERR "%s: Error in setting hw resources\n", - netdev->name); - goto err_out_free_sw; - } - - if ((adapter->msi_mode != MSI_MODE_MULTIFUNC) || - (adapter->intr_scheme != INTR_SCHEME_PERPORT)) { - printk(KERN_ERR "%s: Firmware interrupt scheme is " - "incompatible with driver\n", - netdev->name); - adapter->driver_mismatch = 1; - goto err_out_free_hw; - } - - if (adapter->fw_major < 4) { - adapter->crb_addr_cmd_producer = - crb_cmd_producer[adapter->portnum]; - adapter->crb_addr_cmd_consumer = - crb_cmd_consumer[adapter->portnum]; - - netxen_nic_update_cmd_producer(adapter, 0); - netxen_nic_update_cmd_consumer(adapter, 0); - } - - for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { - for (ring = 0; ring < adapter->max_rds_rings; ring++) - netxen_post_rx_buffers(adapter, ctx, ring); - } - if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) - handler = netxen_msix_intr; - else if (adapter->flags & NETXEN_NIC_MSI_ENABLED) - handler = netxen_msi_intr; - else { - flags |= IRQF_SHARED; - handler = netxen_intr; - } - adapter->irq = netdev->irq; - err = request_irq(adapter->irq, handler, - flags, netdev->name, adapter); - if (err) { - printk(KERN_ERR "request_irq failed with: %d\n", err); - goto err_out_free_rxbuf; - } - - adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; } - /* Done here again so that even if phantom sw overwrote it, - * we set it */ - err = adapter->init_port(adapter, adapter->physical_port); - if (err) { - printk(KERN_ERR "%s: Failed to initialize port %d\n", - netxen_nic_driver_name, adapter->portnum); - goto err_out_free_irq; - } - adapter->macaddr_set(adapter, netdev->dev_addr); - - netxen_nic_set_link_parameters(adapter); - - netxen_set_multicast_list(netdev); - if (adapter->set_mtu) - adapter->set_mtu(adapter, netdev->mtu); - - adapter->ahw.linkup = 0; - mod_timer(&adapter->watchdog_timer, jiffies); - - napi_enable(&adapter->napi); - netxen_nic_enable_int(adapter); + err = netxen_nic_up(adapter, netdev); + if (err) + goto err_out; netif_start_queue(netdev); return 0; -err_out_free_irq: - free_irq(adapter->irq, adapter); -err_out_free_rxbuf: - netxen_release_rx_buffers(adapter); -err_out_free_hw: - netxen_free_hw_resources(adapter); -err_out_free_sw: - netxen_free_sw_resources(adapter); +err_out: + netxen_nic_detach(adapter); return err; } @@ -1127,20 +1170,7 @@ static int netxen_nic_close(struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); - netif_carrier_off(netdev); - netif_stop_queue(netdev); - napi_disable(&adapter->napi); - - if (adapter->stop_port) - adapter->stop_port(adapter); - - netxen_nic_disable_int(adapter); - - netxen_release_tx_buffers(adapter); - - FLUSH_SCHEDULED_WORK(); - del_timer_sync(&adapter->watchdog_timer); - + netxen_nic_down(adapter, netdev); return 0; } -- cgit v1.2.3-70-g09d2 From becf46a012db667c562bbbe589c14e100b62e5a4 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Mon, 9 Mar 2009 08:50:55 +0000 Subject: netxen: cleanup superfluous multi-context code MAX_RCV_CTX was set to 1, there's only rx context per PCI function. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 7 +- drivers/net/netxen/netxen_nic_ctx.c | 130 ++++++++++--------- drivers/net/netxen/netxen_nic_ethtool.c | 11 +- drivers/net/netxen/netxen_nic_hdr.h | 6 - drivers/net/netxen/netxen_nic_init.c | 213 +++++++++++++++----------------- drivers/net/netxen/netxen_nic_main.c | 30 +---- 6 files changed, 178 insertions(+), 219 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index b5c0d66daf7..cde8e70b6b0 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -1280,7 +1280,7 @@ struct netxen_adapter { * Receive instances. These can be either one per port, * or one per peg, etc. */ - struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; + struct netxen_recv_context recv_ctx; int is_up; struct netxen_dummy_dma dummy_dma; @@ -1464,10 +1464,9 @@ void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); int netxen_init_firmware(struct netxen_adapter *adapter); void netxen_nic_clear_stats(struct netxen_adapter *adapter); void netxen_watchdog_task(struct work_struct *work); -void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, - u32 ringid); +void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid); int netxen_process_cmd_ring(struct netxen_adapter *adapter); -u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); +int netxen_process_rcv_ring(struct netxen_adapter *adapter, int max); void netxen_p2_nic_set_multi(struct net_device *netdev); void netxen_p3_nic_set_multi(struct net_device *netdev); void netxen_p3_free_mac_list(struct netxen_adapter *adapter); diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c index 3e437065023..d125dca0131 100644 --- a/drivers/net/netxen/netxen_nic_ctx.c +++ b/drivers/net/netxen/netxen_nic_ctx.c @@ -141,7 +141,7 @@ int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu) { u32 rcode = NX_RCODE_SUCCESS; - struct netxen_recv_context *recv_ctx = &adapter->recv_ctx[0]; + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; if (recv_ctx->state == NX_HOST_CTX_STATE_ACTIVE) rcode = netxen_issue_cmd(adapter, @@ -179,7 +179,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) int err; - struct netxen_recv_context *recv_ctx = &adapter->recv_ctx[0]; + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; /* only one sds ring for now */ nrds_rings = adapter->max_rds_rings; @@ -292,7 +292,7 @@ out_free_rq: static void nx_fw_cmd_destroy_rx_ctx(struct netxen_adapter *adapter) { - struct netxen_recv_context *recv_ctx = &adapter->recv_ctx[0]; + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; if (netxen_issue_cmd(adapter, adapter->ahw.pci_func, @@ -488,7 +488,7 @@ netxen_init_old_ctx(struct netxen_adapter *adapter) { struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; - int ctx, ring; + int ring; int func_id = adapter->portnum; adapter->ctx_desc->cmd_ring_addr = @@ -496,22 +496,20 @@ netxen_init_old_ctx(struct netxen_adapter *adapter) adapter->ctx_desc->cmd_ring_size = cpu_to_le32(adapter->max_tx_desc_count); - for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { - recv_ctx = &adapter->recv_ctx[ctx]; + recv_ctx = &adapter->recv_ctx; - for (ring = 0; ring < adapter->max_rds_rings; ring++) { - rds_ring = &recv_ctx->rds_rings[ring]; + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + rds_ring = &recv_ctx->rds_rings[ring]; - adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr = - cpu_to_le64(rds_ring->phys_addr); - adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = - cpu_to_le32(rds_ring->max_rx_desc_count); - } - adapter->ctx_desc->sts_ring_addr = - cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); - adapter->ctx_desc->sts_ring_size = - cpu_to_le32(adapter->max_rx_desc_count); + adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr = + cpu_to_le64(rds_ring->phys_addr); + adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = + cpu_to_le32(rds_ring->max_rx_desc_count); } + adapter->ctx_desc->sts_ring_addr = + cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); + adapter->ctx_desc->sts_ring_size = + cpu_to_le32(adapter->max_rx_desc_count); adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_LO(func_id), lower32(adapter->ctx_desc_phys_addr)); @@ -533,7 +531,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) u32 state = 0; void *addr; int err = 0; - int ctx, ring; + int ring; struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; @@ -575,48 +573,46 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) hw->cmd_desc_head = (struct cmd_desc_type0 *)addr; - for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { - recv_ctx = &adapter->recv_ctx[ctx]; - - for (ring = 0; ring < adapter->max_rds_rings; ring++) { - /* rx desc ring */ - rds_ring = &recv_ctx->rds_rings[ring]; - addr = pci_alloc_consistent(adapter->pdev, - RCV_DESC_RINGSIZE, - &rds_ring->phys_addr); - if (addr == NULL) { - printk(KERN_ERR "%s failed to allocate rx " - "desc ring[%d]\n", - netxen_nic_driver_name, ring); - err = -ENOMEM; - goto err_out_free; - } - rds_ring->desc_head = (struct rcv_desc *)addr; - - if (adapter->fw_major < 4) - rds_ring->crb_rcv_producer = - recv_crb_registers[adapter->portnum]. - crb_rcv_producer[ring]; - } + recv_ctx = &adapter->recv_ctx; - /* status desc ring */ + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + /* rx desc ring */ + rds_ring = &recv_ctx->rds_rings[ring]; addr = pci_alloc_consistent(adapter->pdev, - STATUS_DESC_RINGSIZE, - &recv_ctx->rcv_status_desc_phys_addr); + RCV_DESC_RINGSIZE, + &rds_ring->phys_addr); if (addr == NULL) { - printk(KERN_ERR "%s failed to allocate sts desc ring\n", - netxen_nic_driver_name); + printk(KERN_ERR "%s failed to allocate rx " + "desc ring[%d]\n", + netxen_nic_driver_name, ring); err = -ENOMEM; goto err_out_free; } - recv_ctx->rcv_status_desc_head = (struct status_desc *)addr; + rds_ring->desc_head = (struct rcv_desc *)addr; if (adapter->fw_major < 4) - recv_ctx->crb_sts_consumer = + rds_ring->crb_rcv_producer = recv_crb_registers[adapter->portnum]. - crb_sts_consumer; + crb_rcv_producer[ring]; } + /* status desc ring */ + addr = pci_alloc_consistent(adapter->pdev, + STATUS_DESC_RINGSIZE, + &recv_ctx->rcv_status_desc_phys_addr); + if (addr == NULL) { + printk(KERN_ERR "%s failed to allocate sts desc ring\n", + netxen_nic_driver_name); + err = -ENOMEM; + goto err_out_free; + } + recv_ctx->rcv_status_desc_head = (struct status_desc *)addr; + + if (adapter->fw_major < 4) + recv_ctx->crb_sts_consumer = + recv_crb_registers[adapter->portnum]. + crb_sts_consumer; + if (adapter->fw_major >= 4) { adapter->intr_scheme = INTR_SCHEME_PERPORT; adapter->msi_mode = MSI_MODE_MULTIFUNC; @@ -654,7 +650,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) { struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; - int ctx, ring; + int ring; if (adapter->fw_major >= 4) { nx_fw_cmd_destroy_tx_ctx(adapter); @@ -679,27 +675,25 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) adapter->ahw.cmd_desc_head = NULL; } - for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { - recv_ctx = &adapter->recv_ctx[ctx]; - for (ring = 0; ring < adapter->max_rds_rings; ring++) { - rds_ring = &recv_ctx->rds_rings[ring]; - - if (rds_ring->desc_head != NULL) { - pci_free_consistent(adapter->pdev, - RCV_DESC_RINGSIZE, - rds_ring->desc_head, - rds_ring->phys_addr); - rds_ring->desc_head = NULL; - } - } + recv_ctx = &adapter->recv_ctx; + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + rds_ring = &recv_ctx->rds_rings[ring]; - if (recv_ctx->rcv_status_desc_head != NULL) { + if (rds_ring->desc_head != NULL) { pci_free_consistent(adapter->pdev, - STATUS_DESC_RINGSIZE, - recv_ctx->rcv_status_desc_head, - recv_ctx->rcv_status_desc_phys_addr); - recv_ctx->rcv_status_desc_head = NULL; + RCV_DESC_RINGSIZE, + rds_ring->desc_head, + rds_ring->phys_addr); + rds_ring->desc_head = NULL; } } + + if (recv_ctx->rcv_status_desc_head != NULL) { + pci_free_consistent(adapter->pdev, + STATUS_DESC_RINGSIZE, + recv_ctx->rcv_status_desc_head, + recv_ctx->rcv_status_desc_phys_addr); + recv_ctx->rcv_status_desc_head = NULL; + } } diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 6b25121cfc1..f811880a57c 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -474,16 +474,13 @@ static void netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) { struct netxen_adapter *adapter = netdev_priv(dev); - int i; ring->rx_pending = 0; ring->rx_jumbo_pending = 0; - for (i = 0; i < MAX_RCV_CTX; ++i) { - ring->rx_pending += adapter->recv_ctx[i]. - rds_rings[RCV_DESC_NORMAL_CTXID].max_rx_desc_count; - ring->rx_jumbo_pending += adapter->recv_ctx[i]. - rds_rings[RCV_DESC_JUMBO_CTXID].max_rx_desc_count; - } + ring->rx_pending += adapter->recv_ctx. + rds_rings[RCV_DESC_NORMAL_CTXID].max_rx_desc_count; + ring->rx_jumbo_pending += adapter->recv_ctx. + rds_rings[RCV_DESC_JUMBO_CTXID].max_rx_desc_count; ring->tx_pending = adapter->max_tx_desc_count; if (adapter->ahw.board_type == NETXEN_NIC_GBE) diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index e589d4bbd9b..016c62129c7 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h @@ -363,12 +363,6 @@ enum { #define NETXEN_HW_CRB_HUB_AGT_ADR_LPC \ ((NETXEN_HW_H6_CH_HUB_ADR << 7) | NETXEN_HW_LPC_CRB_AGT_ADR) -/* - * MAX_RCV_CTX : The number of receive contexts that are available on - * the phantom. - */ -#define MAX_RCV_CTX 1 - #define NETXEN_SRE_INT_STATUS (NETXEN_CRB_SRE + 0x00034) #define NETXEN_SRE_PBI_ACTIVE_STATUS (NETXEN_CRB_SRE + 0x01014) #define NETXEN_SRE_L1RE_CTL (NETXEN_CRB_SRE + 0x03000) diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 72aba634554..bd5e0d69223 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -49,8 +49,8 @@ static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM]; #define NETXEN_NIC_XDMA_RESET 0x8000ff -static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, - uint32_t ctx, uint32_t ringid); +static void +netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid); static void crb_addr_transform_setup(void) { @@ -148,23 +148,21 @@ void netxen_release_rx_buffers(struct netxen_adapter *adapter) struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; struct netxen_rx_buffer *rx_buf; - int i, ctxid, ring; - - for (ctxid = 0; ctxid < MAX_RCV_CTX; ++ctxid) { - recv_ctx = &adapter->recv_ctx[ctxid]; - for (ring = 0; ring < adapter->max_rds_rings; ring++) { - rds_ring = &recv_ctx->rds_rings[ring]; - for (i = 0; i < rds_ring->max_rx_desc_count; ++i) { - rx_buf = &(rds_ring->rx_buf_arr[i]); - if (rx_buf->state == NETXEN_BUFFER_FREE) - continue; - pci_unmap_single(adapter->pdev, - rx_buf->dma, - rds_ring->dma_size, - PCI_DMA_FROMDEVICE); - if (rx_buf->skb != NULL) - dev_kfree_skb_any(rx_buf->skb); - } + int i, ring; + + recv_ctx = &adapter->recv_ctx; + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + rds_ring = &recv_ctx->rds_rings[ring]; + for (i = 0; i < rds_ring->max_rx_desc_count; ++i) { + rx_buf = &(rds_ring->rx_buf_arr[i]); + if (rx_buf->state == NETXEN_BUFFER_FREE) + continue; + pci_unmap_single(adapter->pdev, + rx_buf->dma, + rds_ring->dma_size, + PCI_DMA_FROMDEVICE); + if (rx_buf->skb != NULL) + dev_kfree_skb_any(rx_buf->skb); } } } @@ -205,18 +203,17 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter) { struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; - int ctx, ring; - - for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) { - recv_ctx = &adapter->recv_ctx[ctx]; - for (ring = 0; ring < adapter->max_rds_rings; ring++) { - rds_ring = &recv_ctx->rds_rings[ring]; - if (rds_ring->rx_buf_arr) { - vfree(rds_ring->rx_buf_arr); - rds_ring->rx_buf_arr = NULL; - } + int ring; + + recv_ctx = &adapter->recv_ctx; + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + rds_ring = &recv_ctx->rds_rings[ring]; + if (rds_ring->rx_buf_arr) { + vfree(rds_ring->rx_buf_arr); + rds_ring->rx_buf_arr = NULL; } } + if (adapter->cmd_buf_arr) vfree(adapter->cmd_buf_arr); return; @@ -227,7 +224,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; struct netxen_rx_buffer *rx_buf; - int ctx, ring, i, num_rx_bufs; + int ring, i, num_rx_bufs; struct netxen_cmd_buffer *cmd_buf_arr; struct net_device *netdev = adapter->netdev; @@ -241,74 +238,72 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) memset(cmd_buf_arr, 0, TX_RINGSIZE); adapter->cmd_buf_arr = cmd_buf_arr; - for (ctx = 0; ctx < MAX_RCV_CTX; ctx++) { - recv_ctx = &adapter->recv_ctx[ctx]; - for (ring = 0; ring < adapter->max_rds_rings; ring++) { - rds_ring = &recv_ctx->rds_rings[ring]; - switch (RCV_DESC_TYPE(ring)) { - case RCV_DESC_NORMAL: - rds_ring->max_rx_desc_count = - adapter->max_rx_desc_count; - rds_ring->flags = RCV_DESC_NORMAL; - if (adapter->ahw.cut_through) { - rds_ring->dma_size = - NX_CT_DEFAULT_RX_BUF_LEN; - rds_ring->skb_size = - NX_CT_DEFAULT_RX_BUF_LEN; - } else { - rds_ring->dma_size = RX_DMA_MAP_LEN; - rds_ring->skb_size = - MAX_RX_BUFFER_LENGTH; - } - break; - - case RCV_DESC_JUMBO: - rds_ring->max_rx_desc_count = - adapter->max_jumbo_rx_desc_count; - rds_ring->flags = RCV_DESC_JUMBO; - if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) - rds_ring->dma_size = - NX_P3_RX_JUMBO_BUF_MAX_LEN; - else - rds_ring->dma_size = - NX_P2_RX_JUMBO_BUF_MAX_LEN; + recv_ctx = &adapter->recv_ctx; + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + rds_ring = &recv_ctx->rds_rings[ring]; + switch (RCV_DESC_TYPE(ring)) { + case RCV_DESC_NORMAL: + rds_ring->max_rx_desc_count = + adapter->max_rx_desc_count; + rds_ring->flags = RCV_DESC_NORMAL; + if (adapter->ahw.cut_through) { + rds_ring->dma_size = + NX_CT_DEFAULT_RX_BUF_LEN; rds_ring->skb_size = - rds_ring->dma_size + NET_IP_ALIGN; - break; + NX_CT_DEFAULT_RX_BUF_LEN; + } else { + rds_ring->dma_size = RX_DMA_MAP_LEN; + rds_ring->skb_size = + MAX_RX_BUFFER_LENGTH; + } + break; - case RCV_RING_LRO: - rds_ring->max_rx_desc_count = - adapter->max_lro_rx_desc_count; - rds_ring->flags = RCV_DESC_LRO; - rds_ring->dma_size = RX_LRO_DMA_MAP_LEN; - rds_ring->skb_size = MAX_RX_LRO_BUFFER_LENGTH; - break; + case RCV_DESC_JUMBO: + rds_ring->max_rx_desc_count = + adapter->max_jumbo_rx_desc_count; + rds_ring->flags = RCV_DESC_JUMBO; + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) + rds_ring->dma_size = + NX_P3_RX_JUMBO_BUF_MAX_LEN; + else + rds_ring->dma_size = + NX_P2_RX_JUMBO_BUF_MAX_LEN; + rds_ring->skb_size = + rds_ring->dma_size + NET_IP_ALIGN; + break; - } - rds_ring->rx_buf_arr = (struct netxen_rx_buffer *) - vmalloc(RCV_BUFFSIZE); - if (rds_ring->rx_buf_arr == NULL) { - printk(KERN_ERR "%s: Failed to allocate " - "rx buffer ring %d\n", - netdev->name, ring); - /* free whatever was already allocated */ - goto err_out; - } - memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE); - INIT_LIST_HEAD(&rds_ring->free_list); - /* - * Now go through all of them, set reference handles - * and put them in the queues. - */ - num_rx_bufs = rds_ring->max_rx_desc_count; - rx_buf = rds_ring->rx_buf_arr; - for (i = 0; i < num_rx_bufs; i++) { - list_add_tail(&rx_buf->list, - &rds_ring->free_list); - rx_buf->ref_handle = i; - rx_buf->state = NETXEN_BUFFER_FREE; - rx_buf++; - } + case RCV_RING_LRO: + rds_ring->max_rx_desc_count = + adapter->max_lro_rx_desc_count; + rds_ring->flags = RCV_DESC_LRO; + rds_ring->dma_size = RX_LRO_DMA_MAP_LEN; + rds_ring->skb_size = MAX_RX_LRO_BUFFER_LENGTH; + break; + + } + rds_ring->rx_buf_arr = (struct netxen_rx_buffer *) + vmalloc(RCV_BUFFSIZE); + if (rds_ring->rx_buf_arr == NULL) { + printk(KERN_ERR "%s: Failed to allocate " + "rx buffer ring %d\n", + netdev->name, ring); + /* free whatever was already allocated */ + goto err_out; + } + memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE); + INIT_LIST_HEAD(&rds_ring->free_list); + /* + * Now go through all of them, set reference handles + * and put them in the queues. + */ + num_rx_bufs = rds_ring->max_rx_desc_count; + rx_buf = rds_ring->rx_buf_arr; + for (i = 0; i < num_rx_bufs; i++) { + list_add_tail(&rx_buf->list, + &rds_ring->free_list); + rx_buf->ref_handle = i; + rx_buf->state = NETXEN_BUFFER_FREE; + rx_buf++; } } @@ -838,13 +833,13 @@ no_skb: return skb; } -static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, +static void netxen_process_rcv(struct netxen_adapter *adapter, struct status_desc *desc) { struct net_device *netdev = adapter->netdev; u64 sts_data = le64_to_cpu(desc->status_desc_data); int index = netxen_get_sts_refhandle(sts_data); - struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; struct netxen_rx_buffer *buffer; struct sk_buff *skb; u32 length = netxen_get_sts_totallength(sts_data); @@ -902,10 +897,10 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, adapter->stats.rxbytes += length; } -/* Process Receive status ring */ -u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) +int +netxen_process_rcv_ring(struct netxen_adapter *adapter, int max) { - struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; struct status_desc *desc; u32 consumer = recv_ctx->status_rx_consumer; @@ -922,7 +917,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) opcode = netxen_get_sts_opcode(sts_data); - netxen_process_rcv(adapter, ctxid, desc); + netxen_process_rcv(adapter, desc); desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM); @@ -932,7 +927,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) } for (ring = 0; ring < adapter->max_rds_rings; ring++) - netxen_post_rx_buffers_nodb(adapter, ctxid, ring); + netxen_post_rx_buffers_nodb(adapter, ring); if (count) { recv_ctx->status_rx_consumer = consumer; @@ -1013,14 +1008,12 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) return (done); } -/* - * netxen_post_rx_buffers puts buffer in the Phantom memory - */ -void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) +void +netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid) { struct pci_dev *pdev = adapter->pdev; struct sk_buff *skb; - struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; struct nx_host_rds_ring *rds_ring = NULL; uint producer; struct rcv_desc *pdesc; @@ -1098,12 +1091,12 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) } } -static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, - uint32_t ctx, uint32_t ringid) +static void +netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid) { struct pci_dev *pdev = adapter->pdev; struct sk_buff *skb; - struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; struct nx_host_rds_ring *rds_ring = NULL; u32 producer; struct rcv_desc *pdesc; diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 2953a83bc85..3b4d923f947 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -790,7 +790,7 @@ netxen_nic_attach(struct netxen_adapter *adapter) { struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; - int err, ctx, ring; + int err, ring; err = netxen_init_firmware(adapter); if (err != 0) { @@ -829,10 +829,8 @@ netxen_nic_attach(struct netxen_adapter *adapter) netxen_nic_update_cmd_consumer(adapter, 0); } - for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { - for (ring = 0; ring < adapter->max_rds_rings; ring++) - netxen_post_rx_buffers(adapter, ctx, ring); - } + for (ring = 0; ring < adapter->max_rds_rings; ring++) + netxen_post_rx_buffers(adapter, ring); err = netxen_nic_request_irq(adapter); if (err) { @@ -1640,30 +1638,14 @@ static irqreturn_t netxen_msix_intr(int irq, void *data) static int netxen_nic_poll(struct napi_struct *napi, int budget) { - struct netxen_adapter *adapter = container_of(napi, struct netxen_adapter, napi); + struct netxen_adapter *adapter = + container_of(napi, struct netxen_adapter, napi); int tx_complete; - int ctx; int work_done; tx_complete = netxen_process_cmd_ring(adapter); - work_done = 0; - for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { - /* - * Fairness issue. This will give undue weight to the - * receive context 0. - */ - - /* - * To avoid starvation, we give each of our receivers, - * a fraction of the quota. Sometimes, it might happen that we - * have enough quota to process every packet, but since all the - * packets are on one context, it gets only half of the quota, - * and ends up not processing it. - */ - work_done += netxen_process_rcv_ring(adapter, ctx, - budget / MAX_RCV_CTX); - } + work_done = netxen_process_rcv_ring(adapter, budget); if ((work_done < budget) && tx_complete) { napi_complete(&adapter->napi); -- cgit v1.2.3-70-g09d2 From 1e2d0059fc24c84356721c16c2ad0590c38015a0 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Mon, 9 Mar 2009 08:50:56 +0000 Subject: netxen: annotate board_config and board_type Remove huge board config structure from each instance, read only necessary fields from flash. Replace board_type with port_type (1G/10G), there's another board_type field describing card type (SFP/XFP/CX4). Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 12 ++-- drivers/net/netxen/netxen_nic_ethtool.c | 33 +++++----- drivers/net/netxen/netxen_nic_hw.c | 108 ++++++++++++++++---------------- drivers/net/netxen/netxen_nic_hw.h | 1 - drivers/net/netxen/netxen_nic_init.c | 2 +- drivers/net/netxen/netxen_nic_main.c | 38 +++-------- 6 files changed, 85 insertions(+), 109 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index cde8e70b6b0..618507074bd 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -90,7 +90,6 @@ (sizeof(struct netxen_rx_buffer) * rds_ring->max_rx_desc_count) #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) -#define NETXEN_NETDEV_STATUS 0x1 #define NETXEN_RCV_PRODUCER_OFFSET 0 #define NETXEN_RCV_PEG_DB_ID 2 #define NETXEN_HOST_DUMMY_DMA_SIZE 1024 @@ -795,21 +794,19 @@ struct netxen_hardware_context { void __iomem *pci_base0; void __iomem *pci_base1; void __iomem *pci_base2; - unsigned long first_page_group_end; - unsigned long first_page_group_start; void __iomem *db_base; unsigned long db_len; unsigned long pci_len0; - u8 cut_through; int qdr_sn_window; int ddr_mn_window; unsigned long mn_win_crb; unsigned long ms_win_crb; + u8 cut_through; u8 revision_id; - u16 board_type; - struct netxen_board_info boardcfg; + u16 port_type; + int board_type; u32 linkup; /* Address of cmd ring in Phantom */ struct cmd_desc_type0 *cmd_desc_head; @@ -1260,6 +1257,7 @@ struct netxen_adapter { u32 temp; u32 fw_major; + u32 fw_version; u8 msix_supported; u8 max_possible_rss_rings; @@ -1272,7 +1270,6 @@ struct netxen_adapter { u16 state; u16 link_autoneg; int rx_csum; - int status; struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */ @@ -1391,6 +1388,7 @@ void netxen_nic_write_w1(struct netxen_adapter *adapter, u32 index, u32 value); void netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index, u32 *value); int netxen_nic_get_board_info(struct netxen_adapter *adapter); +void netxen_nic_get_firmware_info(struct netxen_adapter *adapter); int netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off, void *data, int len); diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index f811880a57c..8b4bdfd6a11 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -115,10 +115,9 @@ static int netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) { struct netxen_adapter *adapter = netdev_priv(dev); - struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg; /* read which mode */ - if (adapter->ahw.board_type == NETXEN_NIC_GBE) { + if (adapter->ahw.port_type == NETXEN_NIC_GBE) { ecmd->supported = (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half | @@ -137,7 +136,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ecmd->duplex = adapter->link_duplex; ecmd->autoneg = adapter->link_autoneg; - } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { + } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { u32 val; adapter->hw_read_wx(adapter, NETXEN_PORT_MODE_ADDR, &val, 4); @@ -169,7 +168,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ecmd->phy_address = adapter->physical_port; ecmd->transceiver = XCVR_EXTERNAL; - switch ((netxen_brdtype_t) boardinfo->board_type) { + switch ((netxen_brdtype_t)adapter->ahw.board_type) { case NETXEN_BRDTYPE_P2_SB35_4G: case NETXEN_BRDTYPE_P2_SB31_2G: case NETXEN_BRDTYPE_P3_REF_QG: @@ -185,7 +184,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ecmd->supported |= SUPPORTED_TP; ecmd->advertising |= ADVERTISED_TP; ecmd->port = PORT_TP; - ecmd->autoneg = (boardinfo->board_type == + ecmd->autoneg = (adapter->ahw.board_type == NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? (AUTONEG_DISABLE) : (adapter->link_autoneg); break; @@ -212,7 +211,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ecmd->autoneg = AUTONEG_DISABLE; break; case NETXEN_BRDTYPE_P3_10G_TP: - if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { + if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { ecmd->autoneg = AUTONEG_DISABLE; ecmd->supported |= (SUPPORTED_FIBRE | SUPPORTED_TP); ecmd->advertising |= @@ -228,7 +227,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) break; default: printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", - (netxen_brdtype_t) boardinfo->board_type); + (netxen_brdtype_t)adapter->ahw.board_type); return -EIO; } @@ -242,7 +241,7 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) __u32 status; /* read which mode */ - if (adapter->ahw.board_type == NETXEN_NIC_GBE) { + if (adapter->ahw.port_type == NETXEN_NIC_GBE) { /* autonegotiation */ if (adapter->phy_write && adapter->phy_write(adapter, @@ -430,7 +429,7 @@ static u32 netxen_nic_test_link(struct net_device *dev) int val; /* read which mode */ - if (adapter->ahw.board_type == NETXEN_NIC_GBE) { + if (adapter->ahw.port_type == NETXEN_NIC_GBE) { if (adapter->phy_read && adapter->phy_read(adapter, NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, @@ -440,7 +439,7 @@ static u32 netxen_nic_test_link(struct net_device *dev) val = netxen_get_phy_link(status); return !val; } - } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { + } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { val = adapter->pci_read_normalize(adapter, CRB_XG_STATE); return (val == XG_LINK_UP) ? 0 : 1; } @@ -483,7 +482,7 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) rds_rings[RCV_DESC_JUMBO_CTXID].max_rx_desc_count; ring->tx_pending = adapter->max_tx_desc_count; - if (adapter->ahw.board_type == NETXEN_NIC_GBE) + if (adapter->ahw.port_type == NETXEN_NIC_GBE) ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; else ring->rx_max_pending = MAX_RCV_DESCRIPTORS_10G; @@ -501,7 +500,7 @@ netxen_nic_get_pauseparam(struct net_device *dev, __u32 val; int port = adapter->physical_port; - if (adapter->ahw.board_type == NETXEN_NIC_GBE) { + if (adapter->ahw.port_type == NETXEN_NIC_GBE) { if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) return; /* get flow control settings */ @@ -524,7 +523,7 @@ netxen_nic_get_pauseparam(struct net_device *dev, pause->tx_pause = !(netxen_gb_get_gb3_mask(val)); break; } - } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { + } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) return; pause->rx_pause = 1; @@ -535,7 +534,7 @@ netxen_nic_get_pauseparam(struct net_device *dev, pause->tx_pause = !(netxen_xg_get_xg1_mask(val)); } else { printk(KERN_ERR"%s: Unknown board type: %x\n", - netxen_nic_driver_name, adapter->ahw.board_type); + netxen_nic_driver_name, adapter->ahw.port_type); } } @@ -547,7 +546,7 @@ netxen_nic_set_pauseparam(struct net_device *dev, __u32 val; int port = adapter->physical_port; /* read mode */ - if (adapter->ahw.board_type == NETXEN_NIC_GBE) { + if (adapter->ahw.port_type == NETXEN_NIC_GBE) { if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) return -EIO; /* set flow control */ @@ -591,7 +590,7 @@ netxen_nic_set_pauseparam(struct net_device *dev, break; } netxen_nic_write_w0(adapter, NETXEN_NIU_GB_PAUSE_CTL, val); - } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { + } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) return -EIO; netxen_nic_read_w0(adapter, NETXEN_NIU_XG_PAUSE_CTL, &val); @@ -610,7 +609,7 @@ netxen_nic_set_pauseparam(struct net_device *dev, } else { printk(KERN_ERR "%s: Unknown board type: %x\n", netxen_nic_driver_name, - adapter->ahw.board_type); + adapter->ahw.port_type); } return 0; } diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index b564d69cfa4..a93ab589d9c 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -728,9 +728,8 @@ int netxen_is_flash_supported(struct netxen_adapter *adapter) static int netxen_get_flash_block(struct netxen_adapter *adapter, int base, int size, __le32 * buf) { - int i, addr; + int i, v, addr; __le32 *ptr32; - u32 v; addr = base; ptr32 = buf; @@ -2089,47 +2088,44 @@ u32 netxen_nic_pci_read_normalize_2M(struct netxen_adapter *adapter, u64 off) int netxen_nic_get_board_info(struct netxen_adapter *adapter) { - int rv = 0; - int addr = NETXEN_BRDCFG_START; - struct netxen_board_info *boardinfo; - int index; - int *ptr32; + int offset, board_type, magic, header_version; + struct pci_dev *pdev = adapter->pdev; - boardinfo = &adapter->ahw.boardcfg; - ptr32 = (int *) boardinfo; + offset = NETXEN_BRDCFG_START + + offsetof(struct netxen_board_info, magic); + if (netxen_rom_fast_read(adapter, offset, &magic)) + return -EIO; - for (index = 0; index < sizeof(struct netxen_board_info) / sizeof(u32); - index++) { - if (netxen_rom_fast_read(adapter, addr, ptr32) == -1) { - return -EIO; - } - ptr32++; - addr += sizeof(u32); - } - if (boardinfo->magic != NETXEN_BDINFO_MAGIC) { - printk("%s: ERROR reading %s board config." - " Read %x, expected %x\n", netxen_nic_driver_name, - netxen_nic_driver_name, - boardinfo->magic, NETXEN_BDINFO_MAGIC); - rv = -1; - } - if (boardinfo->header_version != NETXEN_BDINFO_VERSION) { - printk("%s: Unknown board config version." - " Read %x, expected %x\n", netxen_nic_driver_name, - boardinfo->header_version, NETXEN_BDINFO_VERSION); - rv = -1; + offset = NETXEN_BRDCFG_START + + offsetof(struct netxen_board_info, header_version); + if (netxen_rom_fast_read(adapter, offset, &header_version)) + return -EIO; + + if (magic != NETXEN_BDINFO_MAGIC || + header_version != NETXEN_BDINFO_VERSION) { + dev_err(&pdev->dev, + "invalid board config, magic=%08x, version=%08x\n", + magic, header_version); + return -EIO; } - if (boardinfo->board_type == NETXEN_BRDTYPE_P3_4_GB_MM) { + offset = NETXEN_BRDCFG_START + + offsetof(struct netxen_board_info, board_type); + if (netxen_rom_fast_read(adapter, offset, &board_type)) + return -EIO; + + adapter->ahw.board_type = board_type; + + if (board_type == NETXEN_BRDTYPE_P3_4_GB_MM) { u32 gpio = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_PAD_GPIO_I); if ((gpio & 0x8000) == 0) - boardinfo->board_type = NETXEN_BRDTYPE_P3_10G_TP; + board_type = NETXEN_BRDTYPE_P3_10G_TP; } - switch ((netxen_brdtype_t) boardinfo->board_type) { + switch ((netxen_brdtype_t)board_type) { case NETXEN_BRDTYPE_P2_SB35_4G: - adapter->ahw.board_type = NETXEN_NIC_GBE; + adapter->ahw.port_type = NETXEN_NIC_GBE; break; case NETXEN_BRDTYPE_P2_SB31_10G: case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: @@ -2145,7 +2141,7 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter) case NETXEN_BRDTYPE_P3_10G_SFP_QT: case NETXEN_BRDTYPE_P3_10G_XFP: case NETXEN_BRDTYPE_P3_10000_BASE_T: - adapter->ahw.board_type = NETXEN_NIC_XGBE; + adapter->ahw.port_type = NETXEN_NIC_XGBE; break; case NETXEN_BRDTYPE_P1_BD: case NETXEN_BRDTYPE_P1_SB: @@ -2154,20 +2150,19 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter) case NETXEN_BRDTYPE_P3_REF_QG: case NETXEN_BRDTYPE_P3_4_GB: case NETXEN_BRDTYPE_P3_4_GB_MM: - adapter->ahw.board_type = NETXEN_NIC_GBE; + adapter->ahw.port_type = NETXEN_NIC_GBE; break; case NETXEN_BRDTYPE_P3_10G_TP: - adapter->ahw.board_type = (adapter->portnum < 2) ? + adapter->ahw.port_type = (adapter->portnum < 2) ? NETXEN_NIC_XGBE : NETXEN_NIC_GBE; break; default: - printk("%s: Unknown(%x)\n", netxen_nic_driver_name, - boardinfo->board_type); - rv = -ENODEV; + dev_err(&pdev->dev, "unknown board type %x\n", board_type); + adapter->ahw.port_type = NETXEN_NIC_XGBE; break; } - return rv; + return 0; } /* NIU access sections */ @@ -2213,7 +2208,7 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter) return; } - if (adapter->ahw.board_type == NETXEN_NIC_GBE) { + if (adapter->ahw.port_type == NETXEN_NIC_GBE) { adapter->hw_read_wx(adapter, NETXEN_PORT_MODE_ADDR, &port_mode, 4); if (port_mode == NETXEN_PORT_MODE_802_3_AP) { @@ -2268,17 +2263,14 @@ void netxen_nic_set_link_parameters(struct netxen_adapter *adapter) } } -void netxen_nic_flash_print(struct netxen_adapter *adapter) +void netxen_nic_get_firmware_info(struct netxen_adapter *adapter) { - u32 fw_major = 0; - u32 fw_minor = 0; - u32 fw_build = 0; + u32 fw_major, fw_minor, fw_build; char brd_name[NETXEN_MAX_SHORT_NAME]; char serial_num[32]; int i, addr; int *ptr32; - - struct netxen_board_info *board_info = &(adapter->ahw.boardcfg); + struct pci_dev *pdev = adapter->pdev; adapter->driver_mismatch = 0; @@ -2302,23 +2294,31 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter) adapter->hw_read_wx(adapter, NETXEN_FW_VERSION_SUB, &fw_build, 4); adapter->fw_major = fw_major; + adapter->fw_version = NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build); if (adapter->portnum == 0) { - get_brd_name_by_type(board_info->board_type, brd_name); + get_brd_name_by_type(adapter->ahw.board_type, brd_name); printk(KERN_INFO "NetXen %s Board S/N %s Chip rev 0x%x\n", brd_name, serial_num, adapter->ahw.revision_id); - printk(KERN_INFO "NetXen Firmware version %d.%d.%d\n", - fw_major, fw_minor, fw_build); } - if (NETXEN_VERSION_CODE(fw_major, fw_minor, fw_build) < - NETXEN_VERSION_CODE(3, 4, 216)) { + if (adapter->fw_version < NETXEN_VERSION_CODE(3, 4, 216)) { adapter->driver_mismatch = 1; - printk(KERN_ERR "%s: firmware version %d.%d.%d unsupported\n", - netxen_nic_driver_name, + dev_warn(&pdev->dev, "firmware version %d.%d.%d unsupported\n", fw_major, fw_minor, fw_build); return; } + + dev_info(&pdev->dev, "firmware version %d.%d.%d\n", + fw_major, fw_minor, fw_build); + + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { + adapter->hw_read_wx(adapter, + NETXEN_MIU_MN_CONTROL, &i, 4); + adapter->ahw.cut_through = (i & 0x4) ? 1 : 0; + dev_info(&pdev->dev, "firmware running in %s mode\n", + adapter->ahw.cut_through ? "cut-through" : "legacy"); + } } diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h index 9fb51627ee5..04b47a7993c 100644 --- a/drivers/net/netxen/netxen_nic_hw.h +++ b/drivers/net/netxen/netxen_nic_hw.h @@ -57,7 +57,6 @@ struct netxen_adapter; struct netxen_port; void netxen_nic_set_link_parameters(struct netxen_adapter *adapter); -void netxen_nic_flash_print(struct netxen_adapter *adapter); typedef u8 netxen_ethernet_macaddr_t[6]; diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index bd5e0d69223..120b480c1e8 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -316,7 +316,7 @@ err_out: void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) { - switch (adapter->ahw.board_type) { + switch (adapter->ahw.port_type) { case NETXEN_NIC_GBE: adapter->enable_phy_interrupts = netxen_niu_gbe_enable_phy_interrupts; diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 3b4d923f947..9445277321d 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -212,7 +212,7 @@ nx_update_dma_mask(struct netxen_adapter *adapter) static void netxen_check_options(struct netxen_adapter *adapter) { - switch (adapter->ahw.boardcfg.board_type) { + switch (adapter->ahw.board_type) { case NETXEN_BRDTYPE_P3_HMEZ: case NETXEN_BRDTYPE_P3_XG_LOM: case NETXEN_BRDTYPE_P3_10G_CX4: @@ -250,7 +250,7 @@ static void netxen_check_options(struct netxen_adapter *adapter) case NETXEN_BRDTYPE_P3_10G_TP: adapter->msix_supported = !!use_msi_x; - if (adapter->ahw.board_type == NETXEN_NIC_XGBE) + if (adapter->ahw.port_type == NETXEN_NIC_XGBE) adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G; else adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; @@ -261,7 +261,7 @@ static void netxen_check_options(struct netxen_adapter *adapter) adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; printk(KERN_WARNING "Unknown board type(0x%x)\n", - adapter->ahw.boardcfg.board_type); + adapter->ahw.board_type); break; } @@ -330,7 +330,7 @@ static void netxen_set_port_mode(struct netxen_adapter *adapter) { u32 val, data; - val = adapter->ahw.boardcfg.board_type; + val = adapter->ahw.board_type; if ((val == NETXEN_BRDTYPE_P3_HMEZ) || (val == NETXEN_BRDTYPE_P3_XG_LOM)) { if (port_mode == NETXEN_PORT_MODE_802_3_AP) { @@ -523,8 +523,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) void __iomem *mem_ptr2 = NULL; void __iomem *db_ptr = NULL; - unsigned long first_page_group_end; - unsigned long first_page_group_start; unsigned long mem_base, mem_len, db_base, db_len = 0, pci_len0 = 0; struct pci_dev *pdev = adapter->pdev; @@ -562,14 +560,10 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) SECOND_PAGE_GROUP_SIZE); mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); - first_page_group_start = FIRST_PAGE_GROUP_START; - first_page_group_end = FIRST_PAGE_GROUP_END; } else if (mem_len == NETXEN_PCI_32MB_SIZE) { mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); - first_page_group_start = 0; - first_page_group_end = 0; } else if (mem_len == NETXEN_PCI_2MB_SIZE) { adapter->hw_write_wx = netxen_nic_hw_write_wx_2M; adapter->hw_read_wx = netxen_nic_hw_read_wx_2M; @@ -589,8 +583,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) return -EIO; } pci_len0 = mem_len; - first_page_group_start = 0; - first_page_group_end = 0; adapter->ahw.ddr_mn_window = 0; adapter->ahw.qdr_sn_window = 0; @@ -611,8 +603,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) adapter->ahw.pci_base0 = mem_ptr0; adapter->ahw.pci_len0 = pci_len0; - adapter->ahw.first_page_group_start = first_page_group_start; - adapter->ahw.first_page_group_end = first_page_group_end; adapter->ahw.pci_base1 = mem_ptr1; adapter->ahw.pci_base2 = mem_ptr2; @@ -679,7 +669,7 @@ netxen_start_firmware(struct netxen_adapter *adapter) /* Initialize multicast addr pool owners */ val = 0x7654; - if (adapter->ahw.board_type == NETXEN_NIC_XGBE) + if (adapter->ahw.port_type == NETXEN_NIC_XGBE) val |= 0x0f000000; netxen_crb_writelit_adapter(adapter, NETXEN_MAC_ADDR_CNTL_REG, val); @@ -870,7 +860,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct netxen_adapter *adapter = NULL; int i = 0, err; int first_driver; - u32 val; int pci_func_id = PCI_FUNC(pdev->devfn); uint8_t revision_id; @@ -936,7 +925,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* This will be reset for mezz cards */ adapter->portnum = pci_func_id; - adapter->status &= ~NETXEN_NETDEV_STATUS; adapter->rx_csum = 1; adapter->mc_enabled = 0; if (NX_IS_REVISION_P3(revision_id)) @@ -974,7 +962,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netxen_initialize_adapter_ops(adapter); /* Mezz cards have PCI function 0,2,3 enabled */ - switch (adapter->ahw.boardcfg.board_type) { + switch (adapter->ahw.board_type) { case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: if (pci_func_id >= 2) @@ -1007,15 +995,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) nx_update_dma_mask(adapter); - netxen_nic_flash_print(adapter); - - if (NX_IS_REVISION_P3(revision_id)) { - adapter->hw_read_wx(adapter, - NETXEN_MIU_MN_CONTROL, &val, 4); - adapter->ahw.cut_through = (val & 0x4) ? 1 : 0; - dev_info(&pdev->dev, "firmware running in %s mode\n", - adapter->ahw.cut_through ? "cut through" : "legacy"); - } + netxen_nic_get_firmware_info(adapter); /* * See if the firmware gave us a virtual-physical port mapping. @@ -1066,7 +1046,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, adapter); - switch (adapter->ahw.board_type) { + switch (adapter->ahw.port_type) { case NETXEN_NIC_GBE: dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n", adapter->netdev->name); @@ -1460,7 +1440,7 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter) linkup = (val == XG_LINK_UP_P3); } else { val = adapter->pci_read_normalize(adapter, CRB_XG_STATE); - if (adapter->ahw.board_type == NETXEN_NIC_GBE) + if (adapter->ahw.port_type == NETXEN_NIC_GBE) linkup = (val >> port) & 1; else { val = (val >> port*8) & 0xff; -- cgit v1.2.3-70-g09d2 From de9307c68624b03d2922a02a661ce31e20f078cc Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Fri, 6 Mar 2009 14:52:12 +0000 Subject: netxen: remove old flash check. Remove flash size check which made sense only for ancient boards with 1MB flash. The check is based on values read from specific locations and fails with firmware size changes. This prevents driver from getting right mac addresses. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 1 - drivers/net/netxen/netxen_nic_hw.c | 22 ---------------------- drivers/net/netxen/netxen_nic_main.c | 3 --- 3 files changed, 26 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index f4dd9acb687..1ff066b2281 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -1595,7 +1595,6 @@ dma_watchdog_wakeup(struct netxen_adapter *adapter) } -int netxen_is_flash_supported(struct netxen_adapter *adapter); int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, __le64 *mac); int netxen_p3_get_mac_addr(struct netxen_adapter *adapter, __le64 *mac); extern void netxen_change_ringparam(struct netxen_adapter *adapter); diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 821cff68b3f..7fea7708810 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -706,28 +706,6 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu) return rc; } -int netxen_is_flash_supported(struct netxen_adapter *adapter) -{ - const int locs[] = { 0, 0x4, 0x100, 0x4000, 0x4128 }; - int addr, val01, val02, i, j; - - /* if the flash size less than 4Mb, make huge war cry and die */ - for (j = 1; j < 4; j++) { - addr = j * NETXEN_NIC_WINDOW_MARGIN; - for (i = 0; i < ARRAY_SIZE(locs); i++) { - if (netxen_rom_fast_read(adapter, locs[i], &val01) == 0 - && netxen_rom_fast_read(adapter, (addr + locs[i]), - &val02) == 0) { - if (val01 == val02) - return -1; - } else - return -1; - } - } - - return 0; -} - static int netxen_get_flash_block(struct netxen_adapter *adapter, int base, int size, __le32 * buf) { diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 13087782ac4..c172b6e24a9 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -405,9 +405,6 @@ netxen_read_mac_addr(struct netxen_adapter *adapter) struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; - if (netxen_is_flash_supported(adapter) != 0) - return -EIO; - if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { if (netxen_p3_get_mac_addr(adapter, &mac_addr) != 0) return -EIO; -- cgit v1.2.3-70-g09d2 From 0b72e659a10ec50acbef90756bf04177b66c8266 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Fri, 13 Mar 2009 14:52:02 +0000 Subject: netxen: add suspend resume support Detach network interface on PCI suspend and recreate hardware context after resumes. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 1 + drivers/net/netxen/netxen_nic_hw.c | 17 ++++++ drivers/net/netxen/netxen_nic_main.c | 102 ++++++++++++++++++++++++++++------- 3 files changed, 102 insertions(+), 18 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 618507074bd..75cb30f27ae 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -1389,6 +1389,7 @@ void netxen_nic_read_w1(struct netxen_adapter *adapter, u32 index, u32 *value); int netxen_nic_get_board_info(struct netxen_adapter *adapter); void netxen_nic_get_firmware_info(struct netxen_adapter *adapter); +int netxen_nic_wol_supported(struct netxen_adapter *adapter); int netxen_nic_hw_read_wx_128M(struct netxen_adapter *adapter, ulong off, void *data, int len); diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 8db4ac34414..c8faa53d27a 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -2320,3 +2320,20 @@ void netxen_nic_get_firmware_info(struct netxen_adapter *adapter) } } +int +netxen_nic_wol_supported(struct netxen_adapter *adapter) +{ + u32 wol_cfg; + + if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) + return 0; + + wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG_NV); + if (wol_cfg & (1UL << adapter->portnum)) { + wol_cfg = netxen_nic_reg_read(adapter, NETXEN_WOL_CONFIG); + if (wol_cfg & (1 << adapter->portnum)) + return 1; + } + + return 0; +} diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 9445277321d..555b4596b0f 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -643,6 +643,18 @@ netxen_start_firmware(struct netxen_adapter *adapter) int val, err, first_boot; struct pci_dev *pdev = adapter->pdev; + int first_driver = 0; + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { + if (adapter->ahw.pci_func == 0) + first_driver = 1; + } else { + if (adapter->portnum == 0) + first_driver = 1; + } + + if (!first_driver) + return 0; + first_boot = adapter->pci_read_normalize(adapter, NETXEN_CAM_RAM(0x1fc)); @@ -859,7 +871,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct net_device *netdev = NULL; struct netxen_adapter *adapter = NULL; int i = 0, err; - int first_driver; int pci_func_id = PCI_FUNC(pdev->devfn); uint8_t revision_id; @@ -978,20 +989,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) */ netxen_check_options(adapter); - first_driver = 0; - if (NX_IS_REVISION_P3(revision_id)) { - if (adapter->ahw.pci_func == 0) - first_driver = 1; - } else { - if (adapter->portnum == 0) - first_driver = 1; - } - - if (first_driver) { - err = netxen_start_firmware(adapter); - if (err) - goto err_out_iounmap; - } + err = netxen_start_firmware(adapter); + if (err) + goto err_out_iounmap; nx_update_dma_mask(adapter); @@ -1062,8 +1062,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_disable_msi: netxen_teardown_intr(adapter); - if (first_driver) - netxen_free_adapter_offload(adapter); + netxen_free_adapter_offload(adapter); err_out_iounmap: netxen_cleanup_pci_map(adapter); @@ -1114,6 +1113,71 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) free_netdev(netdev); } +static int +netxen_nic_suspend(struct pci_dev *pdev, pm_message_t state) +{ + + struct netxen_adapter *adapter = pci_get_drvdata(pdev); + struct net_device *netdev = adapter->netdev; + + netif_device_detach(netdev); + + if (netif_running(netdev)) + netxen_nic_down(adapter, netdev); + + if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) + netxen_nic_detach(adapter); + + pci_save_state(pdev); + + if (netxen_nic_wol_supported(adapter)) { + pci_enable_wake(pdev, PCI_D3cold, 1); + pci_enable_wake(pdev, PCI_D3hot, 1); + } + + pci_disable_device(pdev); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); + + return 0; +} + +static int +netxen_nic_resume(struct pci_dev *pdev) +{ + struct netxen_adapter *adapter = pci_get_drvdata(pdev); + struct net_device *netdev = adapter->netdev; + int err; + + pci_set_power_state(pdev, PCI_D0); + pci_restore_state(pdev); + + err = pci_enable_device(pdev); + if (err) + return err; + + adapter->curr_window = 255; + + err = netxen_start_firmware(adapter); + if (err) { + dev_err(&pdev->dev, "failed to start firmware\n"); + return err; + } + + if (netif_running(netdev)) { + err = netxen_nic_attach(adapter); + if (err) + return err; + + err = netxen_nic_up(adapter, netdev); + if (err) + return err; + + netif_device_attach(netdev); + } + + return 0; +} + static int netxen_nic_open(struct net_device *netdev) { struct netxen_adapter *adapter = netdev_priv(netdev); @@ -1649,7 +1713,9 @@ static struct pci_driver netxen_driver = { .name = netxen_nic_driver_name, .id_table = netxen_pci_tbl, .probe = netxen_nic_probe, - .remove = __devexit_p(netxen_nic_remove) + .remove = __devexit_p(netxen_nic_remove), + .suspend = netxen_nic_suspend, + .resume = netxen_nic_resume }; /* Driver Registration on NetXen card */ -- cgit v1.2.3-70-g09d2 From 438627c77b877e445a4b918a50ff910a5ea2a12d Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Fri, 13 Mar 2009 14:52:03 +0000 Subject: netxen: sanitize variable names o remove max_ prefix from ring sizes, since they don't really represent max possible sizes. o cleanup naming of rx ring types (normal, jumbo, lro). o simplify logic to choose rx ring size, gig ports get half rx ring of 10 gig ports. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 47 ++++++++------------- drivers/net/netxen/netxen_nic_ctx.c | 16 ++++---- drivers/net/netxen/netxen_nic_ethtool.c | 6 +-- drivers/net/netxen/netxen_nic_hw.c | 2 +- drivers/net/netxen/netxen_nic_init.c | 54 ++++++++++-------------- drivers/net/netxen/netxen_nic_main.c | 73 +++++---------------------------- 6 files changed, 62 insertions(+), 136 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 75cb30f27ae..f00efe84744 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -79,15 +79,15 @@ #define PHAN_VENDOR_ID 0x4040 #define RCV_DESC_RINGSIZE \ - (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) + (sizeof(struct rcv_desc) * adapter->num_rxd) #define STATUS_DESC_RINGSIZE \ - (sizeof(struct status_desc)* adapter->max_rx_desc_count) + (sizeof(struct status_desc) * adapter->num_rxd) #define LRO_DESC_RINGSIZE \ - (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count) + (sizeof(rcvDesc_t) * adapter->num_lro_rxd) #define TX_RINGSIZE \ - (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) + (sizeof(struct netxen_cmd_buffer) * adapter->num_txd) #define RCV_BUFFSIZE \ - (sizeof(struct netxen_rx_buffer) * rds_ring->max_rx_desc_count) + (sizeof(struct netxen_rx_buffer) * rds_ring->num_desc) #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) #define NETXEN_RCV_PRODUCER_OFFSET 0 @@ -190,20 +190,9 @@ #define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */ -/* descriptor types */ -#define RCV_DESC_NORMAL 0x01 -#define RCV_DESC_JUMBO 0x02 -#define RCV_DESC_LRO 0x04 -#define RCV_DESC_NORMAL_CTXID 0 -#define RCV_DESC_JUMBO_CTXID 1 -#define RCV_DESC_LRO_CTXID 2 - -#define RCV_DESC_TYPE(ID) \ - ((ID == RCV_DESC_JUMBO_CTXID) \ - ? RCV_DESC_JUMBO \ - : ((ID == RCV_DESC_LRO_CTXID) \ - ? RCV_DESC_LRO : \ - (RCV_DESC_NORMAL))) +#define RCV_RING_NORMAL 0 +#define RCV_RING_JUMBO 1 +#define RCV_RING_LRO 2 #define MAX_CMD_DESCRIPTORS 4096 #define MAX_RCV_DESCRIPTORS 16384 @@ -815,8 +804,6 @@ struct netxen_hardware_context { int pci_func; }; -#define RCV_RING_LRO RCV_DESC_LRO - #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ #define ETHERNET_FCS_SIZE 4 @@ -842,16 +829,16 @@ struct netxen_adapter_stats { * be one Rcv Descriptor for normal packets, one for jumbo and may be others. */ struct nx_host_rds_ring { - u32 flags; u32 producer; - dma_addr_t phys_addr; u32 crb_rcv_producer; /* reg offset */ struct rcv_desc *desc_head; /* address of rx ring in Phantom */ - u32 max_rx_desc_count; - u32 dma_size; - u32 skb_size; struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */ struct list_head free_list; + u32 num_desc; + u32 dma_size; + u32 skb_size; + u32 flags; + dma_addr_t phys_addr; }; /* @@ -1244,10 +1231,10 @@ struct netxen_adapter { u32 crb_addr_cmd_producer; u32 crb_addr_cmd_consumer; - u32 max_tx_desc_count; - u32 max_rx_desc_count; - u32 max_jumbo_rx_desc_count; - u32 max_lro_rx_desc_count; + u32 num_txd; + u32 num_rxd; + u32 num_jumbo_rxd; + u32 num_lro_rxd; int max_rds_rings; diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c index d125dca0131..2e66335bd00 100644 --- a/drivers/net/netxen/netxen_nic_ctx.c +++ b/drivers/net/netxen/netxen_nic_ctx.c @@ -231,7 +231,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) rds_ring = &recv_ctx->rds_rings[i]; prq_rds[i].host_phys_addr = cpu_to_le64(rds_ring->phys_addr); - prq_rds[i].ring_size = cpu_to_le32(rds_ring->max_rx_desc_count); + prq_rds[i].ring_size = cpu_to_le32(rds_ring->num_desc); prq_rds[i].ring_kind = cpu_to_le32(i); prq_rds[i].buff_size = cpu_to_le64(rds_ring->dma_size); } @@ -241,7 +241,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) prq_sds[0].host_phys_addr = cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); - prq_sds[0].ring_size = cpu_to_le32(adapter->max_rx_desc_count); + prq_sds[0].ring_size = cpu_to_le32(adapter->num_rxd); /* only one msix vector for now */ prq_sds[0].msi_index = cpu_to_le16(0); @@ -362,7 +362,7 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter) prq_cds->host_phys_addr = cpu_to_le64(adapter->ahw.cmd_desc_phys_addr); - prq_cds->ring_size = cpu_to_le32(adapter->max_tx_desc_count); + prq_cds->ring_size = cpu_to_le32(adapter->num_txd); phys_addr = rq_phys_addr; err = netxen_issue_cmd(adapter, @@ -494,7 +494,7 @@ netxen_init_old_ctx(struct netxen_adapter *adapter) adapter->ctx_desc->cmd_ring_addr = cpu_to_le64(adapter->ahw.cmd_desc_phys_addr); adapter->ctx_desc->cmd_ring_size = - cpu_to_le32(adapter->max_tx_desc_count); + cpu_to_le32(adapter->num_txd); recv_ctx = &adapter->recv_ctx; @@ -504,12 +504,12 @@ netxen_init_old_ctx(struct netxen_adapter *adapter) adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr = cpu_to_le64(rds_ring->phys_addr); adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = - cpu_to_le32(rds_ring->max_rx_desc_count); + cpu_to_le32(rds_ring->num_desc); } adapter->ctx_desc->sts_ring_addr = cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); adapter->ctx_desc->sts_ring_size = - cpu_to_le32(adapter->max_rx_desc_count); + cpu_to_le32(adapter->num_rxd); adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_LO(func_id), lower32(adapter->ctx_desc_phys_addr)); @@ -562,7 +562,7 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) /* cmd desc ring */ addr = pci_alloc_consistent(adapter->pdev, sizeof(struct cmd_desc_type0) * - adapter->max_tx_desc_count, + adapter->num_txd, &hw->cmd_desc_phys_addr); if (addr == NULL) { @@ -669,7 +669,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) if (adapter->ahw.cmd_desc_head != NULL) { pci_free_consistent(adapter->pdev, sizeof(struct cmd_desc_type0) * - adapter->max_tx_desc_count, + adapter->num_txd, adapter->ahw.cmd_desc_head, adapter->ahw.cmd_desc_phys_addr); adapter->ahw.cmd_desc_head = NULL; diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 8b4bdfd6a11..a677ff89518 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c @@ -477,10 +477,10 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) ring->rx_pending = 0; ring->rx_jumbo_pending = 0; ring->rx_pending += adapter->recv_ctx. - rds_rings[RCV_DESC_NORMAL_CTXID].max_rx_desc_count; + rds_rings[RCV_RING_NORMAL].num_desc; ring->rx_jumbo_pending += adapter->recv_ctx. - rds_rings[RCV_DESC_JUMBO_CTXID].max_rx_desc_count; - ring->tx_pending = adapter->max_tx_desc_count; + rds_rings[RCV_RING_JUMBO].num_desc; + ring->tx_pending = adapter->num_txd; if (adapter->ahw.port_type == NETXEN_NIC_GBE) ring->rx_max_pending = MAX_RCV_DESCRIPTORS_1G; diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index c8faa53d27a..cea7300426b 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -515,7 +515,7 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter, &cmd_desc_arr[i], sizeof(struct cmd_desc_type0)); producer = get_next_index(producer, - adapter->max_tx_desc_count); + adapter->num_txd); i++; } while (i != nr_elements); diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 120b480c1e8..d722589b1ce 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -153,7 +153,7 @@ void netxen_release_rx_buffers(struct netxen_adapter *adapter) recv_ctx = &adapter->recv_ctx; for (ring = 0; ring < adapter->max_rds_rings; ring++) { rds_ring = &recv_ctx->rds_rings[ring]; - for (i = 0; i < rds_ring->max_rx_desc_count; ++i) { + for (i = 0; i < rds_ring->num_desc; ++i) { rx_buf = &(rds_ring->rx_buf_arr[i]); if (rx_buf->state == NETXEN_BUFFER_FREE) continue; @@ -174,7 +174,7 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter) int i, j; cmd_buf = adapter->cmd_buf_arr; - for (i = 0; i < adapter->max_tx_desc_count; i++) { + for (i = 0; i < adapter->num_txd; i++) { buffrag = cmd_buf->frag_array; if (buffrag->dma) { pci_unmap_single(adapter->pdev, buffrag->dma, @@ -190,7 +190,6 @@ void netxen_release_tx_buffers(struct netxen_adapter *adapter) buffrag->dma = 0ULL; } } - /* Free the skb we received in netxen_nic_xmit_frame */ if (cmd_buf->skb) { dev_kfree_skb_any(cmd_buf->skb); cmd_buf->skb = NULL; @@ -241,11 +240,9 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) recv_ctx = &adapter->recv_ctx; for (ring = 0; ring < adapter->max_rds_rings; ring++) { rds_ring = &recv_ctx->rds_rings[ring]; - switch (RCV_DESC_TYPE(ring)) { - case RCV_DESC_NORMAL: - rds_ring->max_rx_desc_count = - adapter->max_rx_desc_count; - rds_ring->flags = RCV_DESC_NORMAL; + switch (ring) { + case RCV_RING_NORMAL: + rds_ring->num_desc = adapter->num_rxd; if (adapter->ahw.cut_through) { rds_ring->dma_size = NX_CT_DEFAULT_RX_BUF_LEN; @@ -258,10 +255,8 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) } break; - case RCV_DESC_JUMBO: - rds_ring->max_rx_desc_count = - adapter->max_jumbo_rx_desc_count; - rds_ring->flags = RCV_DESC_JUMBO; + case RCV_RING_JUMBO: + rds_ring->num_desc = adapter->num_jumbo_rxd; if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) rds_ring->dma_size = NX_P3_RX_JUMBO_BUF_MAX_LEN; @@ -273,9 +268,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) break; case RCV_RING_LRO: - rds_ring->max_rx_desc_count = - adapter->max_lro_rx_desc_count; - rds_ring->flags = RCV_DESC_LRO; + rds_ring->num_desc = adapter->num_lro_rxd; rds_ring->dma_size = RX_LRO_DMA_MAP_LEN; rds_ring->skb_size = MAX_RX_LRO_BUFFER_LENGTH; break; @@ -296,7 +289,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) * Now go through all of them, set reference handles * and put them in the queues. */ - num_rx_bufs = rds_ring->max_rx_desc_count; + num_rx_bufs = rds_ring->num_desc; rx_buf = rds_ring->rx_buf_arr; for (i = 0; i < num_rx_bufs; i++) { list_add_tail(&rx_buf->list, @@ -848,16 +841,15 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, struct nx_host_rds_ring *rds_ring; desc_ctx = netxen_get_sts_type(sts_data); - if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { + if (unlikely(desc_ctx >= adapter->max_rds_rings)) return; - } rds_ring = &recv_ctx->rds_rings[desc_ctx]; - if (unlikely(index > rds_ring->max_rx_desc_count)) { + if (unlikely(index > rds_ring->num_desc)) return; - } + buffer = &rds_ring->rx_buf_arr[index]; - if (desc_ctx == RCV_DESC_LRO_CTXID) { + if (desc_ctx == RCV_RING_LRO) { buffer->lro_current_frags++; if (netxen_get_sts_desc_lro_last_frag(desc)) { buffer->lro_expected_frags = @@ -875,7 +867,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, if (!skb) return; - if (desc_ctx == RCV_DESC_LRO_CTXID) { + if (desc_ctx == RCV_RING_LRO) { /* True length was only available on the last pkt */ skb_put(skb, buffer->lro_length); } else { @@ -921,8 +913,7 @@ netxen_process_rcv_ring(struct netxen_adapter *adapter, int max) desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM); - consumer = get_next_index(consumer, - adapter->max_rx_desc_count); + consumer = get_next_index(consumer, adapter->num_rxd); count++; } @@ -973,7 +964,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) } last_consumer = get_next_index(last_consumer, - adapter->max_tx_desc_count); + adapter->num_txd); if (++count >= MAX_STATUS_HANDLE) break; } @@ -1060,7 +1051,7 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid) pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); - producer = get_next_index(producer, rds_ring->max_rx_desc_count); + producer = get_next_index(producer, rds_ring->num_desc); } /* if we did allocate buffers, then write the count to Phantom */ if (count) { @@ -1068,7 +1059,7 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid) /* Window = 1 */ adapter->pci_write_normalize(adapter, rds_ring->crb_rcv_producer, - (producer-1) & (rds_ring->max_rx_desc_count-1)); + (producer-1) & (rds_ring->num_desc-1)); if (adapter->fw_major < 4) { /* @@ -1079,9 +1070,8 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid) netxen_set_msg_peg_id(msg, NETXEN_RCV_PEG_DB_ID); netxen_set_msg_privid(msg); netxen_set_msg_count(msg, - ((producer - - 1) & (rds_ring-> - max_rx_desc_count - 1))); + ((producer - 1) & + (rds_ring->num_desc - 1))); netxen_set_msg_ctxid(msg, adapter->portnum); netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); writel(msg, @@ -1141,7 +1131,7 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid) pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); pdesc->addr_buffer = cpu_to_le64(buffer->dma); - producer = get_next_index(producer, rds_ring->max_rx_desc_count); + producer = get_next_index(producer, rds_ring->num_desc); } /* if we did allocate buffers, then write the count to Phantom */ @@ -1150,7 +1140,7 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid) /* Window = 1 */ adapter->pci_write_normalize(adapter, rds_ring->crb_rcv_producer, - (producer-1) & (rds_ring->max_rx_desc_count-1)); + (producer - 1) & (rds_ring->num_desc - 1)); wmb(); } } diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 555b4596b0f..00eaeee235e 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -212,62 +212,19 @@ nx_update_dma_mask(struct netxen_adapter *adapter) static void netxen_check_options(struct netxen_adapter *adapter) { - switch (adapter->ahw.board_type) { - case NETXEN_BRDTYPE_P3_HMEZ: - case NETXEN_BRDTYPE_P3_XG_LOM: - case NETXEN_BRDTYPE_P3_10G_CX4: - case NETXEN_BRDTYPE_P3_10G_CX4_LP: - case NETXEN_BRDTYPE_P3_IMEZ: - case NETXEN_BRDTYPE_P3_10G_SFP_PLUS: - case NETXEN_BRDTYPE_P3_10G_SFP_QT: - case NETXEN_BRDTYPE_P3_10G_SFP_CT: - case NETXEN_BRDTYPE_P3_10G_XFP: - case NETXEN_BRDTYPE_P3_10000_BASE_T: - adapter->msix_supported = !!use_msi_x; - adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G; - break; - - case NETXEN_BRDTYPE_P2_SB31_10G: - case NETXEN_BRDTYPE_P2_SB31_10G_CX4: - case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: - case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: - adapter->msix_supported = 0; - adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G; - break; + if (adapter->ahw.port_type == NETXEN_NIC_XGBE) + adapter->num_rxd = MAX_RCV_DESCRIPTORS_10G; + else if (adapter->ahw.port_type == NETXEN_NIC_GBE) + adapter->num_rxd = MAX_RCV_DESCRIPTORS_1G; - case NETXEN_BRDTYPE_P3_REF_QG: - case NETXEN_BRDTYPE_P3_4_GB: - case NETXEN_BRDTYPE_P3_4_GB_MM: - adapter->msix_supported = !!use_msi_x; - adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; - break; - - case NETXEN_BRDTYPE_P2_SB35_4G: - case NETXEN_BRDTYPE_P2_SB31_2G: - adapter->msix_supported = 0; - adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; - break; - - case NETXEN_BRDTYPE_P3_10G_TP: + if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) adapter->msix_supported = !!use_msi_x; - if (adapter->ahw.port_type == NETXEN_NIC_XGBE) - adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_10G; - else - adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; - break; - - default: + else adapter->msix_supported = 0; - adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS_1G; - - printk(KERN_WARNING "Unknown board type(0x%x)\n", - adapter->ahw.board_type); - break; - } - adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS_HOST; - adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; - adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS; + adapter->num_txd = MAX_CMD_DESCRIPTORS_HOST; + adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS; + adapter->num_lro_rxd = MAX_LRO_RCV_DESCRIPTORS; adapter->max_possible_rss_rings = 1; return; @@ -983,12 +940,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) break; } - /* - * This call will setup various max rx/tx counts. - * It must be done before any buffer/ring allocations. - */ - netxen_check_options(adapter); - err = netxen_start_firmware(adapter); if (err) goto err_out_iounmap; @@ -1008,9 +959,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) adapter->physical_port = i; } - adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED); - - netxen_set_msix_bit(pdev, 0); + netxen_check_options(adapter); netxen_setup_intr(adapter); @@ -1307,7 +1256,7 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) u32 producer, consumer; int frag_count, no_of_desc; - u32 num_txd = adapter->max_tx_desc_count; + u32 num_txd = adapter->num_txd; bool is_tso = false; frag_count = skb_shinfo(skb)->nr_frags + 1; -- cgit v1.2.3-70-g09d2 From d8b100c5da003b6f8c410453e1e6e74ced8d1cc1 Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Fri, 13 Mar 2009 14:52:05 +0000 Subject: netxen: add receive side scaling (rss) support This patch enables the load balancing capability of firmware and hardware to spray traffic into different cpus through separate rx msix interrupts. The feature is being enabled for NX3031, NX2031 (old) will be enabled later. This depends on msi-x and compatibility with msi and legacy is maintained by enabling single rx ring. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 74 ++++++++----- drivers/net/netxen/netxen_nic_ctx.c | 117 +++++++++++--------- drivers/net/netxen/netxen_nic_hw.c | 47 ++++++++ drivers/net/netxen/netxen_nic_init.c | 201 +++++++++++++++++++++-------------- drivers/net/netxen/netxen_nic_main.c | 157 ++++++++++++++++++++------- 5 files changed, 404 insertions(+), 192 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 56fad22fed9..595171d943f 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -78,16 +78,17 @@ #define PHAN_VENDOR_ID 0x4040 -#define RCV_DESC_RINGSIZE \ - (sizeof(struct rcv_desc) * adapter->num_rxd) -#define STATUS_DESC_RINGSIZE \ - (sizeof(struct status_desc) * adapter->num_rxd) -#define LRO_DESC_RINGSIZE \ - (sizeof(rcvDesc_t) * adapter->num_lro_rxd) -#define TX_RINGSIZE \ - (sizeof(struct netxen_cmd_buffer) * adapter->num_txd) -#define RCV_BUFFSIZE \ +#define RCV_DESC_RINGSIZE(rds_ring) \ + (sizeof(struct rcv_desc) * (rds_ring)->num_desc) +#define RCV_BUFF_RINGSIZE(rds_ring) \ (sizeof(struct netxen_rx_buffer) * rds_ring->num_desc) +#define STATUS_DESC_RINGSIZE(sds_ring) \ + (sizeof(struct status_desc) * (sds_ring)->num_desc) +#define TX_BUFF_RINGSIZE(adapter) \ + (sizeof(struct netxen_cmd_buffer) * adapter->num_txd) +#define TX_DESC_RINGSIZE(adapter) \ + (sizeof(struct cmd_desc_type0) * adapter->num_txd) + #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) #define NETXEN_RCV_PRODUCER_OFFSET 0 @@ -188,7 +189,8 @@ /* Host writes the following to notify that it has done the init-handshake */ #define PHAN_INITIALIZE_ACK 0xf00f -#define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */ +#define NUM_RCV_DESC_RINGS 3 +#define NUM_STS_DESC_RINGS 4 #define RCV_RING_NORMAL 0 #define RCV_RING_JUMBO 1 @@ -722,7 +724,7 @@ extern char netxen_nic_driver_name[]; #endif /* Number of status descriptors to handle per interrupt */ -#define MAX_STATUS_HANDLE (128) +#define MAX_STATUS_HANDLE (64) /* * netxen_skb_frag{} is to contain mapping info for each SG list. This @@ -827,17 +829,37 @@ struct netxen_adapter_stats { */ struct nx_host_rds_ring { u32 producer; - u32 crb_rcv_producer; /* reg offset */ - struct rcv_desc *desc_head; /* address of rx ring in Phantom */ - struct netxen_rx_buffer *rx_buf_arr; /* rx buffers for receive */ - struct list_head free_list; + u32 crb_rcv_producer; u32 num_desc; u32 dma_size; u32 skb_size; u32 flags; + struct rcv_desc *desc_head; + struct netxen_rx_buffer *rx_buf_arr; + struct list_head free_list; + spinlock_t lock; dma_addr_t phys_addr; }; +struct nx_host_sds_ring { + u32 consumer; + u32 crb_sts_consumer; + u32 crb_intr_mask; + u32 num_desc; + + struct status_desc *desc_head; + struct netxen_adapter *adapter; + struct napi_struct napi; + struct list_head free_list[NUM_RCV_DESC_RINGS]; + + u16 clean_tx; + u16 post_rxd; + int irq; + + dma_addr_t phys_addr; + char name[IFNAMSIZ+4]; +}; + /* * Receive context. There is one such structure per instance of the * receive processing. Any state information that is relevant to @@ -850,10 +872,7 @@ struct netxen_recv_context { u16 virt_port; struct nx_host_rds_ring rds_rings[NUM_RCV_DESC_RINGS]; - u32 status_rx_consumer; - u32 crb_sts_consumer; /* reg offset */ - dma_addr_t rcv_status_desc_phys_addr; - struct status_desc *rcv_status_desc_head; + struct nx_host_sds_ring sds_rings[NUM_STS_DESC_RINGS]; }; /* New HW context creation */ @@ -1179,13 +1198,13 @@ typedef struct { #define NETXEN_IS_MSI_FAMILY(adapter) \ ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED)) -#define MSIX_ENTRIES_PER_ADAPTER 1 +#define MSIX_ENTRIES_PER_ADAPTER NUM_STS_DESC_RINGS #define NETXEN_MSIX_TBL_SPACE 8192 #define NETXEN_PCI_REG_MSIX_TBL 0x44 #define NETXEN_DB_MAPSIZE_BYTES 0x1000 -#define NETXEN_NETDEV_WEIGHT 120 +#define NETXEN_NETDEV_WEIGHT 128 #define NETXEN_ADAPTER_UP_MAGIC 777 #define NETXEN_NIC_PEG_TUNE 0 @@ -1200,7 +1219,6 @@ struct netxen_adapter { struct net_device *netdev; struct pci_dev *pdev; int pci_using_dac; - struct napi_struct napi; struct net_device_stats net_stats; int mtu; int portnum; @@ -1212,7 +1230,6 @@ struct netxen_adapter { nx_mac_list_t *mac_list; struct netxen_legacy_intr_set legacy_intr; - u32 crb_intr_mask; struct work_struct watchdog_task; struct timer_list watchdog_timer; @@ -1227,6 +1244,7 @@ struct netxen_adapter { u32 last_cmd_consumer; u32 crb_addr_cmd_producer; u32 crb_addr_cmd_consumer; + spinlock_t tx_clean_lock; u32 num_txd; u32 num_rxd; @@ -1234,6 +1252,7 @@ struct netxen_adapter { u32 num_lro_rxd; int max_rds_rings; + int max_sds_rings; u32 flags; u32 irq; @@ -1243,8 +1262,7 @@ struct netxen_adapter { u32 fw_major; u32 fw_version; - u8 msix_supported; - u8 max_possible_rss_rings; + int msix_supported; struct msix_entry msix_entries[MSIX_ENTRIES_PER_ADAPTER]; struct netxen_adapter_stats stats; @@ -1447,14 +1465,16 @@ void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); int netxen_init_firmware(struct netxen_adapter *adapter); void netxen_nic_clear_stats(struct netxen_adapter *adapter); void netxen_watchdog_task(struct work_struct *work); -void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid); +void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid, + struct nx_host_rds_ring *rds_ring); int netxen_process_cmd_ring(struct netxen_adapter *adapter); -int netxen_process_rcv_ring(struct netxen_adapter *adapter, int max); +int netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max); void netxen_p2_nic_set_multi(struct net_device *netdev); void netxen_p3_nic_set_multi(struct net_device *netdev); void netxen_p3_free_mac_list(struct netxen_adapter *adapter); int netxen_p3_nic_set_promisc(struct netxen_adapter *adapter, u32); int netxen_config_intr_coalesce(struct netxen_adapter *adapter); +int netxen_config_rss(struct netxen_adapter *adapter, int enable); int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu); int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); diff --git a/drivers/net/netxen/netxen_nic_ctx.c b/drivers/net/netxen/netxen_nic_ctx.c index 2e66335bd00..9234473bc08 100644 --- a/drivers/net/netxen/netxen_nic_ctx.c +++ b/drivers/net/netxen/netxen_nic_ctx.c @@ -169,6 +169,7 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) nx_cardrsp_rds_ring_t *prsp_rds; nx_cardrsp_sds_ring_t *prsp_sds; struct nx_host_rds_ring *rds_ring; + struct nx_host_sds_ring *sds_ring; dma_addr_t hostrq_phys_addr, cardrsp_phys_addr; u64 phys_addr; @@ -181,9 +182,8 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; - /* only one sds ring for now */ nrds_rings = adapter->max_rds_rings; - nsds_rings = 1; + nsds_rings = adapter->max_sds_rings; rq_size = SIZEOF_HOSTRQ_RX(nx_hostrq_rx_ctx_t, nrds_rings, nsds_rings); @@ -239,11 +239,14 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) prq_sds = (nx_hostrq_sds_ring_t *)(prq->data + le32_to_cpu(prq->sds_ring_offset)); - prq_sds[0].host_phys_addr = - cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); - prq_sds[0].ring_size = cpu_to_le32(adapter->num_rxd); - /* only one msix vector for now */ - prq_sds[0].msi_index = cpu_to_le16(0); + for (i = 0; i < nsds_rings; i++) { + + sds_ring = &recv_ctx->sds_rings[i]; + + prq_sds[i].host_phys_addr = cpu_to_le64(sds_ring->phys_addr); + prq_sds[i].ring_size = cpu_to_le32(sds_ring->num_desc); + prq_sds[i].msi_index = cpu_to_le16(i); + } phys_addr = hostrq_phys_addr; err = netxen_issue_cmd(adapter, @@ -272,11 +275,16 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter) prsp_sds = ((nx_cardrsp_sds_ring_t *) &prsp->data[le32_to_cpu(prsp->sds_ring_offset)]); - reg = le32_to_cpu(prsp_sds[0].host_consumer_crb); - recv_ctx->crb_sts_consumer = NETXEN_NIC_REG(reg - 0x200); - reg = le32_to_cpu(prsp_sds[0].interrupt_crb); - adapter->crb_intr_mask = NETXEN_NIC_REG(reg - 0x200); + for (i = 0; i < le16_to_cpu(prsp->num_sds_rings); i++) { + sds_ring = &recv_ctx->sds_rings[i]; + + reg = le32_to_cpu(prsp_sds[i].host_consumer_crb); + sds_ring->crb_sts_consumer = NETXEN_NIC_REG(reg - 0x200); + + reg = le32_to_cpu(prsp_sds[i].interrupt_crb); + sds_ring->crb_intr_mask = NETXEN_NIC_REG(reg - 0x200); + } recv_ctx->state = le32_to_cpu(prsp->host_ctx_state); recv_ctx->context_id = le16_to_cpu(prsp->context_id); @@ -488,6 +496,7 @@ netxen_init_old_ctx(struct netxen_adapter *adapter) { struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; + struct nx_host_sds_ring *sds_ring; int ring; int func_id = adapter->portnum; @@ -506,10 +515,9 @@ netxen_init_old_ctx(struct netxen_adapter *adapter) adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = cpu_to_le32(rds_ring->num_desc); } - adapter->ctx_desc->sts_ring_addr = - cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); - adapter->ctx_desc->sts_ring_size = - cpu_to_le32(adapter->num_rxd); + sds_ring = &recv_ctx->sds_rings[0]; + adapter->ctx_desc->sts_ring_addr = cpu_to_le64(sds_ring->phys_addr); + adapter->ctx_desc->sts_ring_size = cpu_to_le32(sds_ring->num_desc); adapter->pci_write_normalize(adapter, CRB_CTX_ADDR_REG_LO(func_id), lower32(adapter->ctx_desc_phys_addr)); @@ -534,6 +542,10 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) int ring; struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; + struct nx_host_sds_ring *sds_ring; + + struct pci_dev *pdev = adapter->pdev; + struct net_device *netdev = adapter->netdev; err = netxen_receive_peg_ready(adapter); if (err) { @@ -542,12 +554,12 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) return err; } - addr = pci_alloc_consistent(adapter->pdev, + addr = pci_alloc_consistent(pdev, sizeof(struct netxen_ring_ctx) + sizeof(uint32_t), &adapter->ctx_desc_phys_addr); if (addr == NULL) { - DPRINTK(ERR, "failed to allocate hw context\n"); + dev_err(&pdev->dev, "failed to allocate hw context\n"); return -ENOMEM; } memset(addr, 0, sizeof(struct netxen_ring_ctx)); @@ -560,14 +572,13 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) (__le32 *)(((char *)addr) + sizeof(struct netxen_ring_ctx)); /* cmd desc ring */ - addr = pci_alloc_consistent(adapter->pdev, - sizeof(struct cmd_desc_type0) * - adapter->num_txd, + addr = pci_alloc_consistent(pdev, + TX_DESC_RINGSIZE(adapter), &hw->cmd_desc_phys_addr); if (addr == NULL) { - printk(KERN_ERR "%s failed to allocate tx desc ring\n", - netxen_nic_driver_name); + dev_err(&pdev->dev, "%s: failed to allocate tx desc ring\n", + netdev->name); return -ENOMEM; } @@ -576,15 +587,14 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) recv_ctx = &adapter->recv_ctx; for (ring = 0; ring < adapter->max_rds_rings; ring++) { - /* rx desc ring */ rds_ring = &recv_ctx->rds_rings[ring]; addr = pci_alloc_consistent(adapter->pdev, - RCV_DESC_RINGSIZE, + RCV_DESC_RINGSIZE(rds_ring), &rds_ring->phys_addr); if (addr == NULL) { - printk(KERN_ERR "%s failed to allocate rx " - "desc ring[%d]\n", - netxen_nic_driver_name, ring); + dev_err(&pdev->dev, + "%s: failed to allocate rds ring [%d]\n", + netdev->name, ring); err = -ENOMEM; goto err_out_free; } @@ -596,22 +606,22 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) crb_rcv_producer[ring]; } - /* status desc ring */ - addr = pci_alloc_consistent(adapter->pdev, - STATUS_DESC_RINGSIZE, - &recv_ctx->rcv_status_desc_phys_addr); - if (addr == NULL) { - printk(KERN_ERR "%s failed to allocate sts desc ring\n", - netxen_nic_driver_name); - err = -ENOMEM; - goto err_out_free; + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + + addr = pci_alloc_consistent(adapter->pdev, + STATUS_DESC_RINGSIZE(sds_ring), + &sds_ring->phys_addr); + if (addr == NULL) { + dev_err(&pdev->dev, + "%s: failed to allocate sds ring [%d]\n", + netdev->name, ring); + err = -ENOMEM; + goto err_out_free; + } + sds_ring->desc_head = (struct status_desc *)addr; } - recv_ctx->rcv_status_desc_head = (struct status_desc *)addr; - if (adapter->fw_major < 4) - recv_ctx->crb_sts_consumer = - recv_crb_registers[adapter->portnum]. - crb_sts_consumer; if (adapter->fw_major >= 4) { adapter->intr_scheme = INTR_SCHEME_PERPORT; @@ -624,12 +634,16 @@ int netxen_alloc_hw_resources(struct netxen_adapter *adapter) if (err) goto err_out_free; } else { + sds_ring = &recv_ctx->sds_rings[0]; + sds_ring->crb_sts_consumer = + recv_crb_registers[adapter->portnum].crb_sts_consumer; adapter->intr_scheme = adapter->pci_read_normalize(adapter, CRB_NIC_CAPABILITIES_FW); adapter->msi_mode = adapter->pci_read_normalize(adapter, CRB_NIC_MSI_MODE_FW); - adapter->crb_intr_mask = sw_int_mask[adapter->portnum]; + recv_ctx->sds_rings[0].crb_intr_mask = + sw_int_mask[adapter->portnum]; err = netxen_init_old_ctx(adapter); if (err) { @@ -650,6 +664,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) { struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; + struct nx_host_sds_ring *sds_ring; int ring; if (adapter->fw_major >= 4) { @@ -681,19 +696,23 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) if (rds_ring->desc_head != NULL) { pci_free_consistent(adapter->pdev, - RCV_DESC_RINGSIZE, + RCV_DESC_RINGSIZE(rds_ring), rds_ring->desc_head, rds_ring->phys_addr); rds_ring->desc_head = NULL; } } - if (recv_ctx->rcv_status_desc_head != NULL) { - pci_free_consistent(adapter->pdev, - STATUS_DESC_RINGSIZE, - recv_ctx->rcv_status_desc_head, - recv_ctx->rcv_status_desc_phys_addr); - recv_ctx->rcv_status_desc_head = NULL; + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + + if (sds_ring->desc_head != NULL) { + pci_free_consistent(adapter->pdev, + STATUS_DESC_RINGSIZE(sds_ring), + sds_ring->desc_head, + sds_ring->phys_addr); + sds_ring->desc_head = NULL; + } } } diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index cea7300426b..c89c791e281 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c @@ -670,6 +670,53 @@ int netxen_config_intr_coalesce(struct netxen_adapter *adapter) return rv; } +#define RSS_HASHTYPE_IP_TCP 0x3 + +int netxen_config_rss(struct netxen_adapter *adapter, int enable) +{ + nx_nic_req_t req; + u64 word; + int i, rv; + + u64 key[] = { 0xbeac01fa6a42b73bULL, 0x8030f20c77cb2da3ULL, + 0xae7b30b4d0ca2bcbULL, 0x43a38fb04167253dULL, + 0x255b0ec26d5a56daULL }; + + + memset(&req, 0, sizeof(nx_nic_req_t)); + req.qhdr = cpu_to_le64(NX_HOST_REQUEST << 23); + + word = NX_NIC_H2C_OPCODE_CONFIG_RSS | ((u64)adapter->portnum << 16); + req.req_hdr = cpu_to_le64(word); + + /* + * RSS request: + * bits 3-0: hash_method + * 5-4: hash_type_ipv4 + * 7-6: hash_type_ipv6 + * 8: enable + * 9: use indirection table + * 47-10: reserved + * 63-48: indirection table mask + */ + word = ((u64)(RSS_HASHTYPE_IP_TCP & 0x3) << 4) | + ((u64)(RSS_HASHTYPE_IP_TCP & 0x3) << 6) | + ((u64)(enable & 0x1) << 8) | + ((0x7ULL) << 48); + req.words[0] = cpu_to_le64(word); + for (i = 0; i < 5; i++) + req.words[i+1] = cpu_to_le64(key[i]); + + + rv = netxen_send_cmd_descs(adapter, (struct cmd_desc_type0 *)&req, 1); + if (rv != 0) { + printk(KERN_ERR "%s: could not configure RSS\n", + adapter->netdev->name); + } + + return rv; +} + /* * netxen_nic_change_mtu - Change the Maximum Transfer Unit * @returns 0 on success, negative on failure diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 1b8f79f7f8c..0759c35f16a 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -50,7 +50,8 @@ static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM]; #define NETXEN_NIC_XDMA_RESET 0x8000ff static void -netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid); +netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, + struct nx_host_rds_ring *rds_ring); static void crb_addr_transform_setup(void) { @@ -222,19 +223,21 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) { struct netxen_recv_context *recv_ctx; struct nx_host_rds_ring *rds_ring; + struct nx_host_sds_ring *sds_ring; struct netxen_rx_buffer *rx_buf; int ring, i, num_rx_bufs; struct netxen_cmd_buffer *cmd_buf_arr; struct net_device *netdev = adapter->netdev; - cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); + cmd_buf_arr = + (struct netxen_cmd_buffer *)vmalloc(TX_BUFF_RINGSIZE(adapter)); if (cmd_buf_arr == NULL) { printk(KERN_ERR "%s: Failed to allocate cmd buffer ring\n", netdev->name); return -ENOMEM; } - memset(cmd_buf_arr, 0, TX_RINGSIZE); + memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(adapter)); adapter->cmd_buf_arr = cmd_buf_arr; recv_ctx = &adapter->recv_ctx; @@ -275,7 +278,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) } rds_ring->rx_buf_arr = (struct netxen_rx_buffer *) - vmalloc(RCV_BUFFSIZE); + vmalloc(RCV_BUFF_RINGSIZE(rds_ring)); if (rds_ring->rx_buf_arr == NULL) { printk(KERN_ERR "%s: Failed to allocate " "rx buffer ring %d\n", @@ -283,7 +286,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) /* free whatever was already allocated */ goto err_out; } - memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE); + memset(rds_ring->rx_buf_arr, 0, RCV_BUFF_RINGSIZE(rds_ring)); INIT_LIST_HEAD(&rds_ring->free_list); /* * Now go through all of them, set reference handles @@ -298,6 +301,19 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter) rx_buf->state = NETXEN_BUFFER_FREE; rx_buf++; } + spin_lock_init(&rds_ring->lock); + } + + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + sds_ring->irq = adapter->msix_entries[ring].vector; + sds_ring->clean_tx = (ring == 0); + sds_ring->post_rxd = (ring == 0); + sds_ring->adapter = adapter; + sds_ring->num_desc = adapter->num_rxd; + + for (i = 0; i < NUM_RCV_DESC_RINGS; i++) + INIT_LIST_HEAD(&sds_ring->free_list[i]); } return 0; @@ -793,6 +809,40 @@ int netxen_receive_peg_ready(struct netxen_adapter *adapter) return 0; } +static int +netxen_alloc_rx_skb(struct netxen_adapter *adapter, + struct nx_host_rds_ring *rds_ring, + struct netxen_rx_buffer *buffer) +{ + struct sk_buff *skb; + dma_addr_t dma; + struct pci_dev *pdev = adapter->pdev; + + buffer->skb = dev_alloc_skb(rds_ring->skb_size); + if (!buffer->skb) + return 1; + + skb = buffer->skb; + + if (!adapter->ahw.cut_through) + skb_reserve(skb, 2); + + dma = pci_map_single(pdev, skb->data, + rds_ring->dma_size, PCI_DMA_FROMDEVICE); + + if (pci_dma_mapping_error(pdev, dma)) { + dev_kfree_skb_any(skb); + buffer->skb = NULL; + return 1; + } + + buffer->skb = skb; + buffer->dma = dma; + buffer->state = NETXEN_BUFFER_BUSY; + + return 0; +} + static struct sk_buff *netxen_process_rxbuf(struct netxen_adapter *adapter, struct nx_host_rds_ring *rds_ring, u16 index, u16 cksum) { @@ -817,14 +867,12 @@ static struct sk_buff *netxen_process_rxbuf(struct netxen_adapter *adapter, skb->dev = adapter->netdev; buffer->skb = NULL; - no_skb: buffer->state = NETXEN_BUFFER_FREE; - list_add_tail(&buffer->list, &rds_ring->free_list); return skb; } -static void +static struct netxen_rx_buffer * netxen_process_rcv(struct netxen_adapter *adapter, int ring, int index, int length, int cksum, int pkt_offset) { @@ -835,13 +883,13 @@ netxen_process_rcv(struct netxen_adapter *adapter, struct nx_host_rds_ring *rds_ring = &recv_ctx->rds_rings[ring]; if (unlikely(index > rds_ring->num_desc)) - return; + return NULL; buffer = &rds_ring->rx_buf_arr[index]; skb = netxen_process_rxbuf(adapter, rds_ring, index, cksum); if (!skb) - return; + return buffer; if (length > rds_ring->skb_size) skb_put(skb, rds_ring->skb_size); @@ -858,21 +906,31 @@ netxen_process_rcv(struct netxen_adapter *adapter, adapter->stats.no_rcv++; adapter->stats.rxbytes += length; + + return buffer; } +#define netxen_merge_rx_buffers(list, head) \ + do { list_splice_tail_init(list, head); } while (0); + int -netxen_process_rcv_ring(struct netxen_adapter *adapter, int max) +netxen_process_rcv_ring(struct nx_host_sds_ring *sds_ring, int max) { - struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; - struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; + struct netxen_adapter *adapter = sds_ring->adapter; + + struct list_head *cur; + struct status_desc *desc; - u32 consumer = recv_ctx->status_rx_consumer; + struct netxen_rx_buffer *rxbuf; + + u32 consumer = sds_ring->consumer; + int count = 0; u64 sts_data; int opcode, ring, index, length, cksum, pkt_offset; while (count < max) { - desc = &desc_head[consumer]; + desc = &sds_ring->desc_head[consumer]; sts_data = le64_to_cpu(desc->status_desc_data); if (!(sts_data & STATUS_OWNER_HOST)) @@ -889,22 +947,41 @@ netxen_process_rcv_ring(struct netxen_adapter *adapter, int max) cksum = netxen_get_sts_status(sts_data); pkt_offset = netxen_get_sts_pkt_offset(sts_data); - netxen_process_rcv(adapter, ring, index, + rxbuf = netxen_process_rcv(adapter, ring, index, length, cksum, pkt_offset); + if (rxbuf) + list_add_tail(&rxbuf->list, &sds_ring->free_list[ring]); + desc->status_desc_data = cpu_to_le64(STATUS_OWNER_PHANTOM); - consumer = get_next_index(consumer, adapter->num_rxd); + consumer = get_next_index(consumer, sds_ring->num_desc); count++; } - for (ring = 0; ring < adapter->max_rds_rings; ring++) - netxen_post_rx_buffers_nodb(adapter, ring); + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + struct nx_host_rds_ring *rds_ring = + &adapter->recv_ctx.rds_rings[ring]; + + if (!list_empty(&sds_ring->free_list[ring])) { + list_for_each(cur, &sds_ring->free_list[ring]) { + rxbuf = list_entry(cur, + struct netxen_rx_buffer, list); + netxen_alloc_rx_skb(adapter, rds_ring, rxbuf); + } + spin_lock(&rds_ring->lock); + netxen_merge_rx_buffers(&sds_ring->free_list[ring], + &rds_ring->free_list); + spin_unlock(&rds_ring->lock); + } + + netxen_post_rx_buffers_nodb(adapter, rds_ring); + } if (count) { - recv_ctx->status_rx_consumer = consumer; + sds_ring->consumer = consumer; adapter->pci_write_normalize(adapter, - recv_ctx->crb_sts_consumer, consumer); + sds_ring->crb_sts_consumer, consumer); } return count; @@ -921,6 +998,9 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) struct netxen_skb_frag *frag; int done = 0; + if (!spin_trylock(&adapter->tx_clean_lock)) + return 1; + last_consumer = adapter->last_cmd_consumer; barrier(); /* cmd_consumer can change underneath */ consumer = le32_to_cpu(*(adapter->cmd_consumer)); @@ -976,63 +1056,46 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) barrier(); /* cmd_consumer can change underneath */ consumer = le32_to_cpu(*(adapter->cmd_consumer)); done = (last_consumer == consumer); + spin_unlock(&adapter->tx_clean_lock); return (done); } void -netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid) +netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid, + struct nx_host_rds_ring *rds_ring) { - struct pci_dev *pdev = adapter->pdev; - struct sk_buff *skb; - struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; - struct nx_host_rds_ring *rds_ring = NULL; - uint producer; struct rcv_desc *pdesc; struct netxen_rx_buffer *buffer; - int count = 0; + int producer, count = 0; netxen_ctx_msg msg = 0; - dma_addr_t dma; struct list_head *head; - rds_ring = &recv_ctx->rds_rings[ringid]; - producer = rds_ring->producer; - head = &rds_ring->free_list; + spin_lock(&rds_ring->lock); + head = &rds_ring->free_list; while (!list_empty(head)) { - skb = dev_alloc_skb(rds_ring->skb_size); - if (unlikely(!skb)) { - break; - } - - if (!adapter->ahw.cut_through) - skb_reserve(skb, 2); + buffer = list_entry(head->next, struct netxen_rx_buffer, list); - dma = pci_map_single(pdev, skb->data, - rds_ring->dma_size, PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(pdev, dma)) { - dev_kfree_skb_any(skb); - break; + if (!buffer->skb) { + if (netxen_alloc_rx_skb(adapter, rds_ring, buffer)) + break; } count++; - buffer = list_entry(head->next, struct netxen_rx_buffer, list); list_del(&buffer->list); - buffer->skb = skb; - buffer->state = NETXEN_BUFFER_BUSY; - buffer->dma = dma; - /* make a rcv descriptor */ pdesc = &rds_ring->desc_head[producer]; - pdesc->addr_buffer = cpu_to_le64(dma); + pdesc->addr_buffer = cpu_to_le64(buffer->dma); pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); producer = get_next_index(producer, rds_ring->num_desc); } + spin_unlock(&rds_ring->lock); if (count) { rds_ring->producer = producer; @@ -1061,48 +1124,31 @@ netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ringid) } static void -netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid) +netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, + struct nx_host_rds_ring *rds_ring) { - struct pci_dev *pdev = adapter->pdev; - struct sk_buff *skb; - struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; - struct nx_host_rds_ring *rds_ring = NULL; - u32 producer; struct rcv_desc *pdesc; struct netxen_rx_buffer *buffer; - int count = 0; + int producer, count = 0; struct list_head *head; - dma_addr_t dma; - - rds_ring = &recv_ctx->rds_rings[ringid]; producer = rds_ring->producer; + if (!spin_trylock(&rds_ring->lock)) + return; + head = &rds_ring->free_list; while (!list_empty(head)) { - skb = dev_alloc_skb(rds_ring->skb_size); - if (unlikely(!skb)) { - break; - } - - if (!adapter->ahw.cut_through) - skb_reserve(skb, 2); + buffer = list_entry(head->next, struct netxen_rx_buffer, list); - dma = pci_map_single(pdev, skb->data, - rds_ring->dma_size, PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(pdev, dma)) { - dev_kfree_skb_any(skb); - break; + if (!buffer->skb) { + if (netxen_alloc_rx_skb(adapter, rds_ring, buffer)) + break; } count++; - buffer = list_entry(head->next, struct netxen_rx_buffer, list); list_del(&buffer->list); - buffer->skb = skb; - buffer->state = NETXEN_BUFFER_BUSY; - buffer->dma = dma; - /* make a rcv descriptor */ pdesc = &rds_ring->desc_head[producer]; pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); @@ -1119,6 +1165,7 @@ netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ringid) (producer - 1) & (rds_ring->num_desc - 1)); wmb(); } + spin_unlock(&rds_ring->lock); } void netxen_nic_clear_stats(struct netxen_adapter *adapter) diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 00eaeee235e..274d1e0c893 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -135,20 +135,71 @@ static uint32_t msi_tgt_status[8] = { static struct netxen_legacy_intr_set legacy_intr[] = NX_LEGACY_INTR_CONFIG; -static inline void netxen_nic_disable_int(struct netxen_adapter *adapter) +static inline void netxen_nic_disable_int(struct nx_host_sds_ring *sds_ring) { - adapter->pci_write_normalize(adapter, adapter->crb_intr_mask, 0); + struct netxen_adapter *adapter = sds_ring->adapter; + + adapter->pci_write_normalize(adapter, sds_ring->crb_intr_mask, 0); } -static inline void netxen_nic_enable_int(struct netxen_adapter *adapter) +static inline void netxen_nic_enable_int(struct nx_host_sds_ring *sds_ring) { - adapter->pci_write_normalize(adapter, adapter->crb_intr_mask, 0x1); + struct netxen_adapter *adapter = sds_ring->adapter; + + adapter->pci_write_normalize(adapter, sds_ring->crb_intr_mask, 0x1); if (!NETXEN_IS_MSI_FAMILY(adapter)) adapter->pci_write_immediate(adapter, adapter->legacy_intr.tgt_mask_reg, 0xfbff); } +static void +netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev) +{ + int ring; + struct nx_host_sds_ring *sds_ring; + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; + + if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) + adapter->max_sds_rings = (num_online_cpus() >= 4) ? 4 : 2; + else + adapter->max_sds_rings = 1; + + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + netif_napi_add(netdev, &sds_ring->napi, + netxen_nic_poll, NETXEN_NETDEV_WEIGHT); + } +} + +static void +netxen_napi_enable(struct netxen_adapter *adapter) +{ + int ring; + struct nx_host_sds_ring *sds_ring; + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; + + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + napi_enable(&sds_ring->napi); + netxen_nic_enable_int(sds_ring); + } +} + +static void +netxen_napi_disable(struct netxen_adapter *adapter) +{ + int ring; + struct nx_host_sds_ring *sds_ring; + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; + + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + netxen_nic_disable_int(sds_ring); + napi_disable(&sds_ring->napi); + } +} + static int nx_set_dma_mask(struct netxen_adapter *adapter, uint8_t revision_id) { struct pci_dev *pdev = adapter->pdev; @@ -226,7 +277,6 @@ static void netxen_check_options(struct netxen_adapter *adapter) adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS; adapter->num_lro_rxd = MAX_LRO_RCV_DESCRIPTORS; - adapter->max_possible_rss_rings = 1; return; } @@ -447,6 +497,7 @@ request_msi: dev_info(&pdev->dev, "using msi interrupts\n"); } else dev_info(&pdev->dev, "using legacy interrupts\n"); + adapter->msix_entries[0].vector = pdev->irq; } } @@ -671,8 +722,12 @@ static int netxen_nic_request_irq(struct netxen_adapter *adapter) { irq_handler_t handler; + struct nx_host_sds_ring *sds_ring; + int err, ring; + unsigned long flags = IRQF_SAMPLE_RANDOM; struct net_device *netdev = adapter->netdev; + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; if ((adapter->msi_mode != MSI_MODE_MULTIFUNC) || (adapter->intr_scheme != INTR_SCHEME_PERPORT)) { @@ -693,8 +748,30 @@ netxen_nic_request_irq(struct netxen_adapter *adapter) } adapter->irq = netdev->irq; - return request_irq(adapter->irq, handler, - flags, netdev->name, adapter); + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + sprintf(sds_ring->name, "%16s[%d]", netdev->name, ring); + err = request_irq(sds_ring->irq, handler, + flags, sds_ring->name, sds_ring); + if (err) + return err; + } + + return 0; +} + +static void +netxen_nic_free_irq(struct netxen_adapter *adapter) +{ + int ring; + struct nx_host_sds_ring *sds_ring; + + struct netxen_recv_context *recv_ctx = &adapter->recv_ctx; + + for (ring = 0; ring < adapter->max_sds_rings; ring++) { + sds_ring = &recv_ctx->sds_rings[ring]; + free_irq(sds_ring->irq, sds_ring); + } } static int @@ -719,8 +796,10 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) adapter->ahw.linkup = 0; mod_timer(&adapter->watchdog_timer, jiffies); - napi_enable(&adapter->napi); - netxen_nic_enable_int(adapter); + netxen_napi_enable(adapter); + + if (adapter->max_sds_rings > 1) + netxen_config_rss(adapter, 1); return 0; } @@ -730,13 +809,11 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) { netif_carrier_off(netdev); netif_stop_queue(netdev); - napi_disable(&adapter->napi); + netxen_napi_disable(adapter); if (adapter->stop_port) adapter->stop_port(adapter); - netxen_nic_disable_int(adapter); - netxen_release_tx_buffers(adapter); FLUSH_SCHEDULED_WORK(); @@ -750,6 +827,7 @@ netxen_nic_attach(struct netxen_adapter *adapter) struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; int err, ring; + struct nx_host_rds_ring *rds_ring; err = netxen_init_firmware(adapter); if (err != 0) { @@ -788,8 +866,10 @@ netxen_nic_attach(struct netxen_adapter *adapter) netxen_nic_update_cmd_consumer(adapter, 0); } - for (ring = 0; ring < adapter->max_rds_rings; ring++) - netxen_post_rx_buffers(adapter, ring); + for (ring = 0; ring < adapter->max_rds_rings; ring++) { + rds_ring = &adapter->recv_ctx.rds_rings[ring]; + netxen_post_rx_buffers(adapter, ring, rds_ring); + } err = netxen_nic_request_irq(adapter); if (err) { @@ -812,8 +892,7 @@ err_out_free_sw: static void netxen_nic_detach(struct netxen_adapter *adapter) { - if (adapter->irq) - free_irq(adapter->irq, adapter); + netxen_nic_free_irq(adapter); netxen_release_rx_buffers(adapter); netxen_free_hw_resources(adapter); @@ -883,14 +962,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_free_netdev; rwlock_init(&adapter->adapter_lock); + spin_lock_init(&adapter->tx_clean_lock); err = netxen_setup_pci_map(adapter); if (err) goto err_out_free_netdev; - netif_napi_add(netdev, &adapter->napi, - netxen_nic_poll, NETXEN_NETDEV_WEIGHT); - /* This will be reset for mezz cards */ adapter->portnum = pci_func_id; adapter->rx_csum = 1; @@ -963,10 +1040,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netxen_setup_intr(adapter); - if (adapter->flags & NETXEN_NIC_MSIX_ENABLED) - netdev->irq = adapter->msix_entries[0].vector; - else - netdev->irq = pdev->irq; + netdev->irq = adapter->msix_entries[0].vector; + + netxen_napi_add(adapter, netdev); err = netxen_receive_peg_ready(adapter); if (err) @@ -1520,13 +1596,11 @@ static void netxen_tx_timeout_task(struct work_struct *work) printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", netxen_nic_driver_name, adapter->netdev->name); - netxen_nic_disable_int(adapter); - napi_disable(&adapter->napi); + netxen_napi_disable(adapter); adapter->netdev->trans_start = jiffies; - napi_enable(&adapter->napi); - netxen_nic_enable_int(adapter); + netxen_napi_enable(adapter); netif_wake_queue(adapter->netdev); } @@ -1564,7 +1638,8 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) static irqreturn_t netxen_intr(int irq, void *data) { - struct netxen_adapter *adapter = data; + struct nx_host_sds_ring *sds_ring = data; + struct netxen_adapter *adapter = sds_ring->adapter; u32 status = 0; status = adapter->pci_read_immediate(adapter, ISR_INT_VECTOR); @@ -1595,7 +1670,7 @@ static irqreturn_t netxen_intr(int irq, void *data) /* clear interrupt */ if (adapter->fw_major < 4) - netxen_nic_disable_int(adapter); + netxen_nic_disable_int(sds_ring); adapter->pci_write_immediate(adapter, adapter->legacy_intr.tgt_status_reg, @@ -1604,45 +1679,49 @@ static irqreturn_t netxen_intr(int irq, void *data) adapter->pci_read_immediate(adapter, ISR_INT_VECTOR); adapter->pci_read_immediate(adapter, ISR_INT_VECTOR); - napi_schedule(&adapter->napi); + napi_schedule(&sds_ring->napi); return IRQ_HANDLED; } static irqreturn_t netxen_msi_intr(int irq, void *data) { - struct netxen_adapter *adapter = data; + struct nx_host_sds_ring *sds_ring = data; + struct netxen_adapter *adapter = sds_ring->adapter; /* clear interrupt */ adapter->pci_write_immediate(adapter, msi_tgt_status[adapter->ahw.pci_func], 0xffffffff); - napi_schedule(&adapter->napi); + napi_schedule(&sds_ring->napi); return IRQ_HANDLED; } static irqreturn_t netxen_msix_intr(int irq, void *data) { - struct netxen_adapter *adapter = data; + struct nx_host_sds_ring *sds_ring = data; - napi_schedule(&adapter->napi); + napi_schedule(&sds_ring->napi); return IRQ_HANDLED; } static int netxen_nic_poll(struct napi_struct *napi, int budget) { - struct netxen_adapter *adapter = - container_of(napi, struct netxen_adapter, napi); + struct nx_host_sds_ring *sds_ring = + container_of(napi, struct nx_host_sds_ring, napi); + + struct netxen_adapter *adapter = sds_ring->adapter; + int tx_complete; int work_done; tx_complete = netxen_process_cmd_ring(adapter); - work_done = netxen_process_rcv_ring(adapter, budget); + work_done = netxen_process_rcv_ring(sds_ring, budget); if ((work_done < budget) && tx_complete) { - napi_complete(&adapter->napi); - netxen_nic_enable_int(adapter); + napi_complete(&sds_ring->napi); + netxen_nic_enable_int(sds_ring); } return work_done; -- cgit v1.2.3-70-g09d2 From ff4fbd43fe82de28710761f2cc2ed122d716483a Mon Sep 17 00:00:00 2001 From: Dhananjay Phadke Date: Fri, 13 Mar 2009 14:52:06 +0000 Subject: netxen: update version to 4.0.30 To mark all features and bugfixes submitted since 4.0.11. Signed-off-by: Dhananjay Phadke Signed-off-by: David S. Miller --- drivers/net/netxen/netxen_nic.h | 4 ++-- drivers/net/netxen/netxen_nic_main.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/net/netxen/netxen_nic_main.c') diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 595171d943f..2544129768f 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h @@ -66,8 +66,8 @@ #define _NETXEN_NIC_LINUX_MAJOR 4 #define _NETXEN_NIC_LINUX_MINOR 0 -#define _NETXEN_NIC_LINUX_SUBVERSION 11 -#define NETXEN_NIC_LINUX_VERSIONID "4.0.11" +#define _NETXEN_NIC_LINUX_SUBVERSION 30 +#define NETXEN_NIC_LINUX_VERSIONID "4.0.30" #define NETXEN_VERSION_CODE(a, b, c) (((a) << 16) + ((b) << 8) + (c)) diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 274d1e0c893..1fb9bcf504e 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c @@ -910,9 +910,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) int pci_func_id = PCI_FUNC(pdev->devfn); uint8_t revision_id; - if (pci_func_id == 0) - printk(KERN_INFO "%s\n", netxen_nic_driver_string); - if (pdev->class != 0x020000) { printk(KERN_DEBUG "NetXen function %d, class %x will not " "be enabled.\n",pci_func_id, pdev->class); @@ -1750,6 +1747,8 @@ static struct pci_driver netxen_driver = { static int __init netxen_init_module(void) { + printk(KERN_INFO "%s\n", netxen_nic_driver_string); + if ((netxen_workq = create_singlethread_workqueue("netxen")) == NULL) return -ENOMEM; -- cgit v1.2.3-70-g09d2