[dpdk-dev] [PATCH 3/4] bond: add debug info for mode 6 link bonding

Jastrzebski, MichalX K michalx.k.jastrzebski at intel.com
Fri Jan 30 12:09:20 CET 2015


> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Michal Jastrzebski
> Sent: Friday, January 30, 2015 11:58 AM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH 3/4] bond: add debug info for mode 6 link
> bonding
> 
> 
> Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski at intel.com>
> ---
>  config/common_linuxapp                 |    2 +-
>  lib/librte_pmd_bond/rte_eth_bond_pmd.c |  124
> ++++++++++++++++++++++++++++++++
>  2 files changed, 125 insertions(+), 1 deletion(-)
> 
> diff --git a/config/common_linuxapp b/config/common_linuxapp
> index 2f9643b..1cc2d7e 100644
> --- a/config/common_linuxapp
> +++ b/config/common_linuxapp
> @@ -220,7 +220,7 @@ CONFIG_RTE_LIBRTE_PMD_PCAP=n
>  # Compile link bonding PMD library
>  #
>  CONFIG_RTE_LIBRTE_PMD_BOND=y
> -
> +CONFIG_RTE_LIBRTE_BOND_DEBUG_ALB=n
>  #
>  # Compile software PMD backed by AF_PACKET sockets (Linux only)
>  #
> diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> index b0525cc..348c653 100644
> --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c
> @@ -208,6 +208,78 @@ bond_ethdev_rx_burst_8023ad(void *queue, struct
> rte_mbuf **bufs,
>  	return num_rx_total;
>  }
> 
> +#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
> +uint32_t burstnumberRX;
> +uint32_t burstnumberTX;
> +
> +static void
> +arp_op_name(uint16_t arp_op, char *buf)
> +{
> +	switch (arp_op) {
> +	case ARP_OP_REQUEST:
> +		snprintf(buf, sizeof("ARP Request"), "%s", "ARP Request");
> +		return;
> +	case ARP_OP_REPLY:
> +		snprintf(buf, sizeof("ARP Reply"), "%s", "ARP Reply");
> +		return;
> +	case ARP_OP_REVREQUEST:
> +		snprintf(buf, sizeof("Reverse ARP Request"), "%s", "Reverse
> ARP Request");
> +		return;
> +	case ARP_OP_REVREPLY:
> +		snprintf(buf, sizeof("Reverse ARP Reply"), "%s", "Reverse ARP
> Reply");
> +		return;
> +	case ARP_OP_INVREQUEST:
> +		snprintf(buf, sizeof("Peer Identify Request"), "%s", "Peer
> Identify Request");
> +		return;
> +	case ARP_OP_INVREPLY:
> +		snprintf(buf, sizeof("Peer Identify Reply"), "%s", "Peer
> Identify Reply");
> +		return;
> +	default:
> +		break;
> +	}
> +	snprintf(buf, sizeof("Unknown"), "%s", "Unknown");
> +	return;
> +}
> +#define MaxIPv4String	16
> +static void
> +ipv4_addr_to_dot(uint32_t be_ipv4_addr, char *buf, uint8_t buf_size)
> +{
> +	uint32_t ipv4_addr;
> +
> +	ipv4_addr = rte_be_to_cpu_32(be_ipv4_addr);
> +	snprintf(buf, buf_size, "%d.%d.%d.%d", (ipv4_addr >> 24) & 0xFF,
> +		(ipv4_addr >> 16) & 0xFF, (ipv4_addr >> 8) & 0xFF,
> +		ipv4_addr & 0xFF);
> +}
> +
> +#define MODE6_DEBUG(info, src_ip, dst_ip, eth_h, arp_op, port,
> burstnumber)	\
> +		RTE_LOG(DEBUG, PMD, info \
> +		"port:%d " \
> +		"SrcMAC:%02X:%02X:%02X:%02X:%02X:%02X " \
> +		"SrcIP:%s " \
> +		"DstMAC:%02X:%02X:%02X:%02X:%02X:%02X " \
> +		"DstIP:%s " \
> +		"%s " \
> +		"%d\n", \
> +		port, \
> +		eth_h->s_addr.addr_bytes[0], \
> +		eth_h->s_addr.addr_bytes[1], \
> +		eth_h->s_addr.addr_bytes[2], \
> +		eth_h->s_addr.addr_bytes[3], \
> +		eth_h->s_addr.addr_bytes[4], \
> +		eth_h->s_addr.addr_bytes[5], \
> +		src_ip, \
> +		eth_h->d_addr.addr_bytes[0], \
> +		eth_h->d_addr.addr_bytes[1], \
> +		eth_h->d_addr.addr_bytes[2], \
> +		eth_h->d_addr.addr_bytes[3], \
> +		eth_h->d_addr.addr_bytes[4], \
> +		eth_h->d_addr.addr_bytes[5], \
> +		dst_ip, \
> +		arp_op, \
> +		++burstnumber)
> +#endif
> +
>  static uint16_t
>  bond_ethdev_rx_burst_alb(void *queue, struct rte_mbuf **bufs, uint16_t
> nb_pkts)
>  {
> @@ -222,6 +294,13 @@ bond_ethdev_rx_burst_alb(void *queue, struct
> rte_mbuf **bufs, uint16_t nb_pkts)
>  	int i;
> 
>  	nb_recv_pkts = bond_ethdev_rx_burst(queue, bufs, nb_pkts);
> +#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
> +	struct arp_hdr *arp_h;
> +	struct ipv4_hdr *ipv4_h;
> +	char src_ip[16];
> +	char dst_ip[16];
> +	char ArpOp[24];
> +#endif
> 
>  	for (i = 0; i < nb_recv_pkts; i++) {
>  		eth_h = rte_pktmbuf_mtod(bufs[i], struct ether_hdr *);
> @@ -229,8 +308,23 @@ bond_ethdev_rx_burst_alb(void *queue, struct
> rte_mbuf **bufs, uint16_t nb_pkts)
>  		ether_type = get_vlan_ethertype(eth_h);
> 
>  		if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_ARP)) {
> +#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
> +			arp_h = (struct arp_hdr *)((char *)(eth_h + 1) +
> offset);
> +			ipv4_addr_to_dot(arp_h->arp_data.arp_sip, src_ip,
> MaxIPv4String);
> +			ipv4_addr_to_dot(arp_h->arp_data.arp_tip, dst_ip,
> MaxIPv4String);
> +			arp_op_name(rte_be_to_cpu_16(arp_h->arp_op),
> ArpOp);
> +			MODE6_DEBUG("RX ARP:", src_ip, dst_ip, eth_h,
> ArpOp, bufs[i]->port, burstnumberRX);
> +#endif
>  			bond_mode_alb_arp_recv(eth_h, offset, internals);
>  		}
> +#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
> +		else if (ether_type == rte_cpu_to_be_16(ETHER_TYPE_IPv4)) {
> +			ipv4_h = (struct ipv4_hdr *)((char *)(eth_h + 1) +
> offset);
> +			ipv4_addr_to_dot(ipv4_h->src_addr, src_ip,
> MaxIPv4String);
> +			ipv4_addr_to_dot(ipv4_h->dst_addr, dst_ip,
> MaxIPv4String);
> +			MODE6_DEBUG("RX IPv4:", src_ip, dst_ip, eth_h, "",
> bufs[i]->port, burstnumberRX);
> +		}
> +#endif
>  	}
> 
>  	return nb_recv_pkts;
> @@ -653,6 +747,12 @@ bond_ethdev_tx_burst_alb(void *queue, struct
> rte_mbuf **bufs, uint16_t nb_pkts)
>  		internals->mode6.ntt = 0;
>  	}
> 
> +#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
> +	struct arp_hdr *arp_h;
> +	char src_ip[16];
> +	char dst_ip[16];
> +	char ArpOp[24];
> +#endif
>  	/* Send ARP packets on proper slaves */
>  	for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
>  		if (slave_bufs_pkts[i] > 0) {
> @@ -665,6 +765,19 @@ bond_ethdev_tx_burst_alb(void *queue, struct
> rte_mbuf **bufs, uint16_t nb_pkts)
> 
>  			num_tx_total += num_send;
>  			num_not_send += slave_bufs_pkts[i] - num_send;
> +
> +#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
> +	/* Print TX stats including update packets */
> +			for (j = 0; j < slave_bufs_pkts[i]; j++) {
> +				eth_h = rte_pktmbuf_mtod(slave_bufs[i][j],
> struct ether_hdr *);
> +				offset = get_vlan_offset(eth_h);
> +				arp_h = (struct arp_hdr *)((char *)(eth_h + 1)
> + offset);
> +				ipv4_addr_to_dot(arp_h->arp_data.arp_sip,
> src_ip, MaxIPv4String);
> +				ipv4_addr_to_dot(arp_h->arp_data.arp_tip,
> dst_ip, MaxIPv4String);
> +				arp_op_name(rte_be_to_cpu_16(arp_h-
> >arp_op), ArpOp);
> +				MODE6_DEBUG("TX ARP:", src_ip, dst_ip,
> eth_h, ArpOp, i, burstnumberTX);
> +			}
> +#endif
>  		}
>  	}
> 
> @@ -676,6 +789,17 @@ bond_ethdev_tx_burst_alb(void *queue, struct
> rte_mbuf **bufs, uint16_t nb_pkts)
>  			for (j = num_send; j < update_bufs_pkts[i]; j++) {
>  				rte_pktmbuf_free(update_bufs[i][j]);
>  			}
> +#ifdef RTE_LIBRTE_BOND_DEBUG_ALB
> +			for (j = 0; j < update_bufs_pkts[i]; j++) {
> +				eth_h = rte_pktmbuf_mtod(update_bufs[i][j],
> struct ether_hdr *);
> +				offset = get_vlan_offset(eth_h);
> +				arp_h = (struct arp_hdr *)((char *)(eth_h + 1)
> + offset);
> +				ipv4_addr_to_dot(arp_h->arp_data.arp_sip,
> src_ip, MaxIPv4String);
> +				ipv4_addr_to_dot(arp_h->arp_data.arp_tip,
> dst_ip, MaxIPv4String);
> +				arp_op_name(rte_be_to_cpu_16(arp_h-
> >arp_op), ArpOp);
> +				MODE6_DEBUG("TX ARPupd:", src_ip, dst_ip,
> eth_h, ArpOp, i, burstnumberTX);
> +			}
> +#endif
>  		}
>  	}
> 
> --
> 1.7.9.5

This patch add some debug information when using link bonding mode 6.
It prints basic information about ARP packets on RX and TX (MAC, ip, packet number,
arp packet type).


More information about the dev mailing list