2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-11-19 16:14:13 +08:00

qeth: Cleanup for cast-type determination.

Clear separation of cast-type determination (send path) for layer-2
resp. layer-3. Allowing to have inline functions for qeth layer-
discipline.

Signed-off-by: Klaus-Dieter Wacker <kdwacker@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Klaus-Dieter Wacker 2009-08-26 02:01:08 +00:00 committed by David S. Miller
parent e806904057
commit ce73e10ee0
4 changed files with 57 additions and 82 deletions

View File

@ -843,7 +843,6 @@ int qeth_default_setadapterparms_cb(struct qeth_card *, struct qeth_reply *,
int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *, int qeth_send_control_data(struct qeth_card *, int, struct qeth_cmd_buffer *,
int (*reply_cb)(struct qeth_card *, struct qeth_reply*, unsigned long), int (*reply_cb)(struct qeth_card *, struct qeth_reply*, unsigned long),
void *reply_param); void *reply_param);
int qeth_get_cast_type(struct qeth_card *, struct sk_buff *);
int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int); int qeth_get_priority_queue(struct qeth_card *, struct sk_buff *, int, int);
int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int); int qeth_get_elements_no(struct qeth_card *, void *, struct sk_buff *, int);
int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *, int qeth_do_send_packet_fast(struct qeth_card *, struct qeth_qdio_out_q *,

View File

@ -2952,55 +2952,6 @@ void qeth_qdio_output_handler(struct ccw_device *ccwdev,
} }
EXPORT_SYMBOL_GPL(qeth_qdio_output_handler); EXPORT_SYMBOL_GPL(qeth_qdio_output_handler);
int qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
{
int cast_type = RTN_UNSPEC;
if (card->info.type == QETH_CARD_TYPE_OSN)
return cast_type;
if (skb_dst(skb) && skb_dst(skb)->neighbour) {
cast_type = skb_dst(skb)->neighbour->type;
if ((cast_type == RTN_BROADCAST) ||
(cast_type == RTN_MULTICAST) ||
(cast_type == RTN_ANYCAST))
return cast_type;
else
return RTN_UNSPEC;
}
/* try something else */
if (skb->protocol == ETH_P_IPV6)
return (skb_network_header(skb)[24] == 0xff) ?
RTN_MULTICAST : 0;
else if (skb->protocol == ETH_P_IP)
return ((skb_network_header(skb)[16] & 0xf0) == 0xe0) ?
RTN_MULTICAST : 0;
/* ... */
if (!memcmp(skb->data, skb->dev->broadcast, 6))
return RTN_BROADCAST;
else {
u16 hdr_mac;
hdr_mac = *((u16 *)skb->data);
/* tr multicast? */
switch (card->info.link_type) {
case QETH_LINK_TYPE_HSTR:
case QETH_LINK_TYPE_LANE_TR:
if ((hdr_mac == QETH_TR_MAC_NC) ||
(hdr_mac == QETH_TR_MAC_C))
return RTN_MULTICAST;
break;
/* eth or so multicast? */
default:
if ((hdr_mac == QETH_ETH_MAC_V4) ||
(hdr_mac == QETH_ETH_MAC_V6))
return RTN_MULTICAST;
}
}
return cast_type;
}
EXPORT_SYMBOL_GPL(qeth_get_cast_type);
int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb,
int ipv, int cast_type) int ipv, int cast_type)
{ {

View File

@ -216,36 +216,16 @@ static void qeth_l2_del_all_mc(struct qeth_card *card)
spin_unlock_bh(&card->mclock); spin_unlock_bh(&card->mclock);
} }
static void qeth_l2_get_packet_type(struct qeth_card *card, static inline int qeth_l2_get_cast_type(struct qeth_card *card,
struct qeth_hdr *hdr, struct sk_buff *skb) struct sk_buff *skb)
{ {
__u16 hdr_mac; if (card->info.type == QETH_CARD_TYPE_OSN)
return RTN_UNSPEC;
if (!memcmp(skb->data + QETH_HEADER_SIZE, if (is_broadcast_ether_addr(skb->data))
skb->dev->broadcast, 6)) { return RTN_BROADCAST;
/* broadcast? */ if (is_multicast_ether_addr(skb->data))
hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; return RTN_MULTICAST;
return; return RTN_UNSPEC;
}
hdr_mac = *((__u16 *)skb->data);
/* tr multicast? */
switch (card->info.link_type) {
case QETH_LINK_TYPE_HSTR:
case QETH_LINK_TYPE_LANE_TR:
if ((hdr_mac == QETH_TR_MAC_NC) ||
(hdr_mac == QETH_TR_MAC_C))
hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_MULTICAST;
else
hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST;
break;
/* eth or so multicast? */
default:
if ((hdr_mac == QETH_ETH_MAC_V4) ||
(hdr_mac == QETH_ETH_MAC_V6))
hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_MULTICAST;
else
hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST;
}
} }
static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
@ -262,7 +242,7 @@ static void qeth_l2_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
else if (cast_type == RTN_BROADCAST) else if (cast_type == RTN_BROADCAST)
hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST; hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_BROADCAST;
else else
qeth_l2_get_packet_type(card, hdr, skb); hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_UNICAST;
hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE; hdr->hdr.l2.pkt_length = skb->len-QETH_HEADER_SIZE;
/* VSWITCH relies on the VLAN /* VSWITCH relies on the VLAN
@ -672,7 +652,7 @@ static int qeth_l2_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
struct qeth_card *card = dev->ml_priv; struct qeth_card *card = dev->ml_priv;
struct sk_buff *new_skb = skb; struct sk_buff *new_skb = skb;
int ipv = qeth_get_ip_version(skb); int ipv = qeth_get_ip_version(skb);
int cast_type = qeth_get_cast_type(card, skb); int cast_type = qeth_l2_get_cast_type(card, skb);
struct qeth_qdio_out_q *queue = card->qdio.out_qs struct qeth_qdio_out_q *queue = card->qdio.out_qs
[qeth_get_priority_queue(card, skb, ipv, cast_type)]; [qeth_get_priority_queue(card, skb, ipv, cast_type)];
int tx_bytes = skb->len; int tx_bytes = skb->len;

View File

@ -2525,6 +2525,51 @@ static int qeth_l3_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return rc; return rc;
} }
int inline qeth_l3_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
{
int cast_type = RTN_UNSPEC;
if (skb_dst(skb) && skb_dst(skb)->neighbour) {
cast_type = skb_dst(skb)->neighbour->type;
if ((cast_type == RTN_BROADCAST) ||
(cast_type == RTN_MULTICAST) ||
(cast_type == RTN_ANYCAST))
return cast_type;
else
return RTN_UNSPEC;
}
/* try something else */
if (skb->protocol == ETH_P_IPV6)
return (skb_network_header(skb)[24] == 0xff) ?
RTN_MULTICAST : 0;
else if (skb->protocol == ETH_P_IP)
return ((skb_network_header(skb)[16] & 0xf0) == 0xe0) ?
RTN_MULTICAST : 0;
/* ... */
if (!memcmp(skb->data, skb->dev->broadcast, 6))
return RTN_BROADCAST;
else {
u16 hdr_mac;
hdr_mac = *((u16 *)skb->data);
/* tr multicast? */
switch (card->info.link_type) {
case QETH_LINK_TYPE_HSTR:
case QETH_LINK_TYPE_LANE_TR:
if ((hdr_mac == QETH_TR_MAC_NC) ||
(hdr_mac == QETH_TR_MAC_C))
return RTN_MULTICAST;
break;
/* eth or so multicast? */
default:
if ((hdr_mac == QETH_ETH_MAC_V4) ||
(hdr_mac == QETH_ETH_MAC_V6))
return RTN_MULTICAST;
}
}
return cast_type;
}
static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr,
struct sk_buff *skb, int ipv, int cast_type) struct sk_buff *skb, int ipv, int cast_type)
{ {
@ -2650,7 +2695,7 @@ static int qeth_l3_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
struct qeth_card *card = dev->ml_priv; struct qeth_card *card = dev->ml_priv;
struct sk_buff *new_skb = NULL; struct sk_buff *new_skb = NULL;
int ipv = qeth_get_ip_version(skb); int ipv = qeth_get_ip_version(skb);
int cast_type = qeth_get_cast_type(card, skb); int cast_type = qeth_l3_get_cast_type(card, skb);
struct qeth_qdio_out_q *queue = card->qdio.out_qs struct qeth_qdio_out_q *queue = card->qdio.out_qs
[qeth_get_priority_queue(card, skb, ipv, cast_type)]; [qeth_get_priority_queue(card, skb, ipv, cast_type)];
int tx_bytes = skb->len; int tx_bytes = skb->len;