Commit 267c095a authored by Nikolay Aleksandrov's avatar Nikolay Aleksandrov Committed by David S. Miller

bonding: add 3ad stats

Count the following types of 3ad packets per slave:
 - rx/tx lacpdu
 - rx/tx marker
 - rx/tx marker response
 - rx illegal lacpdus (right now counted on wrong length)
 - rx unknown lacpdu type
 - rx unknown marker type

The counters are using atomic64 since this is not fast path.
Signed-off-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dadeb61d
...@@ -851,6 +851,8 @@ static int ad_lacpdu_send(struct port *port) ...@@ -851,6 +851,8 @@ static int ad_lacpdu_send(struct port *port)
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
atomic64_inc(&SLAVE_AD_INFO(slave)->stats.lacpdu_tx);
skb->dev = slave->dev; skb->dev = slave->dev;
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
skb->network_header = skb->mac_header + ETH_HLEN; skb->network_header = skb->mac_header + ETH_HLEN;
...@@ -892,6 +894,15 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker) ...@@ -892,6 +894,15 @@ static int ad_marker_send(struct port *port, struct bond_marker *marker)
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
switch (marker->tlv_type) {
case AD_MARKER_INFORMATION_SUBTYPE:
atomic64_inc(&SLAVE_AD_INFO(slave)->stats.marker_tx);
break;
case AD_MARKER_RESPONSE_SUBTYPE:
atomic64_inc(&SLAVE_AD_INFO(slave)->stats.marker_resp_tx);
break;
}
skb_reserve(skb, 16); skb_reserve(skb, 16);
skb->dev = slave->dev; skb->dev = slave->dev;
...@@ -1086,6 +1097,9 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) ...@@ -1086,6 +1097,9 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
*/ */
last_state = port->sm_rx_state; last_state = port->sm_rx_state;
if (lacpdu)
atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.lacpdu_rx);
/* check if state machine should change state */ /* check if state machine should change state */
/* first, check if port was reinitialized */ /* first, check if port was reinitialized */
...@@ -1922,6 +1936,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info, ...@@ -1922,6 +1936,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
{ {
struct bond_marker marker; struct bond_marker marker;
atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_rx);
/* copy the received marker data to the response marker */ /* copy the received marker data to the response marker */
memcpy(&marker, marker_info, sizeof(struct bond_marker)); memcpy(&marker, marker_info, sizeof(struct bond_marker));
/* change the marker subtype to marker response */ /* change the marker subtype to marker response */
...@@ -1946,6 +1962,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info, ...@@ -1946,6 +1962,8 @@ static void ad_marker_info_received(struct bond_marker *marker_info,
static void ad_marker_response_received(struct bond_marker *marker, static void ad_marker_response_received(struct bond_marker *marker,
struct port *port) struct port *port)
{ {
atomic64_inc(&SLAVE_AD_INFO(port->slave)->stats.marker_resp_rx);
/* DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW */ /* DO NOTHING, SINCE WE DECIDED NOT TO IMPLEMENT THIS FEATURE FOR NOW */
} }
...@@ -2358,6 +2376,7 @@ static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave) ...@@ -2358,6 +2376,7 @@ static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave)
int ret = RX_HANDLER_ANOTHER; int ret = RX_HANDLER_ANOTHER;
struct bond_marker *marker; struct bond_marker *marker;
struct port *port; struct port *port;
atomic64_t *stat;
port = &(SLAVE_AD_INFO(slave)->port); port = &(SLAVE_AD_INFO(slave)->port);
if (!port->slave) { if (!port->slave) {
...@@ -2397,7 +2416,12 @@ static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave) ...@@ -2397,7 +2416,12 @@ static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave)
default: default:
netdev_dbg(slave->bond->dev, "Received an unknown Marker subtype on slot %d\n", netdev_dbg(slave->bond->dev, "Received an unknown Marker subtype on slot %d\n",
port->actor_port_number); port->actor_port_number);
stat = &SLAVE_AD_INFO(slave)->stats.marker_unknown_rx;
atomic64_inc(stat);
} }
break;
default:
atomic64_inc(&SLAVE_AD_INFO(slave)->stats.lacpdu_unknown_rx);
} }
return ret; return ret;
...@@ -2635,8 +2659,10 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond, ...@@ -2635,8 +2659,10 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
return RX_HANDLER_ANOTHER; return RX_HANDLER_ANOTHER;
lacpdu = skb_header_pointer(skb, 0, sizeof(_lacpdu), &_lacpdu); lacpdu = skb_header_pointer(skb, 0, sizeof(_lacpdu), &_lacpdu);
if (!lacpdu) if (!lacpdu) {
atomic64_inc(&SLAVE_AD_INFO(slave)->stats.lacpdu_illegal_rx);
return RX_HANDLER_ANOTHER; return RX_HANDLER_ANOTHER;
}
return bond_3ad_rx_indication(lacpdu, slave); return bond_3ad_rx_indication(lacpdu, slave);
} }
......
...@@ -180,6 +180,19 @@ struct port; ...@@ -180,6 +180,19 @@ struct port;
#pragma pack(8) #pragma pack(8)
#endif #endif
struct bond_3ad_stats {
atomic64_t lacpdu_rx;
atomic64_t lacpdu_tx;
atomic64_t lacpdu_unknown_rx;
atomic64_t lacpdu_illegal_rx;
atomic64_t marker_rx;
atomic64_t marker_tx;
atomic64_t marker_resp_rx;
atomic64_t marker_resp_tx;
atomic64_t marker_unknown_rx;
};
/* aggregator structure(43.4.5 in the 802.3ad standard) */ /* aggregator structure(43.4.5 in the 802.3ad standard) */
typedef struct aggregator { typedef struct aggregator {
struct mac_addr aggregator_mac_address; struct mac_addr aggregator_mac_address;
...@@ -272,6 +285,7 @@ struct ad_bond_info { ...@@ -272,6 +285,7 @@ struct ad_bond_info {
struct ad_slave_info { struct ad_slave_info {
struct aggregator aggregator; /* 802.3ad aggregator structure */ struct aggregator aggregator; /* 802.3ad aggregator structure */
struct port port; /* 802.3ad port structure */ struct port port; /* 802.3ad port structure */
struct bond_3ad_stats stats;
u16 id; u16 id;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment