s390/qeth: extract helper to determine L2 cast type

This de-duplicates the L2 and L3 cast-type code, and makes the L2 code
a bit more robust by removing the fragile assumption that skb->data
always points to the Ethernet Header. This would break in code paths
where we pushed the HW header onto the skb.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Julian Wiedmann 2019-04-25 18:26:00 +02:00 committed by David S. Miller
parent 4e26c5fe55
commit 58aa2491aa
3 changed files with 14 additions and 18 deletions

View File

@ -881,6 +881,16 @@ static inline int qeth_get_ip_version(struct sk_buff *skb)
}
}
static inline int qeth_get_ether_cast_type(struct sk_buff *skb)
{
u8 *addr = eth_hdr(skb)->h_dest;
if (is_multicast_ether_addr(addr))
return is_broadcast_ether_addr(addr) ? RTN_BROADCAST :
RTN_MULTICAST;
return RTN_UNICAST;
}
static inline void qeth_rx_csum(struct qeth_card *card, struct sk_buff *skb,
u8 flags)
{

View File

@ -161,15 +161,6 @@ static void qeth_l2_drain_rx_mode_cache(struct qeth_card *card)
}
}
static int qeth_l2_get_cast_type(struct sk_buff *skb)
{
if (is_broadcast_ether_addr(skb->data))
return RTN_BROADCAST;
if (is_multicast_ether_addr(skb->data))
return RTN_MULTICAST;
return RTN_UNICAST;
}
static void qeth_l2_fill_header(struct qeth_qdio_out_q *queue,
struct qeth_hdr *hdr, struct sk_buff *skb,
int ipv, int cast_type, unsigned int data_len)
@ -611,7 +602,8 @@ static netdev_tx_t qeth_l2_hard_start_xmit(struct sk_buff *skb,
rc = qeth_l2_xmit_osn(card, skb, queue);
else
rc = qeth_xmit(card, skb, queue, qeth_get_ip_version(skb),
qeth_l2_get_cast_type(skb), qeth_l2_fill_header);
qeth_get_ether_cast_type(skb),
qeth_l2_fill_header);
if (!rc) {
QETH_TXQ_STAT_INC(queue, tx_packets);
@ -631,7 +623,7 @@ static u16 qeth_l2_select_queue(struct net_device *dev, struct sk_buff *skb,
if (IS_IQD(card))
return qeth_iqd_select_queue(dev, skb,
qeth_l2_get_cast_type(skb),
qeth_get_ether_cast_type(skb),
sb_dev);
return qeth_get_priority_queue(card, skb);
}

View File

@ -1918,13 +1918,7 @@ static int qeth_l3_get_cast_type(struct sk_buff *skb)
RTN_MULTICAST : RTN_UNICAST;
default:
/* ... and MAC address */
if (ether_addr_equal_64bits(eth_hdr(skb)->h_dest,
skb->dev->broadcast))
return RTN_BROADCAST;
if (is_multicast_ether_addr(eth_hdr(skb)->h_dest))
return RTN_MULTICAST;
/* default to unicast */
return RTN_UNICAST;
return qeth_get_ether_cast_type(skb);
}
}