提交 7d1756a0 编写于 作者: Y Yunsheng Lin 提交者: Xie XiuQi

net: hns3: add trace events support for hns3 driver

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

This adds trace support for hns3 driver. It also declares
some events which could be used to trace the events when a
tx/rx bd is processed.
Signed-off-by: NYunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f8b41ec1
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# #
# Makefile for the HISILICON network device drivers. # Makefile for the HISILICON network device drivers.
# #
ccflags-y += -I$(srctree)/$(src)
obj-$(CONFIG_HNS3) += hns3pf/ obj-$(CONFIG_HNS3) += hns3pf/
obj-$(CONFIG_HNS3) += hns3vf/ obj-$(CONFIG_HNS3) += hns3vf/
......
...@@ -23,6 +23,12 @@ ...@@ -23,6 +23,12 @@
#include "kcompat.h" #include "kcompat.h"
#include "hnae3.h" #include "hnae3.h"
#include "hns3_enet.h" #include "hns3_enet.h"
/* All hns3 tracepoints are defined by the include below, which
* must be included exactly once across the whole kernel with
* CREATE_TRACE_POINTS defined
*/
#define CREATE_TRACE_POINTS
#include "hns3_trace.h"
#define hns3_set_field(origin, shift, val) ((origin) |= ((val) << (shift))) #define hns3_set_field(origin, shift, val) ((origin) |= ((val) << (shift)))
#define hns3_tx_bd_count(S) DIV_ROUND_UP(S, HNS3_MAX_BD_SIZE) #define hns3_tx_bd_count(S) DIV_ROUND_UP(S, HNS3_MAX_BD_SIZE)
...@@ -1095,6 +1101,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, ...@@ -1095,6 +1101,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
desc->tx.bdtp_fe_sc_vld_ra_ri = desc->tx.bdtp_fe_sc_vld_ra_ri =
cpu_to_le16(bdtp_fe_sc_vld_ra_ri); cpu_to_le16(bdtp_fe_sc_vld_ra_ri);
trace_hns3_tx_desc(ring);
ring_ptr_move_fw(ring, next_to_use); ring_ptr_move_fw(ring, next_to_use);
return 0; return 0;
} }
...@@ -1123,6 +1130,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, ...@@ -1123,6 +1130,7 @@ static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv,
desc->tx.bdtp_fe_sc_vld_ra_ri = desc->tx.bdtp_fe_sc_vld_ra_ri =
cpu_to_le16(bdtp_fe_sc_vld_ra_ri); cpu_to_le16(bdtp_fe_sc_vld_ra_ri);
trace_hns3_tx_desc(ring);
/* move ring pointer to next */ /* move ring pointer to next */
ring_ptr_move_fw(ring, next_to_use); ring_ptr_move_fw(ring, next_to_use);
...@@ -1201,6 +1209,14 @@ static bool hns3_skb_need_linearized(struct sk_buff *skb) ...@@ -1201,6 +1209,14 @@ static bool hns3_skb_need_linearized(struct sk_buff *skb)
return false; return false;
} }
void hns3_shinfo_pack(struct skb_shared_info *shinfo, __u32 *size)
{
int i = 0;
for (i = 0; i < MAX_SKB_FRAGS; i++)
size[i] = skb_frag_size(&shinfo->frags[i]);
}
static int hns3_nic_maybe_stop_tx(struct hns3_enet_ring *ring, static int hns3_nic_maybe_stop_tx(struct hns3_enet_ring *ring,
struct sk_buff **out_skb) struct sk_buff **out_skb)
{ {
...@@ -1217,6 +1233,8 @@ static int hns3_nic_maybe_stop_tx(struct hns3_enet_ring *ring, ...@@ -1217,6 +1233,8 @@ static int hns3_nic_maybe_stop_tx(struct hns3_enet_ring *ring,
if (skb_is_gso(skb) && !hns3_skb_need_linearized(skb)) if (skb_is_gso(skb) && !hns3_skb_need_linearized(skb))
goto out; goto out;
trace_hns3_over_8bd(skb);
bd_num = hns3_tx_bd_count(skb->len); bd_num = hns3_tx_bd_count(skb->len);
if (unlikely(ring_space(ring) < bd_num)) if (unlikely(ring_space(ring) < bd_num))
return -EBUSY; return -EBUSY;
...@@ -2605,6 +2623,7 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, unsigned int length, ...@@ -2605,6 +2623,7 @@ static int hns3_alloc_skb(struct hns3_enet_ring *ring, unsigned int length,
return -ENOMEM; return -ENOMEM;
} }
trace_hns3_rx_desc(ring);
prefetchw(skb->data); prefetchw(skb->data);
ring->pending_buf = 1; ring->pending_buf = 1;
...@@ -2694,6 +2713,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc, ...@@ -2694,6 +2713,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc,
} }
hns3_nic_reuse_page(skb, ring->frag_num++, ring, 0, desc_cb); hns3_nic_reuse_page(skb, ring->frag_num++, ring, 0, desc_cb);
trace_hns3_rx_desc(ring);
ring_ptr_move_fw(ring, next_to_clean); ring_ptr_move_fw(ring, next_to_clean);
ring->pending_buf++; ring->pending_buf++;
} }
......
...@@ -678,4 +678,5 @@ void hns3_dbg_init(struct hnae3_handle *handle); ...@@ -678,4 +678,5 @@ void hns3_dbg_init(struct hnae3_handle *handle);
void hns3_dbg_uninit(struct hnae3_handle *handle); void hns3_dbg_uninit(struct hnae3_handle *handle);
void hns3_dbg_register_debugfs(const char *debugfs_dir_name); void hns3_dbg_register_debugfs(const char *debugfs_dir_name);
void hns3_dbg_unregister_debugfs(void); void hns3_dbg_unregister_debugfs(void);
void hns3_shinfo_pack(struct skb_shared_info *shinfo, __u32 *size);
#endif #endif
/* SPDX-License-Identifier: GPL-2.0+ */
/* Copyright (c) 2018-2019 Hisilicon Limited. */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM hns3
#if !defined(_HNS3_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _HNS3_TRACE_H_
#include <linux/tracepoint.h>
#define DESC_NR (sizeof(struct hns3_desc) / sizeof(u32))
TRACE_EVENT(hns3_over_8bd,
TP_PROTO(struct sk_buff *skb),
TP_ARGS(skb),
TP_STRUCT__entry(
__field(unsigned int, headlen)
__field(__u8, nr_frags)
__field(unsigned short, gso_size)
__array(__u32, size, MAX_SKB_FRAGS)
),
TP_fast_assign(
__entry->headlen = skb_headlen(skb);
__entry->nr_frags = skb_shinfo(skb)->nr_frags;
__entry->gso_size = skb_shinfo(skb)->gso_size;
hns3_shinfo_pack(skb_shinfo(skb), __entry->size);
),
TP_printk(
"headlen: %u, nr_frags: %u, gso: %u frag size: %s",
__entry->headlen, __entry->gso_size, __entry->nr_frags,
__print_array(__entry->size, MAX_SKB_FRAGS, sizeof(__u32))
)
);
TRACE_EVENT(hns3_tx_desc,
TP_PROTO(struct hns3_enet_ring *ring),
TP_ARGS(ring),
TP_STRUCT__entry(
__field(int, index)
__field(int, ntu)
__field(int, ntc)
__field(dma_addr_t, desc_dma)
__array(u32, desc, DESC_NR)
__string(devname, ring->tqp->handle->kinfo.netdev->name)
),
TP_fast_assign(
__entry->index = ring->tqp->tqp_index;
__entry->ntu = ring->next_to_use;
__entry->ntc = ring->next_to_clean;
__entry->desc_dma = ring->desc_dma_addr,
memcpy(__entry->desc, &ring->desc[ring->next_to_use],
sizeof(struct hns3_desc));
__assign_str(devname, ring->tqp->handle->kinfo.netdev->name);
),
TP_printk(
"%s-%d-%d/%d desc(0x%llx): %s",
__get_str(devname), __entry->index, __entry->ntu,
__entry->ntc, __entry->desc_dma,
__print_array(__entry->desc, DESC_NR, sizeof(u32))
)
);
TRACE_EVENT(hns3_rx_desc,
TP_PROTO(struct hns3_enet_ring *ring),
TP_ARGS(ring),
TP_STRUCT__entry(
__field(int, index)
__field(int, ntu)
__field(int, ntc)
__field(dma_addr_t, desc_dma)
__field(dma_addr_t, buf_dma)
__array(u32, desc, DESC_NR)
__string(devname, ring->tqp->handle->kinfo.netdev->name)
),
TP_fast_assign(
__entry->index = ring->tqp->tqp_index;
__entry->ntu = ring->next_to_use;
__entry->ntc = ring->next_to_clean;
__entry->desc_dma = ring->desc_dma_addr;
__entry->buf_dma = ring->desc_cb[ring->next_to_clean].dma;
memcpy(__entry->desc, &ring->desc[ring->next_to_clean],
sizeof(struct hns3_desc));
__assign_str(devname, ring->tqp->handle->kinfo.netdev->name);
),
TP_printk(
"%s-%d-%d/%d desc(0x%llx) buf(0x%llx): %s",
__get_str(devname), __entry->index, __entry->ntu,
__entry->ntc, __entry->desc_dma, __entry->buf_dma,
__print_array(__entry->desc, DESC_NR, sizeof(u32))
)
);
#endif /* _HNS3_TRACE_H_ */
/* This must be outside ifdef _HNS3_TRACE_H */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE hns3_trace
#include <trace/define_trace.h>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册