DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Sujith Sankar (ssujith)" <ssujith@cisco.com>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] enicpd: Warnings and one error when built using clang compiler
Date: Mon, 1 Dec 2014 11:06:43 +0000	[thread overview]
Message-ID: <D0A247E2.292E0%ssujith@cisco.com> (raw)
In-Reply-To: <20141201105756.GB4856@bricha3-MOBL3>


On 01/12/14 4:27 pm, "Bruce Richardson" <bruce.richardson@intel.com> wrote:

>On Sat, Nov 29, 2014 at 12:47:37PM +0530, Sujith Sankar wrote:
>> This patch fixes the warnings and error reported by clang compiler on
>>Linux.
>> 
>> Reported-by: Bruce Richardson <bruce.richardson@intel.com>
>> Signed-off-by: Sujith Sankar <ssujith@cisco.com>
>
>This PMD now compiles up with clang on FreeBSD. The patch seems rather
>large though,
>are all these changes necessary for clang compilation?

Yes.  This patch has only the changes to fix compilation on clang, and it
modifies enic code only.

>
>On the basis that this fixes the issue though:
>
>Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Thanks Bruce.

>
>> ---
>>  lib/librte_pmd_enic/enic.h          | 40
>>+++++++++++++++++++++++++++++++++++++
>>  lib/librte_pmd_enic/enic_compat.h   |  1 +
>>  lib/librte_pmd_enic/enic_main.c     | 31 +++++++++++++++-------------
>>  lib/librte_pmd_enic/vnic/vnic_dev.c | 19 ++++++++++--------
>>  lib/librte_pmd_enic/vnic/vnic_dev.h |  9 +++++++++
>>  5 files changed, 78 insertions(+), 22 deletions(-)
>> 
>> diff --git a/lib/librte_pmd_enic/enic.h b/lib/librte_pmd_enic/enic.h
>> index 6400d24..f128e64 100644
>> --- a/lib/librte_pmd_enic/enic.h
>> +++ b/lib/librte_pmd_enic/enic.h
>> @@ -154,4 +154,44 @@ static inline struct enic *pmd_priv(struct
>>rte_eth_dev *eth_dev)
>>  	return (struct enic *)eth_dev->data->dev_private;
>>  }
>>  
>> +extern int enic_fdir_add_fltr(struct enic *enic,
>> +	struct rte_fdir_filter *params, u16 queue, u8 drop);
>> +extern int enic_fdir_del_fltr(struct enic *enic,
>> +	struct rte_fdir_filter *params);
>> +extern void enic_free_wq(void *txq);
>> +extern int enic_alloc_intr_resources(struct enic *enic);
>> +extern int enic_setup_finish(struct enic *enic);
>> +extern int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
>> +	unsigned int socket_id, uint16_t nb_desc);
>> +extern void enic_start_wq(struct enic *enic, uint16_t queue_idx);
>> +extern int enic_stop_wq(struct enic *enic, uint16_t queue_idx);
>> +extern void enic_start_rq(struct enic *enic, uint16_t queue_idx);
>> +extern int enic_stop_rq(struct enic *enic, uint16_t queue_idx);
>> +extern void enic_free_rq(void *rxq);
>> +extern int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
>> +	unsigned int socket_id, struct rte_mempool *mp,
>> +	uint16_t nb_desc);
>> +extern int enic_set_rss_nic_cfg(struct enic *enic);
>> +extern int enic_set_vnic_res(struct enic *enic);
>> +extern void enic_set_hdr_split_size(struct enic *enic, u16
>>split_hdr_size);
>> +extern int enic_enable(struct enic *enic);
>> +extern int enic_disable(struct enic *enic);
>> +extern void enic_remove(struct enic *enic);
>> +extern int enic_get_link_status(struct enic *enic);
>> +extern void enic_dev_stats_get(struct enic *enic,
>> +	struct rte_eth_stats *r_stats);
>> +extern void enic_dev_stats_clear(struct enic *enic);
>> +extern void enic_add_packet_filter(struct enic *enic);
>> +extern void enic_set_mac_address(struct enic *enic, uint8_t *mac_addr);
>> +extern void enic_del_mac_address(struct enic *enic);
>> +extern unsigned int enic_cleanup_wq(struct enic *enic, struct vnic_wq
>>*wq);
>> +extern int enic_send_pkt(struct enic *enic, struct vnic_wq *wq,
>> +	struct rte_mbuf *tx_pkt, unsigned short len,
>> +	uint8_t sop, uint8_t eop,
>> +	uint16_t ol_flags, uint16_t vlan_tag);
>> +extern int enic_poll(struct vnic_rq *rq, struct rte_mbuf **rx_pkts,
>> +	unsigned int budget, unsigned int *work_done);
>> +extern int enic_probe(struct enic *enic);
>> +extern int enic_clsf_init(struct enic *enic);
>> +extern void enic_clsf_destroy(struct enic *enic);
>>  #endif /* _ENIC_H_ */
>> diff --git a/lib/librte_pmd_enic/enic_compat.h
>>b/lib/librte_pmd_enic/enic_compat.h
>> index b3738ee..b1af838 100644
>> --- a/lib/librte_pmd_enic/enic_compat.h
>> +++ b/lib/librte_pmd_enic/enic_compat.h
>> @@ -37,6 +37,7 @@
>>  #define _ENIC_COMPAT_H_
>>  
>>  #include <stdio.h>
>> +#include <unistd.h>
>>  
>>  #include <rte_atomic.h>
>>  #include <rte_malloc.h>
>> diff --git a/lib/librte_pmd_enic/enic_main.c
>>b/lib/librte_pmd_enic/enic_main.c
>> index 853dd04..4bbf1e4 100644
>> --- a/lib/librte_pmd_enic/enic_main.c
>> +++ b/lib/librte_pmd_enic/enic_main.c
>> @@ -65,17 +65,17 @@ static inline int enic_is_sriov_vf(struct enic
>>*enic)
>>  	return enic->pdev->id.device_id == PCI_DEVICE_ID_CISCO_VIC_ENET_VF;
>>  }
>>  
>> -static int is_zero_addr(char *addr)
>> +static int is_zero_addr(uint8_t *addr)
>>  {
>>  	return !(addr[0] |  addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
>>  }
>>  
>> -static int is_mcast_addr(char *addr)
>> +static int is_mcast_addr(uint8_t *addr)
>>  {
>>  	return addr[0] & 1;
>>  }
>>  
>> -static int is_eth_addr_valid(char *addr)
>> +static int is_eth_addr_valid(uint8_t *addr)
>>  {
>>  	return !is_mcast_addr(addr) && !is_zero_addr(addr);
>>  }
>> @@ -105,7 +105,8 @@ static const struct rte_memzone
>>*ring_dma_zone_reserve(
>>  	if (mz)
>>  		return mz;
>>  
>> -	return rte_memzone_reserve_aligned(z_name, (uint64_t) ring_size,
>> +	return rte_memzone_reserve_aligned((const char *)z_name,
>> +		(uint64_t) ring_size,
>>  		socket_id, RTE_MEMZONE_1GB, ENIC_ALIGN);
>>  }
>>  
>> @@ -430,14 +431,15 @@ static int enic_rq_indicate_buf(struct vnic_rq
>>*rq,
>>  		&ipv4_csum_ok, &ipv6, &ipv4, &ipv4_fragment,
>>  		&fcs_ok);
>>  
>> -	if (packet_error) {
>> -		dev_err(enic, "packet error\n");
>> -		return;
>> -	}
>> -
>>  	rx_pkt = (struct rte_mbuf *)buf->os_buf;
>>  	buf->os_buf = NULL;
>>  
>> +	if (unlikely(packet_error)) {
>> +		dev_err(enic, "packet error\n");
>> +		rx_pkt->data_len = 0;
>> +		return 0;
>> +	}
>> +
>>  	if (unlikely(skipped)) {
>>  		rx_pkt->data_len = 0;
>>  		return 0;
>> @@ -563,7 +565,8 @@ void *enic_alloc_consistent(void *priv, size_t size,
>>  	const struct rte_memzone *rz;
>>  	*dma_handle = 0;
>>  
>> -	rz = rte_memzone_reserve_aligned(name, size, 0, 0, ENIC_ALIGN);
>> +	rz = rte_memzone_reserve_aligned((const char *)name,
>> +		size, 0, 0, ENIC_ALIGN);
>>  	if (!rz) {
>>  		pr_err("%s : Failed to allocate memory requested for %s",
>>  			__func__, name);
>> @@ -873,9 +876,9 @@ static int enic_set_rsskey(struct enic *enic)
>>  		.key[3].b = {69, 78, 73, 67, 105, 115, 99, 111, 111, 108},
>>  	};
>>  	int err;
>> -	char name[NAME_MAX];
>> +	u8 name[NAME_MAX];
>>  
>> -	snprintf(name, NAME_MAX, "rss_key-%s", enic->bdf_name);
>> +	snprintf((char *)name, NAME_MAX, "rss_key-%s", enic->bdf_name);
>>  	rss_key_buf_va = enic_alloc_consistent(enic, sizeof(union
>>vnic_rss_key),
>>  		&rss_key_buf_pa, name);
>>  	if (!rss_key_buf_va)
>> @@ -899,9 +902,9 @@ static int enic_set_rsscpu(struct enic *enic, u8
>>rss_hash_bits)
>>  	union vnic_rss_cpu *rss_cpu_buf_va = NULL;
>>  	unsigned int i;
>>  	int err;
>> -	char name[NAME_MAX];
>> +	u8 name[NAME_MAX];
>>  
>> -	snprintf(name, NAME_MAX, "rss_cpu-%s", enic->bdf_name);
>> +	snprintf((char *)name, NAME_MAX, "rss_cpu-%s", enic->bdf_name);
>>  	rss_cpu_buf_va = enic_alloc_consistent(enic, sizeof(union
>>vnic_rss_cpu),
>>  		&rss_cpu_buf_pa, name);
>>  	if (!rss_cpu_buf_va)
>> diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.c
>>b/lib/librte_pmd_enic/vnic/vnic_dev.c
>> index 485123f..682c9c9 100644
>> --- a/lib/librte_pmd_enic/vnic/vnic_dev.c
>> +++ b/lib/librte_pmd_enic/vnic/vnic_dev.c
>> @@ -517,13 +517,14 @@ int vnic_dev_stats_dump(struct vnic_dev *vdev,
>>struct vnic_stats **stats)
>>  {
>>  	u64 a0, a1;
>>  	int wait = 1000;
>> -	static instance;
>> +	static u32 instance;
>>  	char name[NAME_MAX];
>>  
>>  	if (!vdev->stats) {
>> -		snprintf(name, sizeof(name), "vnic_stats-%d", instance++);
>> +		snprintf((char *)name, sizeof(name),
>> +			"vnic_stats-%d", instance++);
>>  		vdev->stats = vdev->alloc_consistent(vdev->priv,
>> -			sizeof(struct vnic_stats), &vdev->stats_pa, name);
>> +			sizeof(struct vnic_stats), &vdev->stats_pa, (u8 *)name);
>>  		if (!vdev->stats)
>>  			return -ENOMEM;
>>  	}
>> @@ -763,7 +764,7 @@ int vnic_dev_notify_set(struct vnic_dev *vdev, u16
>>intr)
>>  	void *notify_addr;
>>  	dma_addr_t notify_pa;
>>  	char name[NAME_MAX];
>> -	static int instance;
>> +	static u32 instance;
>>  
>>  	if (vdev->notify || vdev->notify_pa) {
>>  		pr_warn("notify block %p still allocated.\n" \
>> @@ -772,10 +773,11 @@ int vnic_dev_notify_set(struct vnic_dev *vdev,
>>u16 intr)
>>  	}
>>  
>>  	if (!vnic_dev_in_reset(vdev)) {
>> -		snprintf(name, sizeof(name), "vnic_notify-%d", instance++);
>> +		snprintf((char *)name, sizeof(name),
>> +			"vnic_notify-%d", instance++);
>>  		notify_addr = vdev->alloc_consistent(vdev->priv,
>>  			sizeof(struct vnic_devcmd_notify),
>> -			&notify_pa, name);
>> +			&notify_pa, (u8 *)name);
>>  		if (!notify_addr)
>>  			return -ENOMEM;
>>  	}
>> @@ -1028,9 +1030,10 @@ int vnic_dev_classifier(struct vnic_dev *vdev,
>>u8 cmd, u16 *entry,
>>  		tlv_size = sizeof(struct filter) +
>>  		    sizeof(struct filter_action) +
>>  		    2*sizeof(struct filter_tlv);
>> -		snprintf(z_name, sizeof(z_name), "vnic_clsf_%d", unique_id++);
>> +		snprintf((char *)z_name, sizeof(z_name),
>> +			"vnic_clsf_%d", unique_id++);
>>  		tlv_va = vdev->alloc_consistent(vdev->priv,
>> -			tlv_size, &tlv_pa, z_name);
>> +			tlv_size, &tlv_pa, (u8 *)z_name);
>>  		if (!tlv_va)
>>  			return -ENOMEM;
>>  		tlv = tlv_va;
>> diff --git a/lib/librte_pmd_enic/vnic/vnic_dev.h
>>b/lib/librte_pmd_enic/vnic/vnic_dev.h
>> index 63c26dd..8cc036b 100644
>> --- a/lib/librte_pmd_enic/vnic/vnic_dev.h
>> +++ b/lib/librte_pmd_enic/vnic/vnic_dev.h
>> @@ -100,6 +100,12 @@ struct vnic_stats;
>>  void *vnic_dev_priv(struct vnic_dev *vdev);
>>  unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
>>  	enum vnic_res_type type);
>> +void vnic_register_cbacks(struct vnic_dev *vdev,
>> +	void *(*alloc_consistent)(void *priv, size_t size,
>> +		dma_addr_t *dma_handle, u8 *name),
>> +	void (*free_consistent)(struct rte_pci_device *hwdev,
>> +		size_t size, void *vaddr,
>> +		dma_addr_t dma_handle));
>>  void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum
>>vnic_res_type type,
>>  	unsigned int index);
>>  dma_addr_t vnic_dev_get_res_bus_addr(struct vnic_dev *vdev,
>> @@ -113,6 +119,8 @@ unsigned long vnic_dev_get_res_type_len(struct
>>vnic_dev *vdev,
>>  unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
>>  	unsigned int desc_count, unsigned int desc_size);
>>  void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring);
>> +void vnic_set_hdr_split_size(struct vnic_dev *vdev, u16 size);
>> +u16 vnic_get_hdr_split_size(struct vnic_dev *vdev);
>>  int vnic_dev_alloc_desc_ring(struct vnic_dev *vdev, struct
>>vnic_dev_ring *ring,
>>  	unsigned int desc_count, unsigned int desc_size, unsigned int
>>socket_id,
>>  	char *z_name);
>> @@ -142,6 +150,7 @@ int vnic_dev_del_addr(struct vnic_dev *vdev, u8
>>*addr);
>>  int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr);
>>  int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr);
>>  int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr);
>> +void vnic_dev_set_reset_flag(struct vnic_dev *vdev, int state);
>>  int vnic_dev_notify_unset(struct vnic_dev *vdev);
>>  int vnic_dev_notify_setcmd(struct vnic_dev *vdev,
>>  	void *notify_addr, dma_addr_t notify_pa, u16 intr);
>> -- 
>> 1.9.1
>> 

  reply	other threads:[~2014-12-01 11:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-29  7:17 Sujith Sankar
2014-11-29  7:22 ` Sujith Sankar (ssujith)
2014-11-29 11:17   ` Thomas Monjalon
2014-11-29 13:20     ` Sujith Sankar (ssujith)
2014-12-01 10:57 ` Bruce Richardson
2014-12-01 11:06   ` Sujith Sankar (ssujith) [this message]
2014-12-01 11:17     ` Bruce Richardson
2014-12-01 11:25   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D0A247E2.292E0%ssujith@cisco.com \
    --to=ssujith@cisco.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).