Skip to content

Commit

Permalink
net: replace uses of __constant_{endian}
Browse files Browse the repository at this point in the history
Base versions handle constant folding now.

Signed-off-by: Harvey Harrison <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
hharrison authored and davem330 committed Feb 1, 2009
1 parent ee43777 commit 09640e6
Show file tree
Hide file tree
Showing 61 changed files with 111 additions and 112 deletions.
2 changes: 1 addition & 1 deletion drivers/net/arcnet/arc-rawmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/arcnet/capmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/bonding/bond_3ad.h
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/bonding/bond_alb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/e1000e/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/enic/enic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/hamachi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/hamradio/bpqether.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/igb/igb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ixgbe/ixgbe_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 |=
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/myri_sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/netxen/netxen_nic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/niu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/pppoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,12 +514,12 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev,
}

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,
};

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ps3_gelic_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/sfc/bitfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 1 addition & 1 deletion drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/usb/hso.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/via-velocity.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct rdesc1 {
};

enum {
RX_INTEN = __constant_cpu_to_le16(0x8000)
RX_INTEN = cpu_to_le16(0x8000)
};

struct rx_desc {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
};


Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wan/hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
16 changes: 8 additions & 8 deletions drivers/net/wan/hdlc_cisco.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 09640e6

Please sign in to comment.