[PATCH 1/2] net: add an identifier name for 'struct sock *'
Fix a warning from checkpatch: function definition argument 'struct sock *' should also have an identifier name in include/net/af_unix.h. Signed-off-by: Bo YU --- include/net/af_unix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/af_unix.h b/include/net/af_unix.h index e2695c4bf358..d53aea859a76 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -13,7 +13,7 @@ void unix_notinflight(struct user_struct *user, struct file *fp); void unix_gc(void); void wait_for_unix_gc(void); struct sock *unix_get_socket(struct file *filp); -struct sock *unix_peer_get(struct sock *); +struct sock *unix_peer_get(struct sock *sk); #define UNIX_HASH_SIZE 256 #define UNIX_HASH_BITS 8 -- 2.11.0
[PATCH 2/2] net: drop a space before tabs
Fix a warning from checkpatch.pl:'please no space before tabs' in include/net/af_unix.h Signed-off-by: Bo YU --- include/net/af_unix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/af_unix.h b/include/net/af_unix.h index d53aea859a76..ddbba838d048 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -40,7 +40,7 @@ struct unix_skb_parms { u32 consumed; } __randomize_layout; -#define UNIXCB(skb)(*(struct unix_skb_parms *)&((skb)->cb)) +#define UNIXCB(skb)(*(struct unix_skb_parms *)&((skb)->cb)) #define unix_state_lock(s) spin_lock(_sk(s)->lock) #define unix_state_unlock(s) spin_unlock(_sk(s)->lock) -- 2.11.0
[PATCH 0/2] net: fix warnings in include/net/af_unix.h
Fix two warnings from checkpatch.pl. Bo YU (2): net: add an identifier name for 'struct sock *' net: drop a space before tabs include/net/af_unix.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.11.0
[PATCH] net: sample/bpf/tracex3_user.c: erase "ARRAY_SIZE" redefined
There is a warning when compiling bpf program in sample/bpf BTW,i get the warning from David's net tree, then i git clone bpf tree try to compile bpf program,but it tell me failed to do that maybe i was not compile the whole kernel once. I don't know this is ok or not. Signed-off-by: Bo YU --- samples/bpf/tracex3_user.c | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/bpf/tracex3_user.c b/samples/bpf/tracex3_user.c index 6c6b10f4c3ee..3d8c39b8ef24 100644 --- a/samples/bpf/tracex3_user.c +++ b/samples/bpf/tracex3_user.c @@ -17,7 +17,6 @@ #include "bpf_load.h" #include "bpf_util.h" -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #define SLOTS 100 -- 2.11.0
Re: iproute2: Debian 9 No ELF support
Hi, On Mon, Sep 17, 2018 at 11:57:12AM +0200, Daniel Borkmann wrote: On 09/17/2018 10:23 AM, Bo YU wrote: Hello, I have followed the instructions from: https://cilium.readthedocs.io/en/latest/bpf/#bpftool to test xdp program. But i can not enable elf support. ./configure --prefix=/usr ```output TC schedulers ATM no libc has setns: yes SELinux support: no ELF support: no libmnl support: yes Berkeley DB: yes need for strlcpy: yes libcap support: yes ``` And i have installed libelf-dev : ```output sudo apt show libelf-dev Package: libelf-dev Version: 0.168-1 Priority: optional Section: libdevel Source: elfutils Maintainer: Kurt Roeckx Installed-Size: 353 kB Depends: libelf1 (= 0.168-1) Conflicts: libelfg0-dev Homepage: https://sourceware.org/elfutils/ Tag: devel::library, role::devel-lib ``` And gcc version: gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) uname -a: Linux debian 4.18.0-rc1+ #2 SMP Sun Jun 24 16:53:57 HKT 2018 x86_64 GNU/Linux Any help is appreciate. Debian's official iproute2 packaging build says 'libelf-dev' [0], and having libelf-dev installed should work ... [...] Build-Depends: bison, debhelper (>= 10~), flex, iptables-dev, libatm1-dev, libcap-dev, libdb-dev, libelf-dev, libmnl-dev, libselinux1-dev, linux-libc-dev, pkg-config, po-debconf, zlib1g-dev, [...] Did you ran into this one perhaps [1]? Do you have zlib1g-dev installed? Yes,You are right. I install zlib1g-dev with your help,iproute2 enable ELF support. ```output ./configure --prefix=/usr TC schedulers ATM no libc has setns: yes SELinux support: no ELF support: yes libmnl support: yes Berkeley DB: yes need for strlcpy: yes libcap support: yes ``` But there is no effect after [1], right? When i install libelf-dev,it should install zlib1g-dev also. Is there any way to update the page [2]? Thank you, Daniel [2] https://cilium.readthedocs.io/en/latest/bpf/#bpftool [0] https://salsa.debian.org/debian/iproute2/blob/master/debian/control [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=885071
iproute2: Debian 9 No ELF support
Hello, I have followed the instructions from: https://cilium.readthedocs.io/en/latest/bpf/#bpftool to test xdp program. But i can not enable elf support. ./configure --prefix=/usr ```output TC schedulers ATM no libc has setns: yes SELinux support: no ELF support: no libmnl support: yes Berkeley DB: yes need for strlcpy: yes libcap support: yes ``` And i have installed libelf-dev : ```output sudo apt show libelf-dev Package: libelf-dev Version: 0.168-1 Priority: optional Section: libdevel Source: elfutils Maintainer: Kurt Roeckx Installed-Size: 353 kB Depends: libelf1 (= 0.168-1) Conflicts: libelfg0-dev Homepage: https://sourceware.org/elfutils/ Tag: devel::library, role::devel-lib ``` And gcc version: gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) uname -a: Linux debian 4.18.0-rc1+ #2 SMP Sun Jun 24 16:53:57 HKT 2018 x86_64 GNU/Linux Any help is appreciate.
Re: [PATCH bpf-next v5 00/10] BTF: BPF Type Format
Hi, On Thu, Jun 07, 2018 at 04:30:29PM -0300, Arnaldo Carvalho de Melo wrote: Em Thu, Jun 07, 2018 at 12:05:10PM -0700, Martin KaFai Lau escreveu: dump-obj = true clang-opt = -g [root@jouet bpf]# perf trace -e open*,hello.c touch /tmp/hello.BTF LLVM: dumping hello.o 0.185 ( ): __bpf_stdout__:Hello, world 0.188 ( 0.009 ms): touch/19670 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC ) = 3 0.219 ( ): __bpf_stdout__:Hello, world 0.220 ( 0.011 ms): touch/19670 openat(dfd: CWD, filename: /lib64/libc.so.6, flags: CLOEXEC ) = 3 0.480 ( 0.095 ms): touch/19670 open(filename: /usr/lib/locale/locale-archive, flags: CLOEXEC ) = 3 0.624 ( ): __bpf_stdout__:Hello, world 0.626 ( 0.011 ms): touch/19670 openat(dfd: CWD, filename: /tmp/hello.BTF, flags: CREAT|NOCTTY|NONBLOCK|WRONLY, mode: IRUGO|IWUGO) = 3 [root@jouet bpf]# file hello.o hello.o: ELF 64-bit LSB relocatable, *unknown arch 0xf7* version 1 (SYSV), with debug_info, not stripped [root@jouet bpf]# Much better: [root@jouet bpf]# readelf -SW hello.o There are 25 section headers, starting at offset 0xc70: Section Headers: [Nr] Name TypeAddress OffSize ES Flg Lk Inf Al [ 0] NULL 00 00 00 0 0 0 [ 1] .strtab STRTAB 000b50 000119 00 0 0 1 [ 2] .text PROGBITS 40 00 00 AX 0 0 4 [ 3] syscalls:sys_enter_openat PROGBITS 40 88 00 AX 0 0 8 [ 4] .relsyscalls:sys_enter_openat REL 000910 10 10 24 3 8 [ 5] license PROGBITS c8 04 00 WA 0 0 1 [ 6] version PROGBITS cc 04 00 WA 0 0 4 [ 7] maps PROGBITS d0 10 00 WA 0 0 4 [ 8] .rodata.str1.1PROGBITS e0 0e 01 AMS 0 0 1 [ 9] .debug_strPROGBITS ee 00010e 01 MS 0 0 1 [10] .debug_locPROGBITS 0001fc 23 00 0 0 1 [11] .debug_abbrev PROGBITS 00021f e3 00 0 0 1 [12] .debug_info PROGBITS 000302 00015e 00 0 0 1 [13] .rel.debug_info REL 000920 0001e0 10 24 12 8 [14] .debug_ranges PROGBITS 000460 30 00 0 0 1 [15] .debug_macinfoPROGBITS 000490 01 00 0 0 1 [16] .debug_pubnames PROGBITS 000491 6e 00 0 0 1 [17] .rel.debug_pubnames REL 000b00 10 10 24 16 8 [18] .debug_pubtypes PROGBITS 0004ff 5a 00 0 0 1 [19] .rel.debug_pubtypes REL 000b10 10 10 24 18 8 [20] .debug_frame PROGBITS 000560 28 00 0 0 8 [21] .rel.debug_frame REL 000b20 20 10 24 20 8 [22] .debug_line PROGBITS 000588 6e 00 0 0 1 [23] .rel.debug_line REL 000b40 10 10 24 22 8 [24] .symtab SYMTAB 0005f8 000318 18 1 29 8 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), p (processor specific) [root@jouet bpf]# [root@jouet bpf]# readelf -s hello.o Symbol table '.symtab' contains 33 entries: Num:Value Size TypeBind Vis Ndx Name 0: 0 NOTYPE LOCAL DEFAULT UND 1: 0 NOTYPE LOCAL DEFAULT9 2: 002d 0 NOTYPE LOCAL DEFAULT9 3: 0044 0 NOTYPE LOCAL DEFAULT9 4: 0053 0 NOTYPE LOCAL DEFAULT9 5: 005c 0 NOTYPE LOCAL DEFAULT9 6: 0061 0 NOTYPE LOCAL DEFAULT9 7: 006a 0 NOTYPE LOCAL DEFAULT9 8: 0073 0 NOTYPE LOCAL DEFAULT9 9: 0077 0 NOTYPE LOCAL DEFAULT9 10: 0086 0 NOTYPE LOCAL DEFAULT9 11: 008b 0 NOTYPE LOCAL DEFAULT9 12: 0098 0 NOTYPE LOCAL DEFAULT9 13: 00a1 0 NOTYPE LOCAL DEFAULT9 14: 00ac 0 NOTYPE LOCAL DEFAULT9 15: 00b8 0 NOTYPE LOCAL DEFAULT9 16: 00c4 0 NOTYPE LOCAL DEFAULT9 17: 00d6 0 NOTYPE LOCAL DEFAULT9 18: 00e8 0
Re: [PATCH V3] net/netlink: make sure the headers line up actual value output
Hi, On Fri, May 04, 2018 at 01:02:23PM -0400, David Miller wrote: From: YU Bo <tsu.y...@gmail.com> Date: Thu, 3 May 2018 23:09:23 -0400 Making sure the headers line up properly with the actual value output of the command `cat /proc/net/netlink` Before the patch: sk Eth Pid Groups Rmem Wmem Dump Locks Drops Inode 33203952 0 897 0113 0 0 0 2 0 14906 Signed-off-by: Bo YU <tsu.y...@gmail.com> Applied, but why did you send this V3 to the list two times? Thanks a lot. When sent the email,i encounter networking issue and not sure send to the list.Sorry for making noise. Thank you.
[PATCH] NET/netlink: optimize output of seq_puts in af_netlink.c
Optimization of command output: `cat /proc/net/netlink` After the patch, we will get: https://clbin.com/lnu4L Signed-off-by: Bo YU <tsu.y...@gmail.com> --- net/netlink/af_netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 55342c4d5cec..2e2dd88fc79f 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -2606,13 +2606,13 @@ static int netlink_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) { seq_puts(seq, -"sk Eth PidGroups " -"Rmem Wmem Dump Locks Drops Inode\n"); +"sk Eth PidGroups " +"Rmem Wmem Dump LocksDropsInode\n"); } else { struct sock *s = v; struct netlink_sock *nlk = nlk_sk(s); - seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d %-8lu\n", + seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d %-8lu\n", s, s->sk_protocol, nlk->portid, -- 2.11.0
[PATCH net 1/1] Modify the seq_puts and seq_printf of af_netlink.c file
Modify format output symbol of seq_printf function and adjust blanks in seq_puts function in order to make convenience with command:`cat /proc/net/netlink` Signed-off-by: Bo YU <tsu.y...@gmail.com> --- net/netlink/af_netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 55342c4d5cec..2e2dd88fc79f 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -2606,13 +2606,13 @@ static int netlink_seq_show(struct seq_file *seq, void *v) { if (v == SEQ_START_TOKEN) { seq_puts(seq, -"sk Eth PidGroups " -"Rmem Wmem Dump Locks Drops Inode\n"); +"sk Eth PidGroups " +"Rmem Wmem Dump LocksDropsInode\n"); } else { struct sock *s = v; struct netlink_sock *nlk = nlk_sk(s); - seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d %-8lu\n", + seq_printf(seq, "%pK %-3d %-10u %08x %-8d %-8d %-5d %-8d %-8d %-8lu\n", s, s->sk_protocol, nlk->portid, -- 2.11.0
Re: [PATCH] netlink: put module reference if dump start fails
Hi, On Wed, Feb 21, 2018 at 04:41:05PM +0100, Jason A. Donenfeld wrote: Fixes: 41c87425a1ac ("netlink: do not set cb_running if dump's start() errs") I think you Would better to resend it. Bo,
Re: [PATCH] netxen: Fix a sleep-in-atomic bug in netxen_nic_pci_mem_access_direct
Hi, On Wed, Jun 21, 2017 at 02:33:03PM +0800, Jia-Ju Bai wrote: On 06/21/2017 02:11 PM, Kalle Valo wrote: David Millerwrites: From: Jia-Ju Bai Date: Mon, 19 Jun 2017 10:48:53 +0800 The driver may sleep under a spin lock, and the function call path is: netxen_nic_pci_mem_access_direct (acquire the lock by spin_lock) ioremap --> may sleep To fix it, the lock is released before "ioremap", and the lock is acquired again after this function. Signed-off-by: Jia-Ju Bai This style of change you are making is really starting to be a problem. You can't just drop locks like this, especially without explaining why it's ok, and why the mutual exclusion this code was trying to achieve is still going to be OK afterwards. In fact, I see zero analysis of the locking situation here, why it was needed in the first place, and why your change is OK in that context. Any locking change is delicate, and you must put the greatest of care and consideration into it. Just putting "unlock/lock" around the sleeping operation shows a very low level of consideration for the implications of the change you are making. This isn't like making whitespace fixes, sorry... We already tried to explain this to Jia-Ju during review of a wireless patch: https://patchwork.kernel.org/patch/9756585/ Jia-Ju, you should listen to feedback. If you continue submitting random patches like this makes it hard for maintainers to trust your patches anymore. Hi, I am quite sorry for my incorrect patches, and I will listen carefully to your advice. In fact, for some bugs and patches which I have reported before, I have not received the feedback of them, so I resent them a few days ago, including this patch. Sorry for my mistake again. Once your patch be accepted, maintainer will reply you by mail sent by automatic or themselves.But for your patch(es),i think most of them will be dropped silently, because (un)lock related operations is very criticality, especially in kernel code. Maintainers will not accept unsafe (un)lock code. Best Regards Thanks, Jia-Ju Bai
Re: [PATCH V3 net-next 1/8] net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC
Hi, On Sat, Jun 17, 2017 at 06:24:24PM +0100, Salil Mehta wrote: + struct notifier_block notifier_block; + /* Vxlan/Geneve information */ + struct hns3_udp_tunnel udp_tnl[HNS3_UDP_TNL_MAX]; +}; + +/* the distance between [begin, end) in a ring buffer + * note: there is a unuse slot between the begin and the end + */ +static inline int ring_dist(struct hns3_enet_ring *ring, int begin, int end) +{ + return (end - begin + ring->desc_num) % ring->desc_num; +} + +static inline int ring_space(struct hns3_enet_ring *ring) +{ + return ring->desc_num - + ring_dist(ring, ring->next_to_clean, ring->next_to_use) - 1; +} + +static inline int is_ring_empty(struct hns3_enet_ring *ring) +{ + return ring->next_to_use == ring->next_to_clean; +} + +static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value) +{ + u8 __iomem *reg_addr = READ_ONCE(base); + + writel(value, reg_addr + reg); +} + +#define hns3_write_dev(a, reg, value) \ + hns3_write_reg((a)->io_base, (reg), (value)) + +#define hnae_queue_xmit(tqp, buf_num) writel_relaxed(buf_num, \ + (tqp)->io_base + HNS3_RING_TX_RING_TAIL_REG) + +#define ring_to_dev(ring) (&(ring)->tqp->handle->pdev->dev) + +#define ring_to_dma_dir(ring) (HNAE3_IS_TX_RING(ring) ? \ + DMA_TO_DEVICE : DMA_FROM_DEVICE) + +#define tx_ring_data(priv, idx) ((priv)->ring_data[idx]) + +#define hnae_buf_size(_ring) ((_ring)->buf_size) +#define hnae_page_order(_ring) (get_order(hnae_buf_size(_ring))) +#define hnae_page_size(_ring) (PAGE_SIZE << hnae_page_order(_ring)) + +/* iterator for handling rings in ring group */ +#define hns3_for_each_ring(pos, head) \ + for (pos = (head).ring; pos != NULL; pos = pos->next) Only a pos? Comparsion to NULL could be written "pos" noticed by checkpatch. + +void hns3_ethtool_set_ops(struct net_device *ndev); + +int hns3_nic_net_xmit_hw( + struct net_device *ndev, + struct sk_buff *skb, + struct hns3_nic_ring_data *ring_data); +int hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget); +int hns3_clean_rx_ring_ex( + struct hns3_enet_ring *ring, + struct sk_buff **skb_ex, + int budget); +#endif -- 2.7.4
Re: [PATCH V3 net-next 2/8] net: hns3: Add support of the HNAE3 framework
Hi, On Sat, Jun 17, 2017 at 06:24:25PM +0100, Salil Mehta wrote: + * Unregister client from ae_dev + * start() + * Enable the hardware + * stop() + * Disable the hardware + * get_status() + * Get the carrier state of the back channel of the handle, 1 for ok, 0 for + * non-ok + * get_ksettings_an_result() + * Get negotiation status,speed and duplex + * update_speed_duplex_h() + * Update hardware speed and duplex + * get_media_type() + * Get media type of MAC + * adjust_link() + * Adjust link status + * set_loopback() + * Set loopback + * set_promisc_mode + * Set promisc mode + * set_mtu() + * set mtu + * get_pauseparam() + * get tx and rx of pause frame use + * set_pauseparam() + * set tx and rx of pause frame use + * set_autoneg() + * set auto autonegotiation of pause frame use + * get_autoneg() + * get auto autonegotiation of pause frame use + * get_coalesce_usecs() + * get usecs to delay a TX interrupt after a packet is sent + * get_rx_max_coalesced_frames() + * get Maximum number of packets to be sent before a TX interrupt. + * set_coalesce_usecs() + * set usecs to delay a TX interrupt after a packet is sent + * set_coalesce_frames() + * set Maximum number of packets to be sent before a TX interrupt. + * get_mac_addr() + * get mac address + * set_mac_addr() + * set mac address + * add_uc_addr + * Add unicast addr to mac table + * rm_uc_addr + * Remove unicast addr from mac table + * set_mc_addr() + * Set multicast address + * add_mc_addr + * Add multicast address to mac table + * rm_mc_addr + * Remove multicast address from mac table + * update_stats() + * Update Old network device statistics + * get_ethtool_stats() + * Get ethtool network device statistics + * get_strings() + * Get a set of strings that describe the requested objects + * get_sset_count() + * Get number of strings that @get_strings will write + * update_led_status() + * Update the led status + * set_led_id() + * Set led id + * get_regs() + * Get regs dump + * get_regs_len() + * Get the len of the regs dump + * get_rss_key_size() + * Get rss key size + * get_rss_indir_size() + * Get rss indirection table size + * get_rss() + * Get rss table + * set_rss() + * Set rss table + * get_tc_size() + * Get tc size of handle + * get_vector() + * Get vector number and vector infomation Just another spealling : information Checkpatch will report it also. + * map_ring_to_vector() + * Map rings to vector + * unmap_ring_from_vector() + * Unmap rings from vector + * add_tunnel_udp() + * Add tunnel information to hardware + * del_tunnel_udp() + * Delete tunnel information from hardware + * reset_queue() + * Reset queue + * get_fw_version() + * Get firmware version + * get_mdix_mode() + * Get media typr of phy + * set_vlan_filter() + * Set vlan filter config of Ports + * set_vf_vlan_filter() + * Set vlan filter config of vf + */ +struct hnae3_ae_ops { + int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev); + void (*uninit_ae_dev)(struct hnae3_ae_dev *ae_dev); + + int (*register_client)(struct hnae3_client *client, + struct hnae3_ae_dev *ae_dev); + void (*unregister_client)(struct hnae3_client *client, + struct hnae3_ae_dev *ae_dev); + int (*start)(struct hnae3_handle *handle); + void (*stop)(struct hnae3_handle *handle); + int (*get_status)(struct hnae3_handle *handle); + void (*get_ksettings_an_result)(struct hnae3_handle *handle, + u8 *auto_neg, u32 *speed, u8 *duplex); + + int (*update_speed_duplex_h)(struct hnae3_handle *handle); + int (*cfg_mac_speed_dup_h)(struct hnae3_handle *handle, int speed, + u8 duplex); + + void (*get_media_type)(struct hnae3_handle *handle, u8 *media_type); + void (*adjust_link)(struct hnae3_handle *handle, int speed, int duplex); + int (*set_loopback)(struct hnae3_handle *handle, + enum hnae3_loop loop_mode, bool en); + + void (*set_promisc_mode)(struct hnae3_handle *handle, u32 en); + int (*set_mtu)(struct hnae3_handle *handle, int new_mtu); + + void (*get_pauseparam)(struct hnae3_handle *handle, + u32 *auto_neg, u32 *rx_en, u32 *tx_en); + int (*set_pauseparam)(struct hnae3_handle *handle, + u32 auto_neg, u32 rx_en, u32 tx_en); + + int (*set_autoneg)(struct hnae3_handle *handle, bool enable); + int (*get_autoneg)(struct hnae3_handle *handle); + + void (*get_coalesce_usecs)(struct hnae3_handle *handle, + u32 *tx_usecs, u32 *rx_usecs); + void (*get_rx_max_coalesced_frames)(struct hnae3_handle *handle, + u32 *tx_frames, u32 *rx_frames); + int (*set_coalesce_usecs)(struct hnae3_handle *handle, u32 timeout); +
Re: [PATCH V3 net-next 1/8] net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC
Hi, On Sat, Jun 17, 2017 at 06:24:24PM +0100, Salil Mehta wrote: +static int hns3_fill_desc(struct hns3_enet_ring *ring, void *priv, + int size, dma_addr_t dma, int frag_end, + enum hns_desc_type type) +{ + struct hns3_desc_cb *desc_cb = >desc_cb[ring->next_to_use]; + struct hns3_desc *desc = >desc[ring->next_to_use]; + u32 ol_type_vlan_len_msec = 0; + u16 bdtp_fe_sc_vld_ra_ri = 0; + u32 type_cs_vlan_tso = 0; + struct sk_buff *skb; + u32 paylen = 0; + u16 mss = 0; + __be16 protocol; + u8 ol4_proto; + u8 il4_proto; + int ret; + + /* The txbd's baseinfo of DESC_TYPE_PAGE & DESC_TYPE_SKB */ + desc_cb->priv = priv; + desc_cb->length = size; + desc_cb->dma = dma; + desc_cb->type = type; + + /* now, fill the descriptor */ + desc->addr = cpu_to_le64(dma); + desc->tx.send_size = cpu_to_le16((u16)size); + hns3_set_txbd_baseinfo(_fe_sc_vld_ra_ri, frag_end); + desc->tx.bdtp_fe_sc_vld_ra_ri = cpu_to_le16(bdtp_fe_sc_vld_ra_ri); + + if (type == DESC_TYPE_SKB) { + skb = (struct sk_buff *)priv; + paylen = cpu_to_le16(skb->len); + + if (skb->ip_summed == CHECKSUM_PARTIAL) { + skb_reset_mac_len(skb); + protocol = skb->protocol; + + /* vlan packe t*/ Just a spealling: /* vlan packet */ + if (protocol == htons(ETH_P_8021Q)) { + protocol = vlan_get_protocol(skb); + skb->protocol = protocol; + } + hns3_get_l4_protocol(skb, _proto, _proto); + hns3_set_l2l3l4_len(skb, ol4_proto, il4_proto, + _cs_vlan_tso, + _type_vlan_len_msec); + ret = hns3_set_l3l4_type_csum(skb, ol4_proto, il4_proto, + _cs_vlan_tso, + _type_vlan_len_msec); + if (ret) + return ret; + + ret = hns3_set_tso(skb, , , + _cs_vlan_tso); + if (ret) + return ret; + } + + /* Set txbd */ + desc->tx.ol_type_vlan_len_msec = + cpu_to_le32(ol_type_vlan_len_msec); + desc->tx.type_cs_vlan_tso_len = + cpu_to_le32(type_cs_vlan_tso); + desc->tx.paylen = cpu_to_le16(paylen); + desc->tx.mss = cpu_to_le16(mss); + } + + /* move ring pointer to next.*/ + ring_ptr_move_fw(ring, next_to_use); + + return 0; +} + +static int hns3_fill_desc_tso(struct hns3_enet_ring *ring, void *priv, + int size, dma_addr_t dma, int frag_end, + enum hns_desc_type type) +{ + int frag_buf_num; + int sizeoflast; + int ret, k; + + frag_buf_num = (size + HNS3_MAX_BD_SIZE - 1) / HNS3_MAX_BD_SIZE; + sizeoflast = size % HNS3_MAX_BD_SIZE; + sizeoflast = sizeoflast ? sizeoflast : HNS3_MAX_BD_SIZE; + + /* When the frag size is bigger than hardware, split this frag */ + for (k = 0; k < frag_buf_num; k++) { + ret = hns3_fill_desc(ring, priv, +(k == frag_buf_num - 1) ? + sizeoflast : HNS3_MAX_BD_SIZE, + dma + HNS3_MAX_BD_SIZE * k, + frag_end && (k == frag_buf_num - 1) ? 1 : 0, + (type == DESC_TYPE_SKB && !k) ? + DESC_TYPE_SKB : DESC_TYPE_PAGE); + if (ret) + return ret; + } + + return 0; +} + +static int hns3_nic_maybe_stop_tso(struct sk_buff **out_skb, int *bnum, + struct hns3_enet_ring *ring) +{ + struct sk_buff *skb = *out_skb; + struct skb_frag_struct *frag; + int bdnum_for_frag; + int frag_num; + int buf_num; + int size; + int i; + + size = skb_headlen(skb); + buf_num = (size + HNS3_MAX_BD_SIZE - 1) / HNS3_MAX_BD_SIZE; + + frag_num = skb_shinfo(skb)->nr_frags; + for (i = 0; i < frag_num; i++) { + frag = _shinfo(skb)->frags[i]; + size = skb_frag_size(frag); + bdnum_for_frag = + (size + HNS3_MAX_BD_SIZE - 1) / HNS3_MAX_BD_SIZE; + if (bdnum_for_frag > HNS3_MAX_BD_PER_FRAG) + return -ENOMEM; + + buf_num += bdnum_for_frag; + } + + if (buf_num > ring_space(ring)) +