Re: [PATCH] Documentation: ip-sysctl.txt: clarify secure_redirects

2016-05-29 Thread David Miller
From: Eric Garver 
Date: Thu, 26 May 2016 12:28:05 -0400

> Clarify how secure_redirects works. Mention that RFC1122 always applies.
> 
> Signed-off-by: Eric Garver 

Applied, thanks.


Re: [PATCH net] sfc: use flow dissector helpers for aRFS

2016-05-29 Thread David Miller
From: Edward Cree 
Date: Thu, 26 May 2016 21:46:05 +0100

> Signed-off-by: Edward Cree 
> ---
> This seems to work in my testing, but I first looked at the flow dissector
> API less than four hours ago, so I might be doing it wrong.
> 
> I still think that this is too big a change for 'net' and that it's better
> to take the original fix now and then I'll respin this patch for net-next
> when it opens up.  But I'm also happy for you to take this now in which
> case I'll respin Jon's patch 2/2 on top of the result.  Your choice.

I definitely prefer this and have applied it, please respin Jon's patch.

Thanks!


Re: [PATCH net] ieee802154: fix logic error in ieee802154_llsec_parse_dev_addr

2016-05-29 Thread David Miller
From: Baozeng Ding 
Date: Thu, 26 May 2016 21:07:42 +0800

> Fix a logic error to avoid potential null pointer dereference.
> 
> Signed-off-by: Baozeng Ding 

Applied.


Re: [PATCH 1/1] net: nps_enet: Disable interrupts before napi reschedule

2016-05-29 Thread David Miller
From: Elad Kanfi 
Date: Thu, 26 May 2016 15:00:06 +0300

> From: Elad Kanfi 
> 
> Since NAPI works by shutting down event interrupts when theres
> work and turning them on when theres none, the net driver must
> make sure that interrupts are disabled when it reschedules polling.
> By calling napi_reschedule, the driver switches to polling mode,
> therefor there should be no interrupt interference.
> Any received packets will be handled in nps_enet_poll by polling the HW
> indication of received packet until all packets are handled.
> 
> Signed-off-by: Elad Kanfi 
> Acked-by: Noam Camus 

Applied.


Re: [patch] ptp: oops in ptp_ioctl()

2016-05-29 Thread David Miller
From: Dan Carpenter 
Date: Thu, 26 May 2016 09:46:22 +0300

> If we pass ERR_PTR(-EFAULT) to kfree() then it's going to oops.
> 
> Fixes: 2ece068e1b1d ('ptp: use memdup_user().')
> Signed-off-by: Dan Carpenter 

Applied, thanks.


Re: [PATCH v2 10/10] nl80211: Prefer kcalloc over kzalloc

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:54 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the checkpatch.pl warning -
> "prefer kcalloc over kzalloc with multiply"
>
> Signed-off-by: Kirtika Ruchandani 

Looks right to me.

Reviewed-by: Julian Calaby 

Thanks,

Julian Calaby


> ---
>  net/wireless/nl80211.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index 46757af..2964406 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -9482,7 +9482,7 @@ static int nl80211_parse_wowlan_nd(struct 
> cfg80211_registered_device *rdev,
> struct nlattr **tb;
> int err;
>
> -   tb = kzalloc(NUM_NL80211_ATTR * sizeof(*tb), GFP_KERNEL);
> +   tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL);
> if (!tb)
> return -ENOMEM;
>
> --
> 2.8.0.rc3.226.g39d4020
>



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH v1 1/1] net/lapb: tuse %*ph to dump buffers

2016-05-29 Thread David Miller
From: Andy Shevchenko 
Date: Thu, 26 May 2016 14:43:52 +0300

> Use %*ph specifier to dump small buffers in hex format instead doing this
> byte-by-byte.
> 
> Signed-off-by: Andy Shevchenko 

Applied.


Re: [PATCH net v2] virtio_net: fix virtnet_open and virtnet_probe competing for try_fill_recv

2016-05-29 Thread David Miller
From: wangyunjian 
Date: Thu, 26 May 2016 14:27:59 +0800

> In function virtnet_open() and virtnet_probe(), func try_fill_recv()
> will be executed at the same time. VQ in virtqueue_add() is not protected
> well and BUG_ON will be triggered when virito_net.ko being removed.
> 
> Signed-off-by: Yunjian Wang 

Patch is whitespace damanged by your email client.

Fix this, email a test patch to yourself, and do not try to resubmit
this patch to the mailing list until you can successfully apply one of
those test patches.

Thanks.


Re: [PATCH v2 09/10] nl80211: Fix checkpatch.pl warning

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:54 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the checkpatch.pl warning "foo * bar should be
> foo *bar"
>
> Signed-off-by: Kirtika Ruchandani 

Looks right to me.

Reviewed-by: Julian Calaby 

Thanks,

Julian Calaby


> ---
>  net/wireless/nl80211.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index c6d870e..46757af 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -12214,7 +12214,7 @@ void nl80211_send_ibss_bssid(struct 
> cfg80211_registered_device *rdev,
>  }
>
>  void cfg80211_notify_new_peer_candidate(struct net_device *dev, const u8 
> *addr,
> -   const u8* ie, u8 ie_len, gfp_t gfp)
> +   const u8 *ie, u8 ie_len, gfp_t gfp)
>  {
> struct wireless_dev *wdev = dev->ieee80211_ptr;
> struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
> @@ -13362,7 +13362,7 @@ void cfg80211_tdls_oper_request(struct net_device 
> *dev, const u8 *peer,
>  }
>  EXPORT_SYMBOL(cfg80211_tdls_oper_request);
>
> -static int nl80211_netlink_notify(struct notifier_block * nb,
> +static int nl80211_netlink_notify(struct notifier_block *nb,
>   unsigned long state,
>   void *_notify)
>  {
> --
> 2.8.0.rc3.226.g39d4020
>



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH v2 08/10] nl80211: Fix spelling

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:54 PM, Kirtika Ruchandani
 wrote:
> Fix 'implementation' spelling, reported by checkpatch.pl
>
> Signed-off-by: Kirtika Ruchandani 

Looks right to me.

Reviewed-by: Julian Calaby 

Thanks,

Julian Calaby


> ---
>  net/wireless/nl80211.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index 6f8e2a7..c6d870e 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -6492,7 +6492,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct 
> wireless_dev *wdev,
>nla_data(ssid), nla_len(ssid));
> request->match_sets[i].ssid.ssid_len =
> nla_len(ssid);
> -   /* special attribute - old implemenation w/a 
> */
> +   /* special attribute - old implementation w/a 
> */
> request->match_sets[i].rssi_thold =
> default_match_rssi;
> rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
> --
> 2.8.0.rc3.226.g39d4020
>



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH v2 07/10] nl80211: Avoid multiple assignments on same line

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:53 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the checkpatch.pl warning "multiple assignments
> should be avoided."
>
> Signed-off-by: Kirtika Ruchandani 

I'm not sure I agree with checkpatch here, but this looks right to me.

Reviewed-by: Julian Calaby 

Thanks,

Julian Calaby


> ---
>  net/wireless/nl80211.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index ad7cdce..6f8e2a7 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -2603,7 +2603,8 @@ static int nl80211_set_interface(struct sk_buff *skb, 
> struct genl_info *info)
>
> memset(, 0, sizeof(params));
>
> -   otype = ntype = dev->ieee80211_ptr->iftype;
> +   otype = dev->ieee80211_ptr->iftype;
> +   ntype = dev->ieee80211_ptr->iftype;
>
> if (info->attrs[NL80211_ATTR_IFTYPE]) {
> ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
> --
> 2.8.0.rc3.226.g39d4020
>



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: usbnet: smsc95xx: fix link detection for disabled autonegotiation

2016-05-29 Thread David Miller
From: Christoph Fritz 
Date: Thu, 26 May 2016 04:06:47 +0200

> @@ -1695,6 +1745,7 @@ static int smsc95xx_resume(struct usb_interface *intf)
>  
>   /* do this first to ensure it's cleared even in error case */
>   pdata->suspend_flags = 0;
> + schedule_delayed_work(>carrier_check, CARRIER_CHECK_DELAY);

Why are you not cancelling this delayed work in the suspend routine of
the driver?


Re: [PATCH v2 06/10] nl80211: Various checkpatch.pl spacing fixes

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:53 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the following spacing issues reported
> by checkpatch.pl -
> - space preferred around that 
> - no space needed after cast.
> - Alignment should match open parenthesis
> - suspect code indent for conditional statements
> - Statements should start on a tabstop
>
> This patch also contains two hunks to fix 'line over 80 characters',
> that are spacing related.
> All other instances of that warning have been ignored.
>
> Signed-off-by: Kirtika Ruchandani 

Looks right to me except for one minor point:

> ---
>  net/wireless/nl80211.c | 103 
> ++---
>  1 file changed, 54 insertions(+), 49 deletions(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index 11cbf0b..ad7cdce 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -1735,8 +1735,9 @@ static int nl80211_send_wiphy(struct 
> cfg80211_registered_device *rdev,
>rdev->wiphy.max_num_csa_counters))
> goto nla_put_failure;
>
> -   if (rdev->wiphy.regulatory_flags & 
> REGULATORY_WIPHY_SELF_MANAGED &&
> -   nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
> +   if ((rdev->wiphy.regulatory_flags &
> +REGULATORY_WIPHY_SELF_MANAGED) &&
> +nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))

Adding the brackets around the & expression doesn't look spacing
related to me. What's the exact warning this is fixing?

> goto nla_put_failure;
>
> if (nla_put(msg, NL80211_ATTR_EXT_FEATURES,

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH 1/2] ipv6: hide ip6_encap_hlen/ip6_tnl_encap definitions

2016-05-29 Thread David Miller
From: Arnd Bergmann 
Date: Wed, 25 May 2016 16:50:45 +0200

> A recent cleanup moved MAX_IPTUN_ENCAP_OPS along with some other
> definitions, but it is now invisible when CONFIG_INET is
> not defined, but still referenced from ip6_tunnel.h:
> 
> In file included from net/xfrm/xfrm_input.c:17:0:
> include/net/ip6_tunnel.h:67:17: error: 'MAX_IPTUN_ENCAP_OPS' undeclared here 
> (not in a function)
>ip6tun_encaps[MAX_IPTUN_ENCAP_OPS];
>  ^~~
> 
> This hides the ip6_encap_hlen and ip6_tnl_encap functions inside
> of CONFIG_INET so we don't run into the the problem.
> 
> Alternatively we could move the macro out of the #ifdef again to
> restore the previous behavior
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: 55c2bc143224 ("net: Cleanup encap items in ip_tunnels.h")

Applied.


Re: [PATCH 2/2] fou: add Kconfig options for IPv6 support

2016-05-29 Thread David Miller
From: Arnd Bergmann 
Date: Wed, 25 May 2016 16:50:46 +0200

> A previous patch added the fou6.ko module, but that failed to link
> in a couple of configurations:
> 
> net/built-in.o: In function `ip6_tnl_encap_add_fou_ops':
> net/ipv6/fou6.c:88: undefined reference to `ip6_tnl_encap_add_ops'
> net/ipv6/fou6.c:94: undefined reference to `ip6_tnl_encap_add_ops'
> net/ipv6/fou6.c:97: undefined reference to `ip6_tnl_encap_del_ops'
> net/built-in.o: In function `ip6_tnl_encap_del_fou_ops':
> net/ipv6/fou6.c:106: undefined reference to `ip6_tnl_encap_del_ops'
> net/ipv6/fou6.c:107: undefined reference to `ip6_tnl_encap_del_ops'
> 
> If CONFIG_IPV6=m, ip6_tnl_encap_add_ops/ip6_tnl_encap_del_ops
> are in a module, but fou6.c can still be built-in, and that
> obviously fails to link.
> 
> Also, if CONFIG_IPV6=y, but CONFIG_IPV6_TUNNEL=m or
> CONFIG_IPV6_TUNNEL=n, the same problem happens for a different
> reason.
> 
> This adds two new silent Kconfig symbols to work around both
> problems:
> 
> - CONFIG_IPV6_FOU is now always set to 'm' if either CONFIG_NET_FOU=m
>   or CONFIG_IPV6=m
> - CONFIG_IPV6_FOU_TUNNEL is set implicitly when IPV6_FOU is enabled
>   and NET_FOU_IP_TUNNELS is also turned out, and it will ensure
>   that CONFIG_IPV6_TUNNEL is also available.
> 
> The options could be made user-visible as well, to give additional
> room for configuration, but it seems easier not to bother users
> with more choice here.
> 
> Signed-off-by: Arnd Bergmann 
> Fixes: aa3463d65e7b ("fou: Add encap ops for IPv6 tunnels")

Applied.


Re: [PATCH v2 05/10] nl80211: Fix checkpatch.pl NULL comparison warning

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:52 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the warning - "comparison to NULL (foo == NULL)
> could be written as (!foo)"
>
> Signed-off-by: Kirtika Ruchandani 

Looks right to me.

Reviewed-by: Julian Calaby 

Thanks,

Julian Calaby

> ---
>  net/wireless/nl80211.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index 945405d..11cbf0b 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -928,7 +928,7 @@ static struct ieee80211_channel 
> *nl80211_get_valid_chan(struct wiphy *wiphy,
>  {
> struct ieee80211_channel *chan;
>
> -   if (tb == NULL)
> +   if (!tb)
> return NULL;
> chan = ieee80211_get_channel(wiphy, nla_get_u32(tb));
> if (!chan || chan->flags & IEEE80211_CHAN_DISABLED)
> @@ -8575,7 +8575,7 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff 
> *skb,
> if (band < 0 || band >= NUM_NL80211_BANDS)
> return -EINVAL;
> sband = rdev->wiphy.bands[band];
> -   if (sband == NULL)
> +   if (!sband)
> return -EINVAL;
> err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
> nla_len(tx_rates), nl80211_txattr_policy);
> --
> 2.8.0.rc3.226.g39d4020
>



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH v2 04/10] nl80211: Fix checkpatch.pl warning about braces

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:52 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the following checkpatch,pl warning -
> - braces {} should be used on all arms of this statement.
>
> Signed-off-by: Kirtika Ruchandani 

Looks right to me.

Reviewed-by: Julian Calaby 

Thanks,

Julian Calaby


> ---
>  net/wireless/nl80211.c | 23 +++
>  1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index 34b8fbe..945405d 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -870,8 +870,9 @@ nl80211_parse_connkeys(struct cfg80211_registered_device 
> *rdev,
> result->def = parse.idx;
> if (!parse.def_uni || !parse.def_multi)
> goto error;
> -   } else if (parse.defmgmt)
> +   } else if (parse.defmgmt) {
> goto error;
> +   }
> err = cfg80211_validate_key_settings(rdev, ,
>  parse.idx, false, NULL);
> if (err)
> @@ -1401,8 +1402,9 @@ static int nl80211_send_wiphy(struct 
> cfg80211_registered_device *rdev,
> break;
> case 2:
> if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
> -   rdev->wiphy.interface_modes))
> -   goto nla_put_failure;
> +   rdev->wiphy.interface_modes)) {
> +   goto nla_put_failure;
> +   }
> state->split_start++;
> if (state->split)
> break;
> @@ -2155,8 +2157,9 @@ static int nl80211_set_wiphy(struct sk_buff *skb, 
> struct genl_info *info)
> wdev = NULL;
> netdev = NULL;
> result = 0;
> -   } else
> +   } else {
> wdev = netdev->ieee80211_ptr;
> +   }
>
> /* end workaround code, by now the rdev is available
>  * and locked, and wdev may or may not be NULL.
> @@ -3403,8 +3406,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
> genl_info *info)
> if (!nl80211_valid_auth_type(rdev, params.auth_type,
>  NL80211_CMD_START_AP))
> return -EINVAL;
> -   } else
> +   } else {
> params.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
> +   }
>
> err = nl80211_crypto_settings(rdev, info, ,
>   NL80211_MAX_NR_CIPHER_SUITES);
> @@ -3450,8 +3454,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
> genl_info *info)
> return err;
> } else if (wdev->preset_chandef.chan) {
> params.chandef = wdev->preset_chandef;
> -   } else if (!nl80211_get_ap_channel(rdev, ))
> +   } else if (!nl80211_get_ap_channel(rdev, )) {
> return -EINVAL;
> +   }
>
> if (!cfg80211_reg_can_beacon_relax(>wiphy, ,
>wdev->iftype))
> @@ -7262,8 +7267,9 @@ static int nl80211_crypto_settings(struct 
> cfg80211_registered_device *rdev,
> return -EINVAL;
> if (info->attrs[NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT])
> settings->control_port_no_encrypt = true;
> -   } else
> +   } else {
> settings->control_port_ethertype = cpu_to_be16(ETH_P_PAE);
> +   }
>
> if (info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]) {
> void *data;
> @@ -7997,8 +8003,9 @@ static int nl80211_connect(struct sk_buff *skb, struct 
> genl_info *info)
> if (!nl80211_valid_auth_type(rdev, connect.auth_type,
>  NL80211_CMD_CONNECT))
> return -EINVAL;
> -   } else
> +   } else {
> connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
> +   }
>
> connect.privacy = info->attrs[NL80211_ATTR_PRIVACY];
>
> --
> 2.8.0.rc3.226.g39d4020
>



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH v2 03/10] nl80211: Prefer ether_addr_copy

2016-05-29 Thread Julian Calaby
Hi All,

On Mon, May 30, 2016 at 12:52 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the checkpatch,pl to prefer ether_addr_copy
> over memcpy.
>
> Signed-off-by: Kirtika Ruchandani 

This looks right to me, but doesn't ether_addr_copy() have alignment
requirements? Could someone more familiar with that review these
changes to ensure they're met?

Thanks,

Julian Calaby

> ---
>  net/wireless/nl80211.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index cd422bd..34b8fbe 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -3194,7 +3194,7 @@ static struct cfg80211_acl_data *parse_acl_data(struct 
> wiphy *wiphy,
> return ERR_PTR(-ENOMEM);
>
> nla_for_each_nested(attr, info->attrs[NL80211_ATTR_MAC_ADDRS], tmp) {
> -   memcpy(acl->mac_addrs[i].addr, nla_data(attr), ETH_ALEN);
> +   ether_addr_copy(acl->mac_addrs[i].addr, nla_data(attr));
> i++;
> }
>
> @@ -5892,8 +5892,8 @@ static int nl80211_parse_random_mac(struct nlattr 
> **attrs,
> if (!attrs[NL80211_ATTR_MAC] || !attrs[NL80211_ATTR_MAC_MASK])
> return -EINVAL;
>
> -   memcpy(mac_addr, nla_data(attrs[NL80211_ATTR_MAC]), ETH_ALEN);
> -   memcpy(mac_addr_mask, nla_data(attrs[NL80211_ATTR_MAC_MASK]), 
> ETH_ALEN);
> +   ether_addr_copy(mac_addr, nla_data(attrs[NL80211_ATTR_MAC]));
> +   ether_addr_copy(mac_addr_mask, 
> nla_data(attrs[NL80211_ATTR_MAC_MASK]));
>
> /* don't allow or configure an mcast address */
> if (!is_multicast_ether_addr(mac_addr_mask) ||
> @@ -9405,8 +9405,7 @@ static int nl80211_parse_wowlan_tcp(struct 
> cfg80211_registered_device *rdev,
> return -ENOMEM;
> cfg->src = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_SRC_IPV4]);
> cfg->dst = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_DST_IPV4]);
> -   memcpy(cfg->dst_mac, nla_data(tb[NL80211_WOWLAN_TCP_DST_MAC]),
> -  ETH_ALEN);
> +   ether_addr_copy(cfg->dst_mac, 
> nla_data(tb[NL80211_WOWLAN_TCP_DST_MAC]));
> if (tb[NL80211_WOWLAN_TCP_SRC_PORT])
> port = nla_get_u16(tb[NL80211_WOWLAN_TCP_SRC_PORT]);
> else
> --
> 2.8.0.rc3.226.g39d4020
>



-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


[PATCH net v2] openvswitch: update checksum in {push,pop}_mpls

2016-05-29 Thread Simon Horman
In the case of CHECKSUM_COMPLETE the skb checksum should be updated in
{push,pop}_mpls() as they the type in the ethernet header.

As suggested by Pravin Shelar.

Cc: Pravin Shelar 
Fixes: 25cd9ba0abc0 ("openvswitch: Add basic MPLS support to kernel")
Signed-off-by: Simon Horman 
---
v2
* Use helper to reduce duplicated code.
---
 net/openvswitch/actions.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 879185fe183f..9a3eb7a0ebf4 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -137,11 +137,23 @@ static bool is_flow_key_valid(const struct sw_flow_key 
*key)
return !!key->eth.type;
 }
 
+static void update_ethertype(struct sk_buff *skb, struct ethhdr *hdr,
+__be16 ethertype)
+{
+   if (skb->ip_summed == CHECKSUM_COMPLETE) {
+   __be16 diff[] = { ~(hdr->h_proto), ethertype };
+
+   skb->csum = ~csum_partial((char *)diff, sizeof(diff),
+   ~skb->csum);
+   }
+
+   hdr->h_proto = ethertype;
+}
+
 static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
 const struct ovs_action_push_mpls *mpls)
 {
__be32 *new_mpls_lse;
-   struct ethhdr *hdr;
 
/* Networking stack do not allow simultaneous Tunnel and MPLS GSO. */
if (skb->encapsulation)
@@ -160,9 +172,7 @@ static int push_mpls(struct sk_buff *skb, struct 
sw_flow_key *key,
 
skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN);
 
-   hdr = eth_hdr(skb);
-   hdr->h_proto = mpls->mpls_ethertype;
-
+   update_ethertype(skb, eth_hdr(skb), mpls->mpls_ethertype);
if (!skb->inner_protocol)
skb_set_inner_protocol(skb, skb->protocol);
skb->protocol = mpls->mpls_ethertype;
@@ -193,7 +203,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key 
*key,
 * field correctly in the presence of VLAN tags.
 */
hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN);
-   hdr->h_proto = ethertype;
+   update_ethertype(skb, hdr, ethertype);
if (eth_p_mpls(skb->protocol))
skb->protocol = ethertype;
 
-- 
2.1.4



[PATCH V2 next] brcmfmac: don't remove interface on link down firmware event

2016-05-29 Thread Rafał Miłecki
There are two firmware events we handle similarly in brcmfmac:
BRCMF_E_LINK and BRCMF_E_IF. The difference from firmware point of view
is that the first one means BSS remains present in the firmware. Trying
to (re)create it (e.g. when adding new virtual interface) will result in
an error.

Current code treats both events in a similar way. It removes Linux
interface for each of them. It works OK with e.g. BCM43602. Its firmware
generates both events for each interface. It means we get BRCMF_E_LINK
and remove interface. That is soon followed by BRCMF_E_IF which means
BSS was also removed in a firmware. The only downside of this is a
harmless error like:
[  208.643180] brcmfmac: brcmf_fweh_call_event_handler: no interface object

Unfortunately BCM4366 firmware doesn't automatically remove BSS and so
it doesn't generate BRCMF_E_IF. In such case we incorrectly remove Linux
interface on BRCMF_E_LINK as BSS is still present in the firmware. It
results in an error when trying to re-create virtual interface, e.g.:
> iw phy phy1 interface add wlan1-1 type __ap
[ 3602.929199] brcmfmac: brcmf_ap_add_vif: timeout occurred
command failed: I/O error (-5)

With this patch we don't remove Linux interface while firmware keeps
BSS. Thanks to this we keep a consistent states of host driver and
device firmware.

Further improvement should be to mark BSS as disabled and remove
interface on BRCMF_E_LINK. Then we should add support for reusing
BSS-es.

Signed-off-by: Rafał Miłecki 
---
V2: Fix drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:5431:19: 
warning: unused variable ‘ifp’ [-Wunused-variable]
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 38df1be..d23b95e 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -5428,7 +5428,6 @@ brcmf_notify_connect_status_ap(struct brcmf_cfg80211_info 
*cfg,
   struct net_device *ndev,
   const struct brcmf_event_msg *e, void *data)
 {
-   struct brcmf_if *ifp = netdev_priv(ndev);
static int generation;
u32 event = e->event_code;
u32 reason = e->reason;
@@ -5439,8 +5438,6 @@ brcmf_notify_connect_status_ap(struct brcmf_cfg80211_info 
*cfg,
ndev != cfg_to_ndev(cfg)) {
brcmf_dbg(CONN, "AP mode link down\n");
complete(>vif_disabled);
-   if (ifp->vif->mbss)
-   brcmf_remove_interface(ifp);
return 0;
}
 
-- 
1.8.4.5



[PATCH v2 08/10] nl80211: Fix spelling

2016-05-29 Thread Kirtika Ruchandani
Fix 'implementation' spelling, reported by checkpatch.pl

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6f8e2a7..c6d870e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -6492,7 +6492,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct 
wireless_dev *wdev,
   nla_data(ssid), nla_len(ssid));
request->match_sets[i].ssid.ssid_len =
nla_len(ssid);
-   /* special attribute - old implemenation w/a */
+   /* special attribute - old implementation w/a */
request->match_sets[i].rssi_thold =
default_match_rssi;
rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
--
2.8.0.rc3.226.g39d4020



[PATCH v2 10/10] nl80211: Prefer kcalloc over kzalloc

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch.pl warning -
"prefer kcalloc over kzalloc with multiply"

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 46757af..2964406 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9482,7 +9482,7 @@ static int nl80211_parse_wowlan_nd(struct 
cfg80211_registered_device *rdev,
struct nlattr **tb;
int err;

-   tb = kzalloc(NUM_NL80211_ATTR * sizeof(*tb), GFP_KERNEL);
+   tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL);
if (!tb)
return -ENOMEM;

--
2.8.0.rc3.226.g39d4020



[PATCH v2 09/10] nl80211: Fix checkpatch.pl warning

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch.pl warning "foo * bar should be
foo *bar"

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c6d870e..46757af 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -12214,7 +12214,7 @@ void nl80211_send_ibss_bssid(struct 
cfg80211_registered_device *rdev,
 }

 void cfg80211_notify_new_peer_candidate(struct net_device *dev, const u8 *addr,
-   const u8* ie, u8 ie_len, gfp_t gfp)
+   const u8 *ie, u8 ie_len, gfp_t gfp)
 {
struct wireless_dev *wdev = dev->ieee80211_ptr;
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
@@ -13362,7 +13362,7 @@ void cfg80211_tdls_oper_request(struct net_device *dev, 
const u8 *peer,
 }
 EXPORT_SYMBOL(cfg80211_tdls_oper_request);

-static int nl80211_netlink_notify(struct notifier_block * nb,
+static int nl80211_netlink_notify(struct notifier_block *nb,
  unsigned long state,
  void *_notify)
 {
--
2.8.0.rc3.226.g39d4020



[PATCH v2 07/10] nl80211: Avoid multiple assignments on same line

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch.pl warning "multiple assignments
should be avoided."

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ad7cdce..6f8e2a7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2603,7 +2603,8 @@ static int nl80211_set_interface(struct sk_buff *skb, 
struct genl_info *info)

memset(, 0, sizeof(params));

-   otype = ntype = dev->ieee80211_ptr->iftype;
+   otype = dev->ieee80211_ptr->iftype;
+   ntype = dev->ieee80211_ptr->iftype;

if (info->attrs[NL80211_ATTR_IFTYPE]) {
ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
--
2.8.0.rc3.226.g39d4020



[PATCH v2 06/10] nl80211: Various checkpatch.pl spacing fixes

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following spacing issues reported
by checkpatch.pl -
- space preferred around that 
- no space needed after cast.
- Alignment should match open parenthesis
- suspect code indent for conditional statements
- Statements should start on a tabstop

This patch also contains two hunks to fix 'line over 80 characters',
that are spacing related.
All other instances of that warning have been ignored.

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 103 ++---
 1 file changed, 54 insertions(+), 49 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 11cbf0b..ad7cdce 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -39,10 +39,10 @@ static void nl80211_post_doit(const struct genl_ops *ops, 
struct sk_buff *skb,

 /* the netlink family */
 static struct genl_family nl80211_fam = {
-   .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
-   .name = NL80211_GENL_NAME,  /* have users key off the name instead 
*/
-   .hdrsize = 0,   /* no private header */
-   .version = 1,   /* no particular meaning now */
+   .id = GENL_ID_GENERATE, /* don't bother with a hardcoded ID */
+   .name = NL80211_GENL_NAME,  /* have users key off the name instead */
+   .hdrsize = 0,   /* no private header */
+   .version = 1,   /* no particular meaning now */
.maxattr = NL80211_ATTR_MAX,
.netnsok = true,
.pre_doit = nl80211_pre_doit,
@@ -213,7 +213,7 @@ cfg80211_get_dev_from_info(struct net *netns, struct 
genl_info *info)
 static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[NL80211_ATTR_WIPHY] = { .type = NLA_U32 },
[NL80211_ATTR_WIPHY_NAME] = { .type = NLA_NUL_STRING,
- .len = 20-1 },
+ .len = 20 - 1 },
[NL80211_ATTR_WIPHY_TXQ_PARAMS] = { .type = NLA_NESTED },

[NL80211_ATTR_WIPHY_FREQ] = { .type = NLA_U32 },
@@ -231,7 +231,7 @@ static const struct nla_policy 
nl80211_policy[NUM_NL80211_ATTR] = {

[NL80211_ATTR_IFTYPE] = { .type = NLA_U32 },
[NL80211_ATTR_IFINDEX] = { .type = NLA_U32 },
-   [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ-1 },
+   [NL80211_ATTR_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 },

[NL80211_ATTR_MAC] = { .len = ETH_ALEN },
[NL80211_ATTR_PREV_BSSID] = { .len = ETH_ALEN },
@@ -967,7 +967,7 @@ static int nl80211_put_iface_combinations(struct wiphy 
*wiphy,
int i, j;

nl_combis = nla_nest_start(msg,
-   NL80211_ATTR_INTERFACE_COMBINATIONS);
+  NL80211_ATTR_INTERFACE_COMBINATIONS);
if (!nl_combis)
goto nla_put_failure;

@@ -1012,9 +1012,9 @@ static int nl80211_put_iface_combinations(struct wiphy 
*wiphy,
goto nla_put_failure;
if (large &&
(nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
-   c->radar_detect_widths) ||
+c->radar_detect_widths) ||
 nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
-   c->radar_detect_regions)))
+c->radar_detect_regions)))
goto nla_put_failure;

nla_nest_end(msg, nl_combi);
@@ -1493,7 +1493,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,

i = 0;
 #define CMD(op, n) \
-do {   \
+   do {\
if (rdev->ops->op) {\
i++;\
if (nla_put_u32(msg, i, NL80211_CMD_ ## n)) \
@@ -1735,8 +1735,9 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
   rdev->wiphy.max_num_csa_counters))
goto nla_put_failure;

-   if (rdev->wiphy.regulatory_flags & 
REGULATORY_WIPHY_SELF_MANAGED &&
-   nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
+   if ((rdev->wiphy.regulatory_flags &
+REGULATORY_WIPHY_SELF_MANAGED) &&
+nla_put_flag(msg, NL80211_ATTR_WIPHY_SELF_MANAGED_REG))
goto nla_put_failure;

if (nla_put(msg, NL80211_ATTR_EXT_FEATURES,
@@ -2299,7 +2300,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
if (frag_threshold < 256)
return -EINVAL;

- 

[PATCH v2 05/10] nl80211: Fix checkpatch.pl NULL comparison warning

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the warning - "comparison to NULL (foo == NULL)
could be written as (!foo)"

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 945405d..11cbf0b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -928,7 +928,7 @@ static struct ieee80211_channel 
*nl80211_get_valid_chan(struct wiphy *wiphy,
 {
struct ieee80211_channel *chan;

-   if (tb == NULL)
+   if (!tb)
return NULL;
chan = ieee80211_get_channel(wiphy, nla_get_u32(tb));
if (!chan || chan->flags & IEEE80211_CHAN_DISABLED)
@@ -8575,7 +8575,7 @@ static int nl80211_set_tx_bitrate_mask(struct sk_buff 
*skb,
if (band < 0 || band >= NUM_NL80211_BANDS)
return -EINVAL;
sband = rdev->wiphy.bands[band];
-   if (sband == NULL)
+   if (!sband)
return -EINVAL;
err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
nla_len(tx_rates), nl80211_txattr_policy);
--
2.8.0.rc3.226.g39d4020



[PATCH v2 03/10] nl80211: Prefer ether_addr_copy

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the checkpatch,pl to prefer ether_addr_copy
over memcpy.

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cd422bd..34b8fbe 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3194,7 +3194,7 @@ static struct cfg80211_acl_data *parse_acl_data(struct 
wiphy *wiphy,
return ERR_PTR(-ENOMEM);

nla_for_each_nested(attr, info->attrs[NL80211_ATTR_MAC_ADDRS], tmp) {
-   memcpy(acl->mac_addrs[i].addr, nla_data(attr), ETH_ALEN);
+   ether_addr_copy(acl->mac_addrs[i].addr, nla_data(attr));
i++;
}

@@ -5892,8 +5892,8 @@ static int nl80211_parse_random_mac(struct nlattr **attrs,
if (!attrs[NL80211_ATTR_MAC] || !attrs[NL80211_ATTR_MAC_MASK])
return -EINVAL;

-   memcpy(mac_addr, nla_data(attrs[NL80211_ATTR_MAC]), ETH_ALEN);
-   memcpy(mac_addr_mask, nla_data(attrs[NL80211_ATTR_MAC_MASK]), ETH_ALEN);
+   ether_addr_copy(mac_addr, nla_data(attrs[NL80211_ATTR_MAC]));
+   ether_addr_copy(mac_addr_mask, nla_data(attrs[NL80211_ATTR_MAC_MASK]));

/* don't allow or configure an mcast address */
if (!is_multicast_ether_addr(mac_addr_mask) ||
@@ -9405,8 +9405,7 @@ static int nl80211_parse_wowlan_tcp(struct 
cfg80211_registered_device *rdev,
return -ENOMEM;
cfg->src = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_SRC_IPV4]);
cfg->dst = nla_get_in_addr(tb[NL80211_WOWLAN_TCP_DST_IPV4]);
-   memcpy(cfg->dst_mac, nla_data(tb[NL80211_WOWLAN_TCP_DST_MAC]),
-  ETH_ALEN);
+   ether_addr_copy(cfg->dst_mac, nla_data(tb[NL80211_WOWLAN_TCP_DST_MAC]));
if (tb[NL80211_WOWLAN_TCP_SRC_PORT])
port = nla_get_u16(tb[NL80211_WOWLAN_TCP_SRC_PORT]);
else
--
2.8.0.rc3.226.g39d4020



[PATCH v2 04/10] nl80211: Fix checkpatch.pl warning about braces

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following checkpatch,pl warning -
- braces {} should be used on all arms of this statement.

Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 34b8fbe..945405d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -870,8 +870,9 @@ nl80211_parse_connkeys(struct cfg80211_registered_device 
*rdev,
result->def = parse.idx;
if (!parse.def_uni || !parse.def_multi)
goto error;
-   } else if (parse.defmgmt)
+   } else if (parse.defmgmt) {
goto error;
+   }
err = cfg80211_validate_key_settings(rdev, ,
 parse.idx, false, NULL);
if (err)
@@ -1401,8 +1402,9 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
break;
case 2:
if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
-   rdev->wiphy.interface_modes))
-   goto nla_put_failure;
+   rdev->wiphy.interface_modes)) {
+   goto nla_put_failure;
+   }
state->split_start++;
if (state->split)
break;
@@ -2155,8 +2157,9 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
wdev = NULL;
netdev = NULL;
result = 0;
-   } else
+   } else {
wdev = netdev->ieee80211_ptr;
+   }

/* end workaround code, by now the rdev is available
 * and locked, and wdev may or may not be NULL.
@@ -3403,8 +3406,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
genl_info *info)
if (!nl80211_valid_auth_type(rdev, params.auth_type,
 NL80211_CMD_START_AP))
return -EINVAL;
-   } else
+   } else {
params.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
+   }

err = nl80211_crypto_settings(rdev, info, ,
  NL80211_MAX_NR_CIPHER_SUITES);
@@ -3450,8 +3454,9 @@ static int nl80211_start_ap(struct sk_buff *skb, struct 
genl_info *info)
return err;
} else if (wdev->preset_chandef.chan) {
params.chandef = wdev->preset_chandef;
-   } else if (!nl80211_get_ap_channel(rdev, ))
+   } else if (!nl80211_get_ap_channel(rdev, )) {
return -EINVAL;
+   }

if (!cfg80211_reg_can_beacon_relax(>wiphy, ,
   wdev->iftype))
@@ -7262,8 +7267,9 @@ static int nl80211_crypto_settings(struct 
cfg80211_registered_device *rdev,
return -EINVAL;
if (info->attrs[NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT])
settings->control_port_no_encrypt = true;
-   } else
+   } else {
settings->control_port_ethertype = cpu_to_be16(ETH_P_PAE);
+   }

if (info->attrs[NL80211_ATTR_CIPHER_SUITES_PAIRWISE]) {
void *data;
@@ -7997,8 +8003,9 @@ static int nl80211_connect(struct sk_buff *skb, struct 
genl_info *info)
if (!nl80211_valid_auth_type(rdev, connect.auth_type,
 NL80211_CMD_CONNECT))
return -EINVAL;
-   } else
+   } else {
connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
+   }

connect.privacy = info->attrs[NL80211_ATTR_PRIVACY];

--
2.8.0.rc3.226.g39d4020



[PATCH v2 02/10] nl80211: Fix checkpatch warnings about blank lines

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following checkpatch.pl issues -
- Please don't use multiple blank lines
- Blank lines aren't necessary before a close brace
- Missing a blank line after declarations

Reviewed-by: Julian Calaby 
Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 50a0de0..cd422bd 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -167,6 +167,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)

if (attrs[NL80211_ATTR_IFINDEX]) {
int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
+
netdev = __dev_get_by_index(netns, ifindex);
if (netdev) {
if (netdev->ieee80211_ptr)
@@ -730,6 +731,7 @@ static int nl80211_parse_key_new(struct nlattr *key, struct 
key_parse *k)

if (tb[NL80211_KEY_DEFAULT_TYPES]) {
struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
+
err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
   tb[NL80211_KEY_DEFAULT_TYPES],
   nl80211_key_default_policy);
@@ -1381,6 +1383,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
rdev->ops->get_antenna) {
u32 tx_ant = 0, rx_ant = 0;
int res;
+
res = rdev_get_antenna(rdev, _ant, _ant);
if (!res) {
if (nla_put_u32(msg,
@@ -2111,7 +2114,6 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, 
struct genl_info *info)
return rdev_set_wds_peer(rdev, dev, bssid);
 }

-
 static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
 {
struct cfg80211_registered_device *rdev;
@@ -2244,6 +2246,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
u32 tx_ant, rx_ant;
+
if ((!rdev->wiphy.available_antennas_tx &&
 !rdev->wiphy.available_antennas_rx) ||
!rdev->ops->set_antenna)
@@ -2910,6 +2913,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct 
genl_info *info)
pairwise = !!mac_addr;
if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
+
if (kt >= NUM_NL80211_KEYTYPES)
return -EINVAL;
if (kt != NL80211_KEYTYPE_GROUP &&
@@ -3949,7 +3953,6 @@ static int nl80211_dump_station(struct sk_buff *skb,
sta_idx++;
}

-
  out:
cb->args[2] = sta_idx;
err = skb->len;
@@ -4742,7 +4745,6 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
path_idx++;
}

-
  out:
cb->args[2] = path_idx;
err = skb->len;
@@ -5032,7 +5034,6 @@ static int nl80211_req_set_reg(struct sk_buff *skb, 
struct genl_info *info)
enum nl80211_user_reg_hint_type user_reg_hint_type;
u32 owner_nlportid;

-
/* You should only get this when cfg80211 hasn't yet initialized
 * completely when built-in to the kernel right between the time
 * window between nl80211_init() and regulatory_init(), if that is
@@ -5240,7 +5241,6 @@ do {  
\
}   \
 } while (0)

-
if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
return -EINVAL;
if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
@@ -5388,7 +5388,6 @@ static int nl80211_parse_mesh_setup(struct genl_info 
*info,
 IEEE80211_PATH_METRIC_VENDOR :
 IEEE80211_PATH_METRIC_AIRTIME;

-
if (tb[NL80211_MESH_SETUP_IE]) {
struct nlattr *ieattr =
tb[NL80211_MESH_SETUP_IE];
@@ -6009,6 +6008,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, 
struct genl_info *info)
/* all channels */
for (band = 0; band < NUM_NL80211_BANDS; band++) {
int j;
+
if (!wiphy->bands[band])
continue;
for (j = 0; j < wiphy->bands[band]->n_channels; j++) {
@@ -6412,6 +6412,7 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct 
wireless_dev *wdev,
/* all channels */
for (band = 0; band < NUM_NL80211_BANDS; band++) {
int j;
+
if (!wiphy->bands[band])
continue;
for (j = 0; j 

[PATCH v2 01/10] nl80211: Fix checkpatch warnings

2016-05-29 Thread Kirtika Ruchandani
This patch fixes the following checkpatch.pl warnings about
comments in nl80211.c :
- networking block comments don't use an empty '/*' line
- block comments use a trailing '*/' on a separate line

Reviewed-by: Julian Calaby 
Signed-off-by: Kirtika Ruchandani 
---
 net/wireless/nl80211.c | 129 +
 1 file changed, 45 insertions(+), 84 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d759901..50a0de0 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -196,8 +196,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct nlattr 
**attrs)
return rdev;
 }

-/*
- * This function returns a pointer to the driver
+/* This function returns a pointer to the driver
  * that the genl_info item that is passed refers to.
  *
  * The result of this can be a PTR_ERR and hence must
@@ -1624,8 +1623,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
goto nla_put_failure;

features = rdev->wiphy.features;
-   /*
-* We can only add the per-channel limit information if the
+   /* We can only add the per-channel limit information if the
 * dump is split, otherwise it makes it too big. Therefore
 * only advertise it in that case.
 */
@@ -1646,8 +1644,7 @@ static int nl80211_send_wiphy(struct 
cfg80211_registered_device *rdev,
rdev->wiphy.max_acl_mac_addrs))
goto nla_put_failure;

-   /*
-* Any information below this point is only available to
+   /* Any information below this point is only available to
 * applications that can deal with it being split. This
 * helps ensure that newly added capabilities don't break
 * older tools by overrunning their buffers.
@@ -1847,8 +1844,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct 
netlink_callback *cb)
 cb->nlh->nlmsg_seq,
 NLM_F_MULTI, state);
if (ret < 0) {
-   /*
-* If sending the wiphy data didn't fit (ENOBUFS
+   /* If sending the wiphy data didn't fit (ENOBUFS
 * or EMSGSIZE returned), this SKB is still
 * empty (so it's not too big because another
 * wiphy dataset is already in the skb) and
@@ -1937,8 +1933,7 @@ static int parse_txq_params(struct nlattr *tb[],

 static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev)
 {
-   /*
-* You can only set the channel explicitly for WDS interfaces,
+   /* You can only set the channel explicitly for WDS interfaces,
 * all others have their channel managed via their respective
 * "establish a connection" command (connect, join, ...)
 *
@@ -2131,8 +2126,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)

ASSERT_RTNL();

-   /*
-* Try to find the wiphy and netdev. Normally this
+   /* Try to find the wiphy and netdev. Normally this
 * function shouldn't need the netdev, but this is
 * done for backward compatibility -- previously
 * setting the channel was done per wiphy, but now
@@ -2162,8 +2156,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
} else
wdev = netdev->ieee80211_ptr;

-   /*
-* end workaround code, by now the rdev is available
+   /* end workaround code, by now the rdev is available
 * and locked, and wdev may or may not be NULL.
 */

@@ -2260,7 +2253,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
rx_ant = 
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);

/* reject antenna configurations which don't match the
-* available antenna masks, except for the "all" mask */
+* available antenna masks, except for the "all" mask
+*/
if ((~tx_ant && (tx_ant & ~rdev->wiphy.available_antennas_tx)) 
||
(~rx_ant && (rx_ant & ~rdev->wiphy.available_antennas_rx)))
return -EINVAL;
@@ -2300,8 +2294,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, struct 
genl_info *info)
return -EINVAL;

if (frag_threshold != (u32) -1) {
-   /*
-* Fragments (apart from the last one) are required to
+   /* Fragments (apart from the last one) are required to
 * have even length. Make the 

[PATCH v2 00/10] nl80211: Fix checkpatch.pl issues

2016-05-29 Thread Kirtika Ruchandani
This patch-set attempts to fix checkpatch.pl issues found in nl80211.c.
Each patch describes the specific warnings/checks/errors it addresses.
This patch-set ignores 'line over 80 chars' warnings, except for 2 cases.
Please check for issues with the 'fixes' for 'alignment should match
open parenthesis'. Some of them do not display correctly with git diff.
This patch-set removes 3 errors, 66 warnings and 46 checks.

Kirtika Ruchandani (10):
  nl80211: Fix checkpatch warnings
  nl80211: Fix checkpatch warnings about blank lines
  nl80211: Prefer ether_addr_copy
  nl80211: Fix checkpatch.pl warning about braces
  nl80211: Fix checkpatch.pl NULL comparison warning
  nl80211: Various checkpatch.pl spacing fixes
  nl80211: Avoid multiple assignments on same line
  nl80211: Fix spelling
  nl80211: Fix checkpatch.pl warning
  nl80211: Prefer kcalloc over kzalloc

Changes in v2:
- Break down patch into smaller independent patches as suggested by Julian 
  Calaby.This breaks down patch 3/3 in set v1 into patches 3-10 of v2.

 net/wireless/nl80211.c | 301 ++---
 1 file changed, 136 insertions(+), 165 deletions(-)

-- 
2.8.0.rc3.226.g39d4020



[patch v2 net-next 12/13] net: hns: implement the miscellaneous operation by asl

2016-05-29 Thread Kejian Yan
The miscellaneous operation is implemented in BIOS, the kernel can call
_DSM method help to call the implementation in ACPI case. Here is a patch
to do that.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2: use a serial function to implement the reset sequence

 v1: first submit
  link: https://lkml.org/lkml/2016/5/13/94
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 167 +
 1 file changed, 167 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
index f21177b..96cb628 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
@@ -12,6 +12,27 @@
 #include "hns_dsaf_ppe.h"
 #include "hns_dsaf_reg.h"
 
+enum _dsm_op_index {
+   HNS_OP_RESET_FUNC   = 0x1,
+   HNS_OP_SERDES_LP_FUNC   = 0x2,
+   HNS_OP_LED_SET_FUNC = 0x3,
+   HNS_OP_GET_PORT_TYPE_FUNC   = 0x4,
+   HNS_OP_GET_SFP_STAT_FUNC= 0x5,
+};
+
+enum _dsm_rst_type {
+   HNS_DSAF_RESET_FUNC = 0x1,
+   HNS_PPE_RESET_FUNC  = 0x2,
+   HNS_XGE_CORE_RESET_FUNC = 0x3,
+   HNS_XGE_RESET_FUNC  = 0x4,
+   HNS_GE_RESET_FUNC   = 0x5,
+};
+
+const u8 hns_dsaf_acpi_dsm_uuid[] = {
+   0x1A, 0xAA, 0x85, 0x1A, 0x93, 0xE2, 0x5E, 0x41,
+   0x8E, 0x28, 0x8D, 0x69, 0x0A, 0x0F, 0x82, 0x0A
+};
+
 static void dsaf_write_sub(struct dsaf_device *dsaf_dev, u32 reg, u32 val)
 {
if (dsaf_dev->sub_ctrl)
@@ -109,6 +130,34 @@ static int cpld_set_led_id(struct hns_mac_cb *mac_cb,
 
 #define RESET_REQ_OR_DREQ 1
 
+static void hns_dsaf_acpi_srst_by_port(struct dsaf_device *dsaf_dev, u8 
op_type,
+  u32 port_type, u32 port, u32 val)
+{
+   union acpi_object *obj;
+   union acpi_object obj_args[3], argv4;
+
+   obj_args[0].integer.type = ACPI_TYPE_INTEGER;
+   obj_args[0].integer.value = port_type;
+   obj_args[1].integer.type = ACPI_TYPE_INTEGER;
+   obj_args[1].integer.value = port;
+   obj_args[2].integer.type = ACPI_TYPE_INTEGER;
+   obj_args[2].integer.value = val;
+
+   argv4.type = ACPI_TYPE_PACKAGE;
+   argv4.package.count = 3;
+   argv4.package.elements = obj_args;
+
+   obj = acpi_evaluate_dsm(ACPI_HANDLE(dsaf_dev->dev),
+   hns_dsaf_acpi_dsm_uuid, 0, op_type, );
+   if (!obj) {
+   dev_warn(dsaf_dev->dev, "reset port_type%d port%d fail!",
+port_type, port);
+   return;
+   }
+
+   ACPI_FREE(obj);
+}
+
 static void hns_dsaf_rst(struct dsaf_device *dsaf_dev, bool dereset)
 {
u32 xbar_reg_addr;
@@ -126,6 +175,13 @@ static void hns_dsaf_rst(struct dsaf_device *dsaf_dev, 
bool dereset)
dsaf_write_sub(dsaf_dev, nt_reg_addr, RESET_REQ_OR_DREQ);
 }
 
+static void hns_dsaf_rst_acpi(struct dsaf_device *dsaf_dev, bool dereset)
+{
+   hns_dsaf_acpi_srst_by_port(dsaf_dev, HNS_OP_RESET_FUNC,
+  HNS_DSAF_RESET_FUNC,
+  0, dereset);
+}
+
 static void hns_dsaf_xge_srst_by_port(struct dsaf_device *dsaf_dev, u32 port,
  bool dereset)
 {
@@ -146,6 +202,13 @@ static void hns_dsaf_xge_srst_by_port(struct dsaf_device 
*dsaf_dev, u32 port,
dsaf_write_sub(dsaf_dev, reg_addr, reg_val);
 }
 
+static void hns_dsaf_xge_srst_by_port_acpi(struct dsaf_device *dsaf_dev,
+  u32 port, bool dereset)
+{
+   hns_dsaf_acpi_srst_by_port(dsaf_dev, HNS_OP_RESET_FUNC,
+  HNS_XGE_RESET_FUNC, port, dereset);
+}
+
 static void hns_dsaf_xge_core_srst_by_port(struct dsaf_device *dsaf_dev,
   u32 port, bool dereset)
 {
@@ -166,6 +229,14 @@ static void hns_dsaf_xge_core_srst_by_port(struct 
dsaf_device *dsaf_dev,
dsaf_write_sub(dsaf_dev, reg_addr, reg_val);
 }
 
+static void
+hns_dsaf_xge_core_srst_by_port_acpi(struct dsaf_device *dsaf_dev,
+   u32 port, bool dereset)
+{
+   hns_dsaf_acpi_srst_by_port(dsaf_dev, HNS_OP_RESET_FUNC,
+  HNS_XGE_CORE_RESET_FUNC, port, dereset);
+}
+
 static void hns_dsaf_ge_srst_by_port(struct dsaf_device *dsaf_dev, u32 port,
 bool dereset)
 {
@@ -218,6 +289,13 @@ static void hns_dsaf_ge_srst_by_port(struct dsaf_device 
*dsaf_dev, u32 port,
}
 }
 
+static void hns_dsaf_ge_srst_by_port_acpi(struct dsaf_device *dsaf_dev,
+ u32 port, bool dereset)
+{
+   hns_dsaf_acpi_srst_by_port(dsaf_dev, HNS_OP_RESET_FUNC,
+  HNS_GE_RESET_FUNC, port, dereset);
+}
+
 static void hns_ppe_srst_by_port(struct dsaf_device *dsaf_dev, u32 port,
   

[patch v2 net-next 04/13] net: hisilicon: add support of acpi for hns-mdio

2016-05-29 Thread Kejian Yan
hns-mdio needs to register itself to mii-bus. The info of the device can
be read by both DT and ACPI.
HNS tries to call Linux PHY driver to help access PHY-devices, the HNS
hardware topology is as below. The MDIO controller may control several
PHY-devices, and each PHY-device connects to a MAC device. The MDIO will
be registered to mdiobus, then PHY-devices will register when each mac
find PHY device.
   cpu
|
|
 ---
|   |   |
|   |   |
|  dsaf |
   MDIO |  MDIO
|  ---  |
| | | |   | |
| | | |   | |
|MAC   MAC   MAC MAC|
| | | |   | |
  | | |   | 
 ||||||   ||
 PHY   PHY   PHY PHY

And the driver can handle reset sequence by _RST method in DSDT in ACPI
case.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2:
1. use dev_of_node instead of IS_ENABLED macro
2. Add ACPI bits
 v1: first submit
Link: https://lkml.org/lkml/2016/5/13/93
---
 drivers/net/ethernet/hisilicon/hns_mdio.c | 107 +++---
 1 file changed, 69 insertions(+), 38 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c 
b/drivers/net/ethernet/hisilicon/hns_mdio.c
index 381cf0a..f78286c 100644
--- a/drivers/net/ethernet/hisilicon/hns_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns_mdio.c
@@ -7,6 +7,7 @@
  * (at your option) any later version.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -354,48 +355,60 @@ static int hns_mdio_reset(struct mii_bus *bus)
struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv;
int ret;
 
-   if (!dev_of_node(bus->parent))
-   return -ENOTSUPP;
+   if (dev_of_node(bus->parent)) {
+   if (!mdio_dev->subctrl_vbase) {
+   dev_err(>dev, "mdio sys ctl reg has not maped\n");
+   return -ENODEV;
+   }
 
-   if (!mdio_dev->subctrl_vbase) {
-   dev_err(>dev, "mdio sys ctl reg has not maped\n");
-   return -ENODEV;
-   }
+   /* 1. reset req, and read reset st check */
+   ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_RESET_REQ, 0x1,
+   MDIO_SC_RESET_ST, 0x1,
+   MDIO_CHECK_SET_ST);
+   if (ret) {
+   dev_err(>dev, "MDIO reset fail\n");
+   return ret;
+   }
 
-   /*1. reset req, and read reset st check*/
-   ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_RESET_REQ, 0x1,
-   MDIO_SC_RESET_ST, 0x1,
-   MDIO_CHECK_SET_ST);
-   if (ret) {
-   dev_err(>dev, "MDIO reset fail\n");
-   return ret;
-   }
+   /* 2. dis clk, and read clk st check */
+   ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_CLK_DIS,
+   0x1, MDIO_SC_CLK_ST, 0x1,
+   MDIO_CHECK_CLR_ST);
+   if (ret) {
+   dev_err(>dev, "MDIO dis clk fail\n");
+   return ret;
+   }
 
-   /*2. dis clk, and read clk st check*/
-   ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_CLK_DIS,
-   0x1, MDIO_SC_CLK_ST, 0x1,
-   MDIO_CHECK_CLR_ST);
-   if (ret) {
-   dev_err(>dev, "MDIO dis clk fail\n");
-   return ret;
-   }
+   /* 3. reset dreq, and read reset st check */
+   ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_RESET_DREQ, 0x1,
+   MDIO_SC_RESET_ST, 0x1,
+   MDIO_CHECK_CLR_ST);
+   if (ret) {
+   dev_err(>dev, "MDIO dis clk fail\n");
+   return ret;
+   }
 
-   /*3. reset dreq, and read reset st check*/
-   ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_RESET_DREQ, 0x1,
-   MDIO_SC_RESET_ST, 0x1,
-   MDIO_CHECK_CLR_ST);
-   if (ret) {
-   dev_err(>dev, "MDIO dis clk fail\n");
-   return ret;
+   /* 4. en clk, and read clk st check */
+   ret = mdio_sc_cfg_reg_write(mdio_dev, MDIO_SC_CLK_EN,
+   0x1, MDIO_SC_CLK_ST, 0x1,
+

[patch v2 net-next 02/13] ACPI: bus: add stub acpi_evaluate_dsm() to linux/acpi.h

2016-05-29 Thread Kejian Yan
acpi_evaluate_dsm() will be used to handle the _DSM method in ACPI case.
It will be compiled in non-ACPI case, but the function is in acpi_bus.h
and acpi_bus.h can only be used in ACPI case, so this patch add the stub
function to linux/acpi.h to make compiled successfully in non-ACPI cases.

Cc: Rafael J. Wysocki 
Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
 include/linux/acpi.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 3025d19..4d4bb49 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -659,6 +659,14 @@ static inline bool acpi_driver_match_device(struct device 
*dev,
return false;
 }
 
+static inline union acpi_object *acpi_evaluate_dsm(acpi_handle handle,
+  const u8 *uuid,
+  int rev, int func,
+  union acpi_object *argv4)
+{
+   return NULL;
+}
+
 static inline int acpi_device_uevent_modalias(struct device *dev,
struct kobj_uevent_env *env)
 {
-- 
1.9.1



[patch v2 net-next 09/13] net: hns: add dsaf misc operation method

2016-05-29 Thread Kejian Yan
The misc operation for different hw platform may be different, if using
current implementation, it will add a new branch on each function for
every new hw platform, so we add a method for this operation.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c  |  4 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c |  6 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 14 ++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h  |  2 -
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 11 ++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h | 33 ++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 79 +++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.h |  7 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c  | 15 ++--
 .../net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c| 10 +--
 10 files changed, 111 insertions(+), 70 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c 
b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 8e009f4..d37b778 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -637,13 +637,15 @@ static int hns_ae_config_loopback(struct hnae_handle 
*handle,
int ret;
struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);
struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);
+   struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev;
 
switch (loop) {
case MAC_INTERNALLOOP_PHY:
ret = 0;
break;
case MAC_INTERNALLOOP_SERDES:
-   ret = hns_mac_config_sds_loopback(vf_cb->mac_cb, en);
+   ret = dsaf_dev->misc_op->cfg_serdes_loopback(vf_cb->mac_cb,
+!!en);
break;
case MAC_INTERNALLOOP_MAC:
ret = hns_mac_config_mac_loopback(vf_cb->mac_cb, loop, en);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
index 44abb08..1235c7f 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c
@@ -110,7 +110,7 @@ static void hns_gmac_free(void *mac_drv)
 
u32 mac_id = drv->mac_id;
 
-   hns_dsaf_ge_srst_by_port(dsaf_dev, mac_id, 0);
+   dsaf_dev->misc_op->ge_srst(dsaf_dev, mac_id, 0);
 }
 
 static void hns_gmac_set_tx_auto_pause_frames(void *mac_drv, u16 newval)
@@ -317,9 +317,9 @@ static void hns_gmac_init(void *mac_drv)
 
port = drv->mac_id;
 
-   hns_dsaf_ge_srst_by_port(dsaf_dev, port, 0);
+   dsaf_dev->misc_op->ge_srst(dsaf_dev, port, 0);
mdelay(10);
-   hns_dsaf_ge_srst_by_port(dsaf_dev, port, 1);
+   dsaf_dev->misc_op->ge_srst(dsaf_dev, port, 1);
mdelay(10);
hns_gmac_disable(mac_drv, MAC_COMM_MODE_RX_AND_TX);
hns_gmac_tx_loop_pkt_dis(mac_drv);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 527b49d..2ebf14a 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -95,7 +95,7 @@ void hns_mac_get_link_status(struct hns_mac_cb *mac_cb, u32 
*link_status)
else
*link_status = 0;
 
-   ret = hns_mac_get_sfp_prsnt(mac_cb, _prsnt);
+   ret = mac_cb->dsaf_dev->misc_op->get_sfp_prsnt(mac_cb, _prsnt);
if (!ret)
*link_status = *link_status && sfp_prsnt;
 
@@ -512,7 +512,7 @@ void hns_mac_stop(struct hns_mac_cb *mac_cb)
 
mac_ctrl_drv->mac_en_flg = 0;
mac_cb->link = 0;
-   cpld_led_reset(mac_cb);
+   mac_cb->dsaf_dev->misc_op->cpld_reset_led(mac_cb);
 }
 
 /**
@@ -804,7 +804,7 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, struct 
hns_mac_cb *mac_cb)
else
mac_cb->mac_type = HNAE_PORT_DEBUG;
 
-   mac_cb->phy_if = hns_mac_get_phy_if(mac_cb);
+   mac_cb->phy_if = dsaf_dev->misc_op->get_phy_if(mac_cb);
 
ret = hns_mac_get_mode(mac_cb->phy_if);
if (ret < 0) {
@@ -819,7 +819,7 @@ int hns_mac_get_cfg(struct dsaf_device *dsaf_dev, struct 
hns_mac_cb *mac_cb)
if (ret)
return ret;
 
-   cpld_led_reset(mac_cb);
+   mac_cb->dsaf_dev->misc_op->cpld_reset_led(mac_cb);
mac_cb->vaddr = hns_mac_get_vaddr(dsaf_dev, mac_cb, mac_mode_idx);
 
return 0;
@@ -906,7 +906,7 @@ void hns_mac_uninit(struct dsaf_device *dsaf_dev)
int max_port_num = hns_mac_get_max_port_num(dsaf_dev);
 
for (i = 0; i < max_port_num; i++) {
-   cpld_led_reset(dsaf_dev->mac_cb[i]);
+   dsaf_dev->misc_op->cpld_reset_led(dsaf_dev->mac_cb[i]);
dsaf_dev->mac_cb[i] = NULL;
}
 }
@@ -989,7 +989,7 @@ void hns_set_led_opt(struct hns_mac_cb *mac_cb)

[patch v2 net-next 13/13] net: hns: net: hns: enet adds support of acpi

2016-05-29 Thread Kejian Yan
Enet needs to get configration parameter by acpi. This patch
adds support of ACPI for enet. The configuration parameter will
be configed in BIOS.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2:
 1. use acpi_dev_found() instead of acpi_match_device_ids()
 2. use is_acpi_node() to check if it works by ACPI case
 3. use dev_of_node() to check if it works by DT case

 v1: first submit
  link: https://lkml.org/lkml/2016/5/13/99
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 56 +--
 1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 3ec3c27..ad742a6 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -132,6 +132,13 @@ static void fill_v2_desc(struct hnae_ring *ring, void 
*priv,
ring_ptr_move_fw(ring, next_to_use);
 }
 
+static const struct acpi_device_id hns_enet_acpi_match[] = {
+   { "HISI00C1", 0 },
+   { "HISI00C2", 0 },
+   { },
+};
+MODULE_DEVICE_TABLE(acpi, hns_enet_acpi_match);
+
 static void fill_desc(struct hnae_ring *ring, void *priv,
  int size, dma_addr_t dma, int frag_end,
  int buf_num, enum hns_desc_type type, int mtu)
@@ -1870,7 +1877,6 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
struct device *dev = >dev;
struct net_device *ndev;
struct hns_nic_priv *priv;
-   struct device_node *ae_node;
u32 port_id;
int ret;
 
@@ -1884,20 +1890,45 @@ static int hns_nic_dev_probe(struct platform_device 
*pdev)
priv->dev = dev;
priv->netdev = ndev;
 
-   if (of_device_is_compatible(dev->of_node, "hisilicon,hns-nic-v1"))
-   priv->enet_ver = AE_VERSION_1;
-   else
-   priv->enet_ver = AE_VERSION_2;
+   if (dev_of_node(dev)) {
+   struct device_node *ae_node;
 
-   ae_node = of_parse_phandle(dev->of_node, "ae-handle", 0);
-   if (IS_ERR_OR_NULL(ae_node)) {
-   ret = PTR_ERR(ae_node);
-   dev_err(dev, "not find ae-handle\n");
-   goto out_read_prop_fail;
+   if (of_device_is_compatible(dev->of_node,
+   "hisilicon,hns-nic-v1"))
+   priv->enet_ver = AE_VERSION_1;
+   else
+   priv->enet_ver = AE_VERSION_2;
+
+   ae_node = of_parse_phandle(dev->of_node, "ae-handle", 0);
+   if (IS_ERR_OR_NULL(ae_node)) {
+   ret = PTR_ERR(ae_node);
+   dev_err(dev, "not find ae-handle\n");
+   goto out_read_prop_fail;
+   }
+   priv->fwnode = _node->fwnode;
+   } else if (is_acpi_node(dev->fwnode)) {
+   struct acpi_reference_args args;
+
+   if (acpi_dev_found(hns_enet_acpi_match[0].id))
+   priv->enet_ver = AE_VERSION_1;
+   else if (acpi_dev_found(hns_enet_acpi_match[1].id))
+   priv->enet_ver = AE_VERSION_2;
+   else
+   return -ENXIO;
+
+   /* try to find port-idx-in-ae first */
+   ret = acpi_node_get_property_reference(dev->fwnode,
+  "ae-handle", 0, );
+   if (ret) {
+   dev_err(dev, "not find ae-handle\n");
+   goto out_read_prop_fail;
+   }
+   priv->fwnode = acpi_fwnode_handle(args.adev);
+   } else {
+   dev_err(dev, "cannot read cfg data from OF or acpi\n");
+   return -ENXIO;
}
-   priv->fwnode = _node->fwnode;
 
-   /* try to find port-idx-in-ae first */
ret = device_property_read_u32(dev, "port-idx-in-ae", _id);
if (ret) {
/* only for old code compatible */
@@ -2014,6 +2045,7 @@ static struct platform_driver hns_nic_dev_driver = {
.driver = {
.name = "hns-nic",
.of_match_table = hns_enet_of_match,
+   .acpi_match_table = ACPI_PTR(hns_enet_acpi_match),
},
.probe = hns_nic_dev_probe,
.remove = hns_nic_dev_remove,
-- 
1.9.1



[patch v2 net-next 00/13] net: hns: add support of ACPI

2016-05-29 Thread Kejian Yan
This series adds HNS support of acpi. The routine will call some ACPI
helper functions, like acpi_dev_found() and acpi_evaluate_dsm(), which
are not included in other cases. In order to make system compile
successfully in other cases except ACPI, it needs to add relative stub
functions to linux/acpi.h. And we use device property functions instead
of serial helper functions to suport both DT and ACPI cases. And then
add the supports of ACPI for HNS.

change log:
 v1 -> v2:
 1. use acpi_dev_found() instead of acpi_match_device_ids() to check if
it is a acpi node.
 2. use is_of_node() instead of IS_ENABLED() to check if it is a DT node.
 3. split the patch("add support of acpi for hns-mdio") into two patches:
3.1 Move to use fwnode_handle
3.2 Add ACPI
 4. add the patch which subject is dsaf misc operation method
 5. fix the comments by Andy Shevchenko

Kejian Yan (13):
  ACPI: bus: add stub acpi_dev_found() to linux/acpi.h
  ACPI: bus: add stub acpi_evaluate_dsm() to linux/acpi.h
  net: hisilicon: cleanup to prepare for other cases
  net: hisilicon: add support of acpi for hns-mdio
  net: hns: use device_* APIs instead of of_* APIs
  net: hns: use platform_get_irq instead of irq_of_parse_and_map
  net: hns: enet specify a reference to dsaf by fwnode_handle
  net: hns: add uniform interface for phy connection
  net: hns: add dsaf misc operation method
  net: hns: dsaf adds support of acpi
  net: hns: register phy device in each mac initial sequence
  net: hns: implement the miscellaneous operation by asl
  net: hns: net: hns: enet adds support of acpi

 drivers/net/ethernet/hisilicon/hns/hnae.c  |  18 +-
 drivers/net/ethernet/hisilicon/hns/hnae.h  |   5 +-
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c  |   6 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c |   6 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 247 +++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h  |   4 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 105 ++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h |  33 ++-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 250 ++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.h |   7 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c  |  15 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c  |   5 +-
 .../net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c|  10 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  |  90 +---
 drivers/net/ethernet/hisilicon/hns/hns_enet.h  |   2 +-
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c   |   2 +-
 drivers/net/ethernet/hisilicon/hns_mdio.c  | 147 +++-
 include/linux/acpi.h   |  13 ++
 18 files changed, 710 insertions(+), 255 deletions(-)

-- 
1.9.1



[patch v2 net-next 03/13] net: hisilicon: cleanup to prepare for other cases

2016-05-29 Thread Kejian Yan
Hns-mdio only supports DT case now. do some cleanup to prepare
for introducing other cases later, no functional change.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns_mdio.c | 46 +++
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns_mdio.c 
b/drivers/net/ethernet/hisilicon/hns_mdio.c
index 765ddb3..381cf0a 100644
--- a/drivers/net/ethernet/hisilicon/hns_mdio.c
+++ b/drivers/net/ethernet/hisilicon/hns_mdio.c
@@ -354,6 +354,9 @@ static int hns_mdio_reset(struct mii_bus *bus)
struct hns_mdio_device *mdio_dev = (struct hns_mdio_device *)bus->priv;
int ret;
 
+   if (!dev_of_node(bus->parent))
+   return -ENOTSUPP;
+
if (!mdio_dev->subctrl_vbase) {
dev_err(>dev, "mdio sys ctl reg has not maped\n");
return -ENODEV;
@@ -399,19 +402,12 @@ static int hns_mdio_reset(struct mii_bus *bus)
 /**
  * hns_mdio_bus_name - get mdio bus name
  * @name: mdio bus name
- * @np: mdio device node pointer
+ * @addr: mdio physical address
  */
-static void hns_mdio_bus_name(char *name, struct device_node *np)
+static void hns_mdio_bus_name(char *name, phys_addr_t addr)
 {
-   const u32 *addr;
-   u64 taddr = OF_BAD_ADDR;
-
-   addr = of_get_address(np, 0, NULL, NULL);
-   if (addr)
-   taddr = of_translate_address(np, addr);
-
-   snprintf(name, MII_BUS_ID_SIZE, "%s@%llx", np->name,
-(unsigned long long)taddr);
+   snprintf(name, MII_BUS_ID_SIZE,
+"hns-mdio@%llx", (unsigned long long)addr);
 }
 
 /**
@@ -422,17 +418,16 @@ static void hns_mdio_bus_name(char *name, struct 
device_node *np)
  */
 static int hns_mdio_probe(struct platform_device *pdev)
 {
-   struct device_node *np;
struct hns_mdio_device *mdio_dev;
struct mii_bus *new_bus;
struct resource *res;
-   int ret;
+   int ret = -ENODEV;
 
if (!pdev) {
dev_err(NULL, "pdev is NULL!\r\n");
return -ENODEV;
}
-   np = pdev->dev.of_node;
+
mdio_dev = devm_kzalloc(>dev, sizeof(*mdio_dev), GFP_KERNEL);
if (!mdio_dev)
return -ENOMEM;
@@ -448,7 +443,7 @@ static int hns_mdio_probe(struct platform_device *pdev)
new_bus->write = hns_mdio_write;
new_bus->reset = hns_mdio_reset;
new_bus->priv = mdio_dev;
-   hns_mdio_bus_name(new_bus->id, np);
+   new_bus->parent = >dev;
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
mdio_dev->vbase = devm_ioremap_resource(>dev, res);
@@ -457,18 +452,23 @@ static int hns_mdio_probe(struct platform_device *pdev)
return ret;
}
 
-   mdio_dev->subctrl_vbase =
-   syscon_node_to_regmap(of_parse_phandle(np, "subctrl-vbase", 0));
-   if (IS_ERR(mdio_dev->subctrl_vbase)) {
-   dev_warn(>dev, "no syscon hisilicon,peri-c-subctrl\n");
-   mdio_dev->subctrl_vbase = NULL;
-   }
-   new_bus->parent = >dev;
platform_set_drvdata(pdev, new_bus);
 
-   ret = of_mdiobus_register(new_bus, np);
+   hns_mdio_bus_name(new_bus->id, res->start);
+   if (dev_of_node(>dev)) {
+   mdio_dev->subctrl_vbase = syscon_node_to_regmap(
+   of_parse_phandle(pdev->dev.of_node,
+"subctrl-vbase", 0));
+   if (IS_ERR(mdio_dev->subctrl_vbase)) {
+   dev_warn(>dev, "no syscon 
hisilicon,peri-c-subctrl\n");
+   mdio_dev->subctrl_vbase = NULL;
+   }
+   ret = of_mdiobus_register(new_bus, pdev->dev.of_node);
+   }
+
if (ret) {
dev_err(>dev, "Cannot register as MDIO bus!\n");
+
platform_set_drvdata(pdev, NULL);
return ret;
}
-- 
1.9.1



[patch v2 net-next 11/13] net: hns: register phy device in each mac initial sequence

2016-05-29 Thread Kejian Yan
In ACPI case, there is no interface to register phy device to mdio-bus.
Phy device has to be registered itself to mdio-bus, and then enet can
get the phy device's info so that it can config the phy-device to help
to trasmit and receive data.
HNS hardware topology is as below. The MDIO controller may control several
PHY-devices, and each PHY-device connects to a MAC device. PHY-devices
will register when each mac find PHY device in initial sequence.

   cpu
|
|
 ---
|   |   |
|   |   |
|  dsaf |
   MDIO |  MDIO
|  ---  |
| | | |   | |
| | | |   | |
|MAC   MAC   MAC MAC|
| | | |   | |
  | | |   | 
 ||||||   ||
 PHY   PHY   PHY PHY

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2: fix the build error by kbuild test robot

 v1: first submit
  link: https://lkml.org/lkml/2016/5/13/97
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 133 --
 1 file changed, 126 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 3ef0c9b..c526558 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -7,6 +7,7 @@
  * (at your option) any later version.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -638,6 +639,115 @@ free_mac_drv:
return ret;
 }
 
+static int
+hns_mac_phy_parse_addr(struct device *dev, struct fwnode_handle *fwnode)
+{
+   u32 addr;
+   int ret;
+
+   ret = fwnode_property_read_u32(fwnode, "phy-addr", );
+   if (ret) {
+   dev_err(dev, "has invalid PHY address ret:%d\n", ret);
+   return ret;
+   }
+
+   if (addr >= PHY_MAX_ADDR) {
+   dev_err(dev, "PHY address %i is too large\n", addr);
+   return -EINVAL;
+   }
+
+   return addr;
+}
+
+static int hns_mac_phydev_match(struct device *dev, void *fwnode)
+{
+   return dev->fwnode == fwnode;
+}
+
+static struct
+platform_device *hns_mac_find_platform_device(struct fwnode_handle *fwnode)
+{
+   struct device *dev;
+
+   dev = bus_find_device(_bus_type, NULL,
+ fwnode, hns_mac_phydev_match);
+   return dev ? to_platform_device(dev) : NULL;
+}
+
+static int
+hns_mac_register_phydev(struct mii_bus *mdio, struct hns_mac_cb *mac_cb,
+   u32 addr)
+{
+   struct phy_device *phy;
+   const char *phy_type;
+   bool is_c45;
+   int rc;
+
+   rc = fwnode_property_read_string(mac_cb->fw_port,
+"phy-mode", _type);
+   if (rc < 0)
+   return rc;
+
+   if (!strcmp(phy_type, phy_modes(PHY_INTERFACE_MODE_XGMII)))
+   is_c45 = 1;
+   else if (!strcmp(phy_type, phy_modes(PHY_INTERFACE_MODE_SGMII)))
+   is_c45 = 0;
+   else
+   return -ENODATA;
+
+   phy = get_phy_device(mdio, addr, is_c45);
+   if (!phy || IS_ERR(phy))
+   return -EIO;
+
+   if (mdio->irq)
+   phy->irq = mdio->irq[addr];
+
+   /* All data is now stored in the phy struct;
+* register it
+*/
+   rc = phy_device_register(phy);
+   if (rc) {
+   phy_device_free(phy);
+   return -ENODEV;
+   }
+
+   mac_cb->phy_dev = phy;
+
+   dev_dbg(>dev, "registered phy at address %i\n", addr);
+
+   return 0;
+}
+
+static void hns_mac_register_phy(struct hns_mac_cb *mac_cb)
+{
+   struct acpi_reference_args args;
+   struct platform_device *pdev;
+   struct mii_bus *mii_bus;
+   int rc;
+   int addr;
+
+   /* Loop over the child nodes and register a phy_device for each one */
+   if (!to_acpi_device_node(mac_cb->fw_port))
+   return;
+
+   rc = acpi_node_get_property_reference(
+   mac_cb->fw_port, "mdio-node", 0, );
+   if (rc)
+   return;
+
+   addr = hns_mac_phy_parse_addr(mac_cb->dev, mac_cb->fw_port);
+   if (addr < 0)
+   return;
+
+   /* dev address in adev */
+   pdev = hns_mac_find_platform_device(acpi_fwnode_handle(args.adev));
+   mii_bus = platform_get_drvdata(pdev);
+   rc = hns_mac_register_phydev(mii_bus, mac_cb, addr);
+   if (!rc)
+   dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n",
+   mac_cb->mac_id, 

[patch v2 net-next 05/13] net: hns: use device_* APIs instead of of_* APIs

2016-05-29 Thread Kejian Yan
OF series functions can be used only for DT case. Use unified
device property function instead to support both DT and ACPI.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c |  9 +
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 11 +++
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
index 1c2ddb2..9afc5e6 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
@@ -50,7 +50,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
else
dsaf_dev->dsaf_ver = AE_VERSION_2;
 
-   ret = of_property_read_string(np, "mode", _str);
+   ret = device_property_read_string(dsaf_dev->dev, "mode", _str);
if (ret) {
dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret);
return ret;
@@ -142,7 +142,7 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
}
}
 
-   ret = of_property_read_u32(np, "desc-num", _num);
+   ret = device_property_read_u32(dsaf_dev->dev, "desc-num", _num);
if (ret < 0 || desc_num < HNS_DSAF_MIN_DESC_CNT ||
desc_num > HNS_DSAF_MAX_DESC_CNT) {
dev_err(dsaf_dev->dev, "get desc-num(%d) fail, ret=%d!\n",
@@ -151,14 +151,15 @@ int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)
}
dsaf_dev->desc_num = desc_num;
 
-   ret = of_property_read_u32(np, "reset-field-offset", _offset);
+   ret = device_property_read_u32(dsaf_dev->dev, "reset-field-offset",
+  _offset);
if (ret < 0) {
dev_dbg(dsaf_dev->dev,
"get reset-field-offset fail, ret=%d!\r\n", ret);
}
dsaf_dev->reset_offset = reset_offset;
 
-   ret = of_property_read_u32(np, "buf-size", _size);
+   ret = device_property_read_u32(dsaf_dev->dev, "buf-size", _size);
if (ret < 0) {
dev_err(dsaf_dev->dev,
"get buf-size fail, ret=%d!\r\n", ret);
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index e621636..8851420 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1067,13 +1067,8 @@ void hns_nic_update_stats(struct net_device *netdev)
 static void hns_init_mac_addr(struct net_device *ndev)
 {
struct hns_nic_priv *priv = netdev_priv(ndev);
-   struct device_node *node = priv->dev->of_node;
-   const void *mac_addr_temp;
 
-   mac_addr_temp = of_get_mac_address(node);
-   if (mac_addr_temp && is_valid_ether_addr(mac_addr_temp)) {
-   memcpy(ndev->dev_addr, mac_addr_temp, ndev->addr_len);
-   } else {
+   if (!device_get_mac_address(priv->dev, ndev->dev_addr, ETH_ALEN)) {
eth_hw_addr_random(ndev);
dev_warn(priv->dev, "No valid mac, use random mac %pM",
 ndev->dev_addr);
@@ -1898,10 +1893,10 @@ static int hns_nic_dev_probe(struct platform_device 
*pdev)
goto out_read_prop_fail;
}
/* try to find port-idx-in-ae first */
-   ret = of_property_read_u32(node, "port-idx-in-ae", _id);
+   ret = device_property_read_u32(dev, "port-idx-in-ae", _id);
if (ret) {
/* only for old code compatible */
-   ret = of_property_read_u32(node, "port-id", _id);
+   ret = device_property_read_u32(dev, "port-id", _id);
if (ret)
goto out_read_prop_fail;
/* for old dts, we need to caculate the port offset */
-- 
1.9.1



[patch v2 net-next 10/13] net: hns: dsaf adds support of acpi

2016-05-29 Thread Kejian Yan
Dsaf needs to get configuration parameter by ACPI, so this patch add
support of ACPI.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2:
  1. use dev_of_node() instead of IS_ENABLED() to check if it is in
DT case,
  2. split a new patch to implement misc operation method,
  3. use acpi_dev_found() instead of acpi_match_device_ids() to
check which hw version it is,
  4. use is_acpi_node instead of ACPI_COMPANION to check if it is
work in ACPI case.

 v1: first submit
  link: https://lkml.org/lkml/2016/5/13/108
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 80 ++--
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 85 +++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | 32 
 3 files changed, 114 insertions(+), 83 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 2ebf14a..3ef0c9b 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -689,9 +689,7 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
return 0;
}
 
-   if (!is_of_node(mac_cb->fw_port))
-   return -EINVAL;
-
+   if (is_of_node(mac_cb->fw_port)) {
/* parse property from port subnode in dsaf */
np = of_parse_phandle(to_of_node(mac_cb->fw_port), "phy-handle", 0);
mac_cb->phy_dev = of_phy_find_device(np);
@@ -701,47 +699,49 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
mac_cb->mac_id, np->name);
}
 
-   syscon = syscon_node_to_regmap(
-   of_parse_phandle(to_of_node(mac_cb->fw_port),
-"serdes-syscon", 0));
-   if (IS_ERR_OR_NULL(syscon)) {
-   dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
-   return -EINVAL;
-   }
-   mac_cb->serdes_ctrl = syscon;
-
-   ret = fwnode_property_read_u32(mac_cb->fw_port,
-  "port-rst-offset",
-  _cb->port_rst_off);
-   if (ret) {
-   dev_dbg(mac_cb->dev,
-   "mac%d port-rst-offset not found, use default value.\n",
-   mac_cb->mac_id);
-   }
+   syscon = syscon_node_to_regmap(
+   of_parse_phandle(to_of_node(mac_cb->fw_port),
+"serdes-syscon", 0));
+   if (IS_ERR_OR_NULL(syscon)) {
+   dev_err(mac_cb->dev, "serdes-syscon is needed!\n");
+   return -EINVAL;
+   }
+   mac_cb->serdes_ctrl = syscon;
 
-   ret = fwnode_property_read_u32(mac_cb->fw_port,
-  "port-mode-offset",
-  _cb->port_mode_off);
-   if (ret) {
-   dev_dbg(mac_cb->dev,
-   "mac%d port-mode-offset not found, use default 
value.\n",
-   mac_cb->mac_id);
-   }
+   ret = fwnode_property_read_u32(mac_cb->fw_port,
+  "port-rst-offset",
+  _cb->port_rst_off);
+   if (ret) {
+   dev_dbg(mac_cb->dev,
+   "mac%d port-rst-offset not found, use default 
value.\n",
+   mac_cb->mac_id);
+   }
 
-   ret = of_parse_phandle_with_fixed_args(to_of_node(mac_cb->fw_port),
-  "cpld-syscon", 1, 0, _args);
-   if (ret) {
-   dev_dbg(mac_cb->dev, "mac%d no cpld-syscon found.\n",
-   mac_cb->mac_id);
-   mac_cb->cpld_ctrl = NULL;
-   } else {
-   syscon = syscon_node_to_regmap(cpld_args.np);
-   if (IS_ERR_OR_NULL(syscon)) {
-   dev_dbg(mac_cb->dev, "no cpld-syscon found!\n");
+   ret = fwnode_property_read_u32(mac_cb->fw_port,
+  "port-mode-offset",
+  _cb->port_mode_off);
+   if (ret) {
+   dev_dbg(mac_cb->dev,
+   "mac%d port-mode-offset not found, use default 
value.\n",
+   mac_cb->mac_id);
+   }
+
+   ret = of_parse_phandle_with_fixed_args(
+   to_of_node(mac_cb->fw_port), "cpld-syscon", 1, 0,
+   _args);
+   if (ret) {
+   dev_dbg(mac_cb->dev, "mac%d no cpld-syscon found.\n",
+   mac_cb->mac_id);
mac_cb->cpld_ctrl = NULL;
} else {
- 

[patch v2 net-next 08/13] net: hns: add uniform interface for phy connection

2016-05-29 Thread Kejian Yan
As device_node is only used by DT case, HNS needs to treat the other
cases including ACPI. It needs to use uniform ways to handle both of
DT and ACPI. This patch chooses phy_device, and of_phy_connect and
of_phy_attach are only used by DT case. It needs to use uniform interface
to handle that sequence by both DT and ACPI.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2:
  1. remove the redundant functions, and
  2. adds fwnode match method beside DT and ACPI.

 v1: first submit
  link: https://lkml.org/lkml/2016/5/13/100
---
 drivers/net/ethernet/hisilicon/hns/hnae.c  |  8 -
 drivers/net/ethernet/hisilicon/hns/hnae.h  |  3 +-
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c  |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c  | 34 +++---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h  |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c  | 21 +++--
 drivers/net/ethernet/hisilicon/hns/hns_ethtool.c   |  2 +-
 8 files changed, 49 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c 
b/drivers/net/ethernet/hisilicon/hns/hnae.c
index d630acd..5d3047c 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -96,7 +96,13 @@ static int __ae_match(struct device *dev, const void *data)
 {
struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
 
-   return (data == >dev->of_node->fwnode);
+   if (dev_of_node(hdev->dev))
+   return (data == >dev->of_node->fwnode);
+   else if (is_acpi_node(hdev->dev->fwnode))
+   return (data == hdev->dev->fwnode);
+
+   dev_err(dev, "__ae_match cannot read cfg data from OF or acpi\n");
+   return 0;
 }
 
 static struct hnae_ae_dev *find_ae(const struct fwnode_handle *fwnode)
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h 
b/drivers/net/ethernet/hisilicon/hns/hnae.h
index f5f8140..529cb13 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -27,6 +27,7 @@
  * "cb" means control block
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -512,7 +513,7 @@ struct hnae_ae_dev {
 struct hnae_handle {
struct device *owner_dev; /* the device which make use of this handle */
struct hnae_ae_dev *dev;  /* the device who provides this handle */
-   struct device_node *phy_node;
+   struct phy_device *phy_dev;
phy_interface_t phy_if;
u32 if_support;
int q_num;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c 
b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index 7a757e8..8e009f4 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -131,7 +131,7 @@ struct hnae_handle *hns_ae_get_handle(struct hnae_ae_dev 
*dev,
vf_cb->mac_cb = dsaf_dev->mac_cb[port_id];
 
ae_handle->phy_if = vf_cb->mac_cb->phy_if;
-   ae_handle->phy_node = vf_cb->mac_cb->phy_node;
+   ae_handle->phy_dev = vf_cb->mac_cb->phy_dev;
ae_handle->if_support = vf_cb->mac_cb->if_support;
ae_handle->port_type = vf_cb->mac_cb->mac_type;
ae_handle->dport_id = port_id;
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
index 611581f..527b49d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
@@ -15,7 +15,8 @@
 #include 
 #include 
 #include 
-#include 
+#include 
+#include 
 #include 
 
 #include "hns_dsaf_main.h"
@@ -645,7 +646,7 @@ free_mac_drv:
  */
 static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
 {
-   struct device_node *np = mac_cb->dev->of_node;
+   struct device_node *np;
struct regmap *syscon;
struct of_phandle_args cpld_args;
u32 ret;
@@ -672,21 +673,34 @@ static int  hns_mac_get_info(struct hns_mac_cb *mac_cb)
 * from dsaf node
 */
if (!mac_cb->fw_port) {
-   mac_cb->phy_node = of_parse_phandle(np, "phy-handle",
-   mac_cb->mac_id);
-   if (mac_cb->phy_node)
+   np = of_parse_phandle(mac_cb->dev->of_node, "phy-handle",
+ mac_cb->mac_id);
+   mac_cb->phy_dev = of_phy_find_device(np);
+   if (mac_cb->phy_dev) {
+   /* refcount is held by of_phy_find_device()
+* if the phy_dev is found
+*/
+   put_device(_cb->phy_dev->mdio.dev);
+
dev_dbg(mac_cb->dev, "mac%d phy_node: %s\n",
-   mac_cb->mac_id, mac_cb->phy_node->name);
+   mac_cb->mac_id, np->name);
+   }
+
 

[patch v2 net-next 01/13] ACPI: bus: add stub acpi_dev_found() to linux/acpi.h

2016-05-29 Thread Kejian Yan
acpi_dev_found() will be used to detect if a given ACPI device is in the
system. It will be compiled in non-ACPI case, but the function is in
acpi_bus.h and acpi_bus.h can only be used in ACPI case, so this patch add
the stub function to linux/acpi.h to make compiled successfully in
non-ACPI cases.

Cc: Rafael J. Wysocki 
Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
 include/linux/acpi.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 288fac5..3025d19 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -543,6 +543,11 @@ struct platform_device *acpi_create_platform_device(struct 
acpi_device *);
 
 struct fwnode_handle;
 
+static inline bool acpi_dev_found(const char *hid)
+{
+   return false;
+}
+
 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
 {
return false;
-- 
1.9.1



[patch v2 net-next 07/13] net: hns: enet specify a reference to dsaf by fwnode_handle

2016-05-29 Thread Kejian Yan
As device_node is only used by DT case, it is expected to find uniform
ways. So fwnode_handle is the suitable method.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
change log:
 v2: remove the redundant line

 v1: first submit
 link: https://lkml.org/lkml/2016/5/13/98
---
 drivers/net/ethernet/hisilicon/hns/hnae.c | 12 ++--
 drivers/net/ethernet/hisilicon/hns/hnae.h |  2 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 14 --
 drivers/net/ethernet/hisilicon/hns/hns_enet.h |  2 +-
 4 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c 
b/drivers/net/ethernet/hisilicon/hns/hnae.c
index 3bfe36f..d630acd 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.c
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.c
@@ -96,16 +96,16 @@ static int __ae_match(struct device *dev, const void *data)
 {
struct hnae_ae_dev *hdev = cls_to_ae_dev(dev);
 
-   return hdev->dev->of_node == data;
+   return (data == >dev->of_node->fwnode);
 }
 
-static struct hnae_ae_dev *find_ae(const struct device_node *ae_node)
+static struct hnae_ae_dev *find_ae(const struct fwnode_handle *fwnode)
 {
struct device *dev;
 
-   WARN_ON(!ae_node);
+   WARN_ON(!fwnode);
 
-   dev = class_find_device(hnae_class, NULL, ae_node, __ae_match);
+   dev = class_find_device(hnae_class, NULL, fwnode, __ae_match);
 
return dev ? cls_to_ae_dev(dev) : NULL;
 }
@@ -312,7 +312,7 @@ EXPORT_SYMBOL(hnae_reinit_handle);
  * return handle ptr or ERR_PTR
  */
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-   const struct device_node *ae_node,
+   const struct fwnode_handle  *fwnode,
u32 port_id,
struct hnae_buf_ops *bops)
 {
@@ -321,7 +321,7 @@ struct hnae_handle *hnae_get_handle(struct device 
*owner_dev,
int i, j;
int ret;
 
-   dev = find_ae(ae_node);
+   dev = find_ae(fwnode);
if (!dev)
return ERR_PTR(-ENODEV);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h 
b/drivers/net/ethernet/hisilicon/hns/hnae.h
index e8d36aa..f5f8140 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -528,7 +528,7 @@ struct hnae_handle {
 #define ring_to_dev(ring) ((ring)->q->dev->dev)
 
 struct hnae_handle *hnae_get_handle(struct device *owner_dev,
-   const struct device_node *ae_node,
+   const struct fwnode_handle  *fwnode,
u32 port_id,
struct hnae_buf_ops *bops);
 
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 8851420..93f6ccb 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -1807,7 +1807,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
int ret;
 
h = hnae_get_handle(>netdev->dev,
-   priv->ae_node, priv->port_id, NULL);
+   priv->fwnode, priv->port_id, NULL);
if (IS_ERR_OR_NULL(h)) {
ret = -ENODEV;
dev_dbg(priv->dev, "has not handle, register notifier!\n");
@@ -1867,7 +1867,7 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
struct device *dev = >dev;
struct net_device *ndev;
struct hns_nic_priv *priv;
-   struct device_node *node = dev->of_node;
+   struct device_node *ae_node;
u32 port_id;
int ret;
 
@@ -1881,17 +1881,19 @@ static int hns_nic_dev_probe(struct platform_device 
*pdev)
priv->dev = dev;
priv->netdev = ndev;
 
-   if (of_device_is_compatible(node, "hisilicon,hns-nic-v1"))
+   if (of_device_is_compatible(dev->of_node, "hisilicon,hns-nic-v1"))
priv->enet_ver = AE_VERSION_1;
else
priv->enet_ver = AE_VERSION_2;
 
-   priv->ae_node = (void *)of_parse_phandle(node, "ae-handle", 0);
-   if (IS_ERR_OR_NULL(priv->ae_node)) {
-   ret = PTR_ERR(priv->ae_node);
+   ae_node = of_parse_phandle(dev->of_node, "ae-handle", 0);
+   if (IS_ERR_OR_NULL(ae_node)) {
+   ret = PTR_ERR(ae_node);
dev_err(dev, "not find ae-handle\n");
goto out_read_prop_fail;
}
+   priv->fwnode = _node->fwnode;
+
/* try to find port-idx-in-ae first */
ret = device_property_read_u32(dev, "port-idx-in-ae", _id);
if (ret) {
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.h 
b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
index 337efa5..44bb301 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.h
@@ 

[patch v2 net-next 06/13] net: hns: use platform_get_irq instead of irq_of_parse_and_map

2016-05-29 Thread Kejian Yan
As irq_of_parse_and_map is only used by DT case, it is excepted to use
a uniform interface. So it is used platform_get_irq() instead.

Signed-off-by: Kejian Yan 
Signed-off-by: Yisen Zhuang 
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c 
b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
index 4ef6d23..3ce2409 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c
@@ -458,7 +458,6 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
u32 i;
u32 ring_num = rcb_common->ring_num;
int base_irq_idx = hns_rcb_get_base_irq_idx(rcb_common);
-   struct device_node *np = rcb_common->dsaf_dev->dev->of_node;
struct platform_device *pdev =
to_platform_device(rcb_common->dsaf_dev->dev);
bool is_ver1 = AE_IS_VER1(rcb_common->dsaf_dev->dsaf_ver);
@@ -473,10 +472,10 @@ void hns_rcb_get_cfg(struct rcb_common_cb *rcb_common)
ring_pair_cb->port_id_in_comm =
hns_rcb_get_port_in_comm(rcb_common, i);
ring_pair_cb->virq[HNS_RCB_IRQ_IDX_TX] =
-   is_ver1 ? irq_of_parse_and_map(np, base_irq_idx + i * 2) :
+   is_ver1 ? platform_get_irq(pdev, base_irq_idx + i * 2) :
  platform_get_irq(pdev, base_irq_idx + i * 3 + 1);
ring_pair_cb->virq[HNS_RCB_IRQ_IDX_RX] =
-   is_ver1 ? irq_of_parse_and_map(np, base_irq_idx + i * 2 + 1) :
+   is_ver1 ? platform_get_irq(pdev, base_irq_idx + i * 2 + 1) :
  platform_get_irq(pdev, base_irq_idx + i * 3);
ring_pair_cb->q.phy_base =
RCB_COMM_BASE_TO_RING_BASE(rcb_common->phy_base, i);
-- 
1.9.1



Re: [PATCH iproute2 net-next 2/5] bridge: add json support for bridge vlan show

2016-05-29 Thread Toshiaki Makita
On 2016/05/28 13:37, Roopa Prabhu wrote:
> From: Roopa Prabhu 
> 
> $bridge -c vlan show
> port  vlan ids
> swp1   1 PVID Egress Untagged
>10-13
> 
> swp2   1 PVID Egress Untagged
>10-13
> 
> br01 PVID Egress Untagged
> 
> $bridge -j vlan show
> {
> "swp1": [{
> "vlan": 1,
> "flags": "PVID Egress Untagged"

Shouldn't we split flags?

"swp1": [{
"vlan": 1,
"flags": [
"PVID",
"Egress Untagged"
]
}

--
Toshiaki Makita




Re: [PATCH 3/3] nl80211: Various checkpatch.pl fixes

2016-05-29 Thread Julian Calaby
Hi Kirtika,

On Mon, May 30, 2016 at 10:44 AM, Kirtika Ruchandani
 wrote:
>>> There's too much stuff here to quickly review, it'd be nice if you
>>> could split this up into patches that do the following:
>
> Is it preferable to resend the whole patch-set or just patch 3/3 in
> this one as a separate set?

Re-send the entire set, make sure you mark it as v2, include a
changelog in the cover letter or below the "---" in the patches
themselves, and don't forget to include the reviewed-bys for any
unchanged patches.

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH 3/3] nl80211: Various checkpatch.pl fixes

2016-05-29 Thread Kirtika Ruchandani
>> There's too much stuff here to quickly review, it'd be nice if you
>> could split this up into patches that do the following:

Is it preferable to resend the whole patch-set or just patch 3/3 in
this one as a separate set?


Re: [PATCH 3/3] nl80211: Various checkpatch.pl fixes

2016-05-29 Thread Kirtika Ruchandani
> There's too much stuff here to quickly review, it'd be nice if you
> could split this up into patches that do the following:

Thanks, I will send out a v2 with the split you suggested.


Re: [PATCH 3/3] nl80211: Various checkpatch.pl fixes

2016-05-29 Thread Julian Calaby
Hi Kirtika,

On Sun, May 29, 2016 at 1:31 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the following checkpatch.pl issues -

There's too much stuff here to quickly review, it'd be nice if you
could split this up into patches that do the following:

Space issues:
> - space preferred around that 
> - no space needed after cast.
> - Alignment should match open parenthesis
> - suspect code indent for conditional statements
> - Statements should start on a tabstop

Braces:
> - braces {} should be used on all arms of this statement

Multiple assignments:
> - multiple assignments should be avoided

ether_addr_copy:
> - prefer ether_addr_copy over memcpy

Spelling:
> - correct spelling - 'implementation'

NULL comparisons:
> - comparison to NULL could be written as !foo

kcalloc vs kzalloc:
> - prefer kcalloc over kzalloc with multiply

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH 2/3] nl80211: Fix checkpatch warnings about blank lines

2016-05-29 Thread Julian Calaby
Hi All,

On Sun, May 29, 2016 at 1:31 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the following checkpatch.pl issues -
> - Please don't use multiple blank lines
> - Blank lines aren't necessary before a close brace
> - Missing a blank line after declarations
>
> Signed-off-by: Kirtika Ruchandani 

Looks sensible to me

Reviewed-by: Julian Calaby 

Thanks,

Julian Calaby


> ---
>  net/wireless/nl80211.c | 22 ++
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index 50a0de0..cd422bd 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -167,6 +167,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct 
> nlattr **attrs)
>
> if (attrs[NL80211_ATTR_IFINDEX]) {
> int ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]);
> +
> netdev = __dev_get_by_index(netns, ifindex);
> if (netdev) {
> if (netdev->ieee80211_ptr)
> @@ -730,6 +731,7 @@ static int nl80211_parse_key_new(struct nlattr *key, 
> struct key_parse *k)
>
> if (tb[NL80211_KEY_DEFAULT_TYPES]) {
> struct nlattr *kdt[NUM_NL80211_KEY_DEFAULT_TYPES];
> +
> err = nla_parse_nested(kdt, NUM_NL80211_KEY_DEFAULT_TYPES - 1,
>tb[NL80211_KEY_DEFAULT_TYPES],
>nl80211_key_default_policy);
> @@ -1381,6 +1383,7 @@ static int nl80211_send_wiphy(struct 
> cfg80211_registered_device *rdev,
> rdev->ops->get_antenna) {
> u32 tx_ant = 0, rx_ant = 0;
> int res;
> +
> res = rdev_get_antenna(rdev, _ant, _ant);
> if (!res) {
> if (nla_put_u32(msg,
> @@ -2111,7 +2114,6 @@ static int nl80211_set_wds_peer(struct sk_buff *skb, 
> struct genl_info *info)
> return rdev_set_wds_peer(rdev, dev, bssid);
>  }
>
> -
>  static int nl80211_set_wiphy(struct sk_buff *skb, struct genl_info *info)
>  {
> struct cfg80211_registered_device *rdev;
> @@ -2244,6 +2246,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, 
> struct genl_info *info)
> if (info->attrs[NL80211_ATTR_WIPHY_ANTENNA_TX] &&
> info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]) {
> u32 tx_ant, rx_ant;
> +
> if ((!rdev->wiphy.available_antennas_tx &&
>  !rdev->wiphy.available_antennas_rx) ||
> !rdev->ops->set_antenna)
> @@ -2910,6 +2913,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct 
> genl_info *info)
> pairwise = !!mac_addr;
> if (info->attrs[NL80211_ATTR_KEY_TYPE]) {
> u32 kt = nla_get_u32(info->attrs[NL80211_ATTR_KEY_TYPE]);
> +
> if (kt >= NUM_NL80211_KEYTYPES)
> return -EINVAL;
> if (kt != NL80211_KEYTYPE_GROUP &&
> @@ -3949,7 +3953,6 @@ static int nl80211_dump_station(struct sk_buff *skb,
> sta_idx++;
> }
>
> -
>   out:
> cb->args[2] = sta_idx;
> err = skb->len;
> @@ -4742,7 +4745,6 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
> path_idx++;
> }
>
> -
>   out:
> cb->args[2] = path_idx;
> err = skb->len;
> @@ -5032,7 +5034,6 @@ static int nl80211_req_set_reg(struct sk_buff *skb, 
> struct genl_info *info)
> enum nl80211_user_reg_hint_type user_reg_hint_type;
> u32 owner_nlportid;
>
> -
> /* You should only get this when cfg80211 hasn't yet initialized
>  * completely when built-in to the kernel right between the time
>  * window between nl80211_init() and regulatory_init(), if that is
> @@ -5240,7 +5241,6 @@ do {
>   \
> }   \
>  } while (0)
>
> -
> if (!info->attrs[NL80211_ATTR_MESH_CONFIG])
> return -EINVAL;
> if (nla_parse_nested(tb, NL80211_MESHCONF_ATTR_MAX,
> @@ -5388,7 +5388,6 @@ static int nl80211_parse_mesh_setup(struct genl_info 
> *info,
>  IEEE80211_PATH_METRIC_VENDOR :
>  IEEE80211_PATH_METRIC_AIRTIME;
>
> -
> if (tb[NL80211_MESH_SETUP_IE]) {
> struct nlattr *ieattr =
> tb[NL80211_MESH_SETUP_IE];
> @@ -6009,6 +6008,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, 
> struct genl_info *info)
> /* all channels */
> for (band = 0; band < NUM_NL80211_BANDS; band++) {
> int j;
> +
> if (!wiphy->bands[band])
> continue;
> for (j = 0; j < 

Re: [PATCH 1/3] nl80211: Fix checkpatch warnings

2016-05-29 Thread Julian Calaby
Hi All,

On Sun, May 29, 2016 at 1:30 PM, Kirtika Ruchandani
 wrote:
> This patch fixes the following checkpatch.pl warnings about
> comments in nl80211.c :
> - networking block comments don't use an empty '/*' line
> - block comments use a trailing '*/' on a separate line
>
> Signed-off-by: Kirtika Ruchandani 

The change and logic behind it are sound, so it gets my:

Reviewed-by: Julian Calaby 

however I'm concerned that this file is a deliberate exception to the
networking comment rules.

Johannes?

Thanks,

Julian Calaby


> ---
>  net/wireless/nl80211.c | 129 
> +
>  1 file changed, 45 insertions(+), 84 deletions(-)
>
> diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
> index d759901..50a0de0 100644
> --- a/net/wireless/nl80211.c
> +++ b/net/wireless/nl80211.c
> @@ -196,8 +196,7 @@ __cfg80211_rdev_from_attrs(struct net *netns, struct 
> nlattr **attrs)
> return rdev;
>  }
>
> -/*
> - * This function returns a pointer to the driver
> +/* This function returns a pointer to the driver
>   * that the genl_info item that is passed refers to.
>   *
>   * The result of this can be a PTR_ERR and hence must
> @@ -1624,8 +1623,7 @@ static int nl80211_send_wiphy(struct 
> cfg80211_registered_device *rdev,
> goto nla_put_failure;
>
> features = rdev->wiphy.features;
> -   /*
> -* We can only add the per-channel limit information if the
> +   /* We can only add the per-channel limit information if the
>  * dump is split, otherwise it makes it too big. Therefore
>  * only advertise it in that case.
>  */
> @@ -1646,8 +1644,7 @@ static int nl80211_send_wiphy(struct 
> cfg80211_registered_device *rdev,
> rdev->wiphy.max_acl_mac_addrs))
> goto nla_put_failure;
>
> -   /*
> -* Any information below this point is only available to
> +   /* Any information below this point is only available to
>  * applications that can deal with it being split. This
>  * helps ensure that newly added capabilities don't break
>  * older tools by overrunning their buffers.
> @@ -1847,8 +1844,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, 
> struct netlink_callback *cb)
>  cb->nlh->nlmsg_seq,
>  NLM_F_MULTI, state);
> if (ret < 0) {
> -   /*
> -* If sending the wiphy data didn't fit 
> (ENOBUFS
> +   /* If sending the wiphy data didn't fit 
> (ENOBUFS
>  * or EMSGSIZE returned), this SKB is still
>  * empty (so it's not too big because another
>  * wiphy dataset is already in the skb) and
> @@ -1937,8 +1933,7 @@ static int parse_txq_params(struct nlattr *tb[],
>
>  static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev)
>  {
> -   /*
> -* You can only set the channel explicitly for WDS interfaces,
> +   /* You can only set the channel explicitly for WDS interfaces,
>  * all others have their channel managed via their respective
>  * "establish a connection" command (connect, join, ...)
>  *
> @@ -2131,8 +2126,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, 
> struct genl_info *info)
>
> ASSERT_RTNL();
>
> -   /*
> -* Try to find the wiphy and netdev. Normally this
> +   /* Try to find the wiphy and netdev. Normally this
>  * function shouldn't need the netdev, but this is
>  * done for backward compatibility -- previously
>  * setting the channel was done per wiphy, but now
> @@ -2162,8 +2156,7 @@ static int nl80211_set_wiphy(struct sk_buff *skb, 
> struct genl_info *info)
> } else
> wdev = netdev->ieee80211_ptr;
>
> -   /*
> -* end workaround code, by now the rdev is available
> +   /* end workaround code, by now the rdev is available
>  * and locked, and wdev may or may not be NULL.
>  */
>
> @@ -2260,7 +2253,8 @@ static int nl80211_set_wiphy(struct sk_buff *skb, 
> struct genl_info *info)
> rx_ant = 
> nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_ANTENNA_RX]);
>
> /* reject antenna configurations which don't match the
> -* available antenna masks, except for the "all" mask */
> +* available antenna masks, except for the "all" mask
> +*/
> if ((~tx_ant && (tx_ant & 
> ~rdev->wiphy.available_antennas_tx)) ||
> (~rx_ant && (rx_ant & 
> 

Re: [PATCH next] brcmfmac: don't remove interface on link down firmware event

2016-05-29 Thread kbuild test robot
Hi,

[auto build test WARNING on next-20160527]

url:
https://github.com/0day-ci/linux/commits/Rafa-Mi-ecki/brcmfmac-don-t-remove-interface-on-link-down-firmware-event/20160530-054251
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64 

All warnings (new ones prefixed by >>):

   drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 
'brcmf_notify_connect_status_ap':
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:5339:19: 
>> warning: unused variable 'ifp' [-Wunused-variable]
 struct brcmf_if *ifp = netdev_priv(ndev);
  ^

vim +/ifp +5339 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5323conn_info->resp_ie_len,
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5324completed ? 
WLAN_STATUS_SUCCESS :
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5325
WLAN_STATUS_AUTH_TIMEOUT,
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5326GFP_KERNEL);
16886735 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2012-12-05  5327brcmf_dbg(CONN, "Report connect result - 
connection %s\n",
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5328  completed ? "succeeded" : "failed");
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5329}
d96b801f drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2012-12-05  5330brcmf_dbg(TRACE, "Exit\n");
12f32370 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Peter Senna 
Tschudin 2014-05-31  5331return 0;
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5332  }
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5333  
5b435de0 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2011-10-05  5334  static s32
27a68fe3 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2012-09-27  5335  brcmf_notify_connect_status_ap(struct brcmf_cfg80211_info 
*cfg,
1a873342 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Hante Meuleman   
2012-09-27  5336   struct net_device *ndev,
1a873342 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Hante Meuleman   
2012-09-27  5337   const struct brcmf_event_msg *e, 
void *data)
1a873342 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Hante Meuleman   
2012-09-27  5338  {
a44aa400 drivers/net/wireless/brcm80211/brcmfmac/cfg80211.cHante Meuleman   
2014-12-03 @5339struct brcmf_if *ifp = netdev_priv(ndev);
7ee29602 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Hante Meuleman   
2013-02-06  5340static int generation;
5c36b99a drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2012-11-14  5341u32 event = e->event_code;
5c36b99a drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2012-11-14  5342u32 reason = e->reason;
1a873342 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Hante Meuleman   
2012-09-27  5343struct station_info sinfo;
1a873342 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Hante Meuleman   
2012-09-27  5344  
16886735 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2012-12-05  5345brcmf_dbg(CONN, "event %d, reason %d\n", event, reason);
5f4f9f11 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2013-02-08  5346if (event == BRCMF_E_LINK && reason == 
BRCMF_E_REASON_LINK_BSSCFG_DIS &&
5f4f9f11 drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c Arend van Spriel 
2013-02-08  5347ndev != cfg_to_ndev(cfg)) {

:: The code at line 5339 was first introduced by commit
:: a44aa4001a86d46f936ca449e5d6c268446bfae2 brcmfmac: add multiple BSS 
support.

:: TO: Hante Meuleman 
:: CC: John W. Linville 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH next] brcmfmac: don't remove interface on link down firmware event

2016-05-29 Thread Rafał Miłecki
There are two firmware events we handle similarly in brcmfmac:
BRCMF_E_LINK and BRCMF_E_IF. The difference from firmware point of view
is that the first one means BSS remains present in the firmware. Trying
to (re)create it (e.g. when adding new virtual interface) will result in
an error.

Current code treats both events in a similar way. It removes Linux
interface for each of them. It works OK with e.g. BCM43602. Its firmware
generates both events for each interface. It means we get BRCMF_E_LINK
and remove interface. That is soon followed by BRCMF_E_IF which means
BSS was also removed in a firmware. The only downside of this is a
harmless error like:
[  208.643180] brcmfmac: brcmf_fweh_call_event_handler: no interface object

Unfortunately BCM4366 firmware doesn't automatically remove BSS and so
it doesn't generate BRCMF_E_IF. In such case we incorrectly remove Linux
interface on BRCMF_E_LINK as BSS is still present in the firmware. It
results in an error when trying to re-create virtual interface, e.g.:
> iw phy phy1 interface add wlan1-1 type __ap
[ 3602.929199] brcmfmac: brcmf_ap_add_vif: timeout occurred
command failed: I/O error (-5)

With this patch we don't remove Linux interface while firmware keeps
BSS. Thanks to this we keep a consistent states of host driver and
device firmware.

Further improvement should be to mark BSS as disabled and remove
interface on BRCMF_E_LINK. Then we should add support for reusing
BSS-es.

Signed-off-by: Rafał Miłecki 
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 38df1be..26ff0f4 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -5439,8 +5439,6 @@ brcmf_notify_connect_status_ap(struct brcmf_cfg80211_info 
*cfg,
ndev != cfg_to_ndev(cfg)) {
brcmf_dbg(CONN, "AP mode link down\n");
complete(>vif_disabled);
-   if (ifp->vif->mbss)
-   brcmf_remove_interface(ifp);
return 0;
}
 
-- 
1.8.4.5



[PATCH net-next] ravb: Add SET_RUNTIME_PM_OPS macro

2016-05-29 Thread Yoshihiro Kaneko
From: Kazuya Mizuguchi 

Use SET_RUNTIME_PM_OPS macro instead of assigning a member of
dev_pm_ops directly.

Signed-off-by: Kazuya Mizuguchi 
Signed-off-by: Yoshihiro Kaneko 
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 867caf6..da8da86 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2111,8 +2111,7 @@ static int ravb_runtime_nop(struct device *dev)
 }
 
 static const struct dev_pm_ops ravb_dev_pm_ops = {
-   .runtime_suspend = ravb_runtime_nop,
-   .runtime_resume = ravb_runtime_nop,
+   SET_RUNTIME_PM_OPS(ravb_runtime_nop, ravb_runtime_nop, NULL)
 };
 
 #define RAVB_PM_OPS (_dev_pm_ops)
-- 
1.9.1



[PATCH net-next] ravb: Add ESF in RCR for enabling separation filter

2016-05-29 Thread Yoshihiro Kaneko
From: Masaru Nagai 

This patch adds enabling separation filter(ESF) is setting value of B'11.
This setting filter for separating AVB stream frames from non-AVB stream
frames is enabled. Non-matching frames from a stream are processed in
queue 0(best effort). H/W manual recommends B'11 or B'10.
When B'10 is setting, Non-mating frames are discarded.

Signed-off-by: Masaru Nagai 
Signed-off-by: Kazuya Mizuguchi 
Signed-off-by: Yoshihiro Kaneko 
---

This patch is based on the master branch of David Miller's next networking
tree.

 drivers/net/ethernet/renesas/ravb_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/ravb_main.c 
b/drivers/net/ethernet/renesas/ravb_main.c
index 867caf6..1ceadbf 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -402,7 +402,8 @@ static int ravb_dmac_init(struct net_device *ndev)
 #endif
 
/* Set AVB RX */
-   ravb_write(ndev, RCR_EFFS | RCR_ENCF | RCR_ETS0 | 0x1800, RCR);
+   ravb_write(ndev,
+  RCR_EFFS | RCR_ENCF | RCR_ETS0 | RCR_ESF | 0x1800, RCR);
 
/* Set FIFO size */
ravb_write(ndev, TGC_TQP_AVBMODE1 | 0x0000, TGC);
-- 
1.9.1



[RFC PATCH iproute2] tc: let m_ipt work with new iptables API headers

2016-05-29 Thread Alexander Aring
Since commit 5cd1adb ("Update to current iptables headers") the build
with m_ipt.o and the following config will fail:

TC_CONFIG_XT:=n
TC_CONFIG_XT_OLD:=n
TC_CONFIG_XT_OLD_H:=n

This patch renames "iptables_target" to "xtables_target" and some other
things which gets renamed and I noticed while reading iptables git log.
Functions which are not used in m_ipt.c and not exported by the header
are removed, if they still used in m_ipt.c I added a static to the function.

Reported-by: Clemens Gruber 
Signed-off-by: Alexander Aring 
---
I removed also "linux/if.h" because some redifinition errors and seems
not be necessary anymore.

I didn't test this implementation, I just fix the compile issues at m_ipt
implementation according to the algoritmn described above.

Maybe there are more TC_CONFIG_XT* config variants broken than just m_ipt?

 tc/m_ipt.c | 134 +++--
 1 file changed, 14 insertions(+), 120 deletions(-)

diff --git a/tc/m_ipt.c b/tc/m_ipt.c
index d088f5e..098f610 100644
--- a/tc/m_ipt.c
+++ b/tc/m_ipt.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -51,7 +50,7 @@ static struct option original_opts[] = {
{0, 0, 0, 0}
 };
 
-static struct iptables_target *t_list;
+static struct xtables_target *t_list;
 static struct option *opts = original_opts;
 static unsigned int global_option_offset;
 #define OPTION_OFFSET 256
@@ -59,32 +58,21 @@ static unsigned int global_option_offset;
 char *lib_dir;
 
 void
-register_target(struct iptables_target *me)
+xtables_register_target(struct xtables_target *me)
 {
-/*  fprintf(stderr, "\nDummy register_target %s\n", me->name);
-*/
me->next = t_list;
t_list = me;
 
 }
 
-void
-xtables_register_target(struct iptables_target *me)
-{
-   me->next = t_list;
-   t_list = me;
-}
-
-void
-exit_tryhelp(int status)
+static void exit_tryhelp(int status)
 {
fprintf(stderr, "Try `%s -h' or '%s --help' for more information.\n",
pname, pname);
exit(status);
 }
 
-void
-exit_error(enum exittype status, char *msg, ...)
+static void exit_error(enum xtables_exittype status, char *msg, ...)
 {
va_list args;
 
@@ -106,61 +94,6 @@ They should really have them as a library so i can link to 
them
 Email them next time i remember
 */
 
-char *
-addr_to_dotted(const struct in_addr *addrp)
-{
-   static char buf[20];
-   const unsigned char *bytep;
-
-   bytep = (const unsigned char *) &(addrp->s_addr);
-   sprintf(buf, "%d.%d.%d.%d", bytep[0], bytep[1], bytep[2], bytep[3]);
-   return buf;
-}
-
-int string_to_number_ll(const char *s, unsigned long long min,
-   unsigned long long max,
-unsigned long long *ret)
-{
-   unsigned long long number;
-   char *end;
-
-   /* Handle hex, octal, etc. */
-   errno = 0;
-   number = strtoull(s, , 0);
-   if (*end == '\0' && end != s) {
-   /* we parsed a number, let's see if we want this */
-   if (errno != ERANGE && min <= number && (!max || number <= 
max)) {
-   *ret = number;
-   return 0;
-   }
-   }
-   return -1;
-}
-
-int string_to_number_l(const char *s, unsigned long min, unsigned long max,
-  unsigned long *ret)
-{
-   int result;
-   unsigned long long number;
-
-   result = string_to_number_ll(s, min, max, );
-   *ret = (unsigned long)number;
-
-   return result;
-}
-
-int string_to_number(const char *s, unsigned int min, unsigned int max,
-   unsigned int *ret)
-{
-   int result;
-   unsigned long number;
-
-   result = string_to_number_l(s, min, max, );
-   *ret = (unsigned int)number;
-
-   return result;
-}
-
 static void free_opts(struct option *local_opts)
 {
if (local_opts != original_opts) {
@@ -205,10 +138,10 @@ fw_calloc(size_t count, size_t size)
return p;
 }
 
-static struct iptables_target *
+static struct xtables_target *
 find_t(char *name)
 {
-   struct iptables_target *m;
+   struct xtables_target *m;
 
for (m = t_list; m; m = m->next) {
if (strcmp(m->name, name) == 0)
@@ -218,13 +151,13 @@ find_t(char *name)
return NULL;
 }
 
-static struct iptables_target *
+static struct xtables_target *
 get_target_name(const char *name)
 {
void *handle;
char *error;
char *new_name, *lname;
-   struct iptables_target *m;
+   struct xtables_target *m;
char path[strlen(lib_dir) + sizeof("/libipt_.so") + strlen(name)];
 
 #ifdef NO_SHARED_LIBS
@@ -291,7 +224,7 @@ get_target_name(const char *name)
 
m = dlsym(handle, new_name);
if ((error = dlerror()) != NULL) {
-   m = (struct iptables_target *) dlsym(handle, lname);
+   m = (struct xtables_target *) 

Re: [PATCH linux-firmware] qed: Add FW 8.10.5.0

2016-05-29 Thread Kyle McMartin
On Tue, May 17, 2016 at 12:50:02AM +0300, Yuval Mintz wrote:
> The new QED firmware contains several new additions;
> As for bug-fixes, it fixes a couple of issues:
>  - Wrong classification of packets in 4-port devices.
>  - Anti-spoof interoperability with encapsulated packets.
>  - Tx-switching of encapsulated packets.
> It also slightly improves Tx performance in several scenarios.
> 
> >From the driver's feature-set POV, this firmware would
> allow us to add 2 major enhancements in the near future:
>  - It would allow us produce a register dump from the device,
>as well as other debug-related information.
>  - It should be sufficient for our iscsi driver, which we [hopefully]
>plan to push upstream soon.
> 
> Signed-off-by: Yuval Mintz 

Merged, thanks Yuval.

--Kyle


Re: [PATCH net] openvswitch: update checksum in {push,pop}_mpls

2016-05-29 Thread pravin shelar
On Thu, May 26, 2016 at 11:58 PM, Simon Horman
 wrote:
> In the case of CHECKSUM_COMPLETE the skb checksum should be updated in
> {push,pop}_mpls() as they the type in the ethernet header.
>
> As suggested by Pravin Shelar.
>
> Cc: Pravin Shelar 
> Fixes: 25cd9ba0abc0 ("openvswitch: Add basic MPLS support to kernel")
> Signed-off-by: Simon Horman 
> ---
>  net/openvswitch/actions.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> index 879185fe183f..d6010b44d423 100644
> --- a/net/openvswitch/actions.c
> +++ b/net/openvswitch/actions.c
> @@ -161,6 +161,12 @@ static int push_mpls(struct sk_buff *skb, struct 
> sw_flow_key *key,
> skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN);
>
> hdr = eth_hdr(skb);
> +   if (skb->ip_summed == CHECKSUM_COMPLETE) {
> +   __be16 diff[] = { ~(hdr->h_proto), mpls->mpls_ethertype };
> +
> +   skb->csum = ~csum_partial((char *)diff, sizeof(diff),
> +   ~skb->csum);
> +   }
> hdr->h_proto = mpls->mpls_ethertype;
>
This looks correct. But same code is now replicated three times in
this file. can you add helper function to update checksum for such
case?

> if (!skb->inner_protocol)
> @@ -193,6 +199,12 @@ static int pop_mpls(struct sk_buff *skb, struct 
> sw_flow_key *key,
>  * field correctly in the presence of VLAN tags.
>  */
> hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN);
> +   if (skb->ip_summed == CHECKSUM_COMPLETE) {
> +   __be16 diff[] = { ~(hdr->h_proto), ethertype };
> +
> +   skb->csum = ~csum_partial((char *)diff, sizeof(diff),
> +   ~skb->csum);
> +   }
> hdr->h_proto = ethertype;
> if (eth_p_mpls(skb->protocol))
> skb->protocol = ethertype;
> --
> 2.1.4
>


[PATCH] veth: delay peer link configuration after interfaces are tied

2016-05-29 Thread Vincent Bernat
When the peer link is created, its "iflink" information is not
advertised through netlink. If a user is maintaining a cache from all
updates, it will miss this information:

2: veth0@NONE:  mtu 1500 qdisc noop state DOWN group 
default
link/ether ae:0e:08:af:fb:a0 brd ff:ff:ff:ff:ff:ff
3: veth1@veth0:  mtu 1500 qdisc noop state DOWN 
group default
link/ether 3a:31:f1:36:2e:e5 brd ff:ff:ff:ff:ff:ff

To avoid this situation, the peer link is only configured after both
interfaces are tied together:

3: veth0@veth1:  mtu 1500 qdisc noop state DOWN group 
default
link/ether ee:0d:80:46:36:fe brd ff:ff:ff:ff:ff:ff
4: veth1@veth0:  mtu 1500 qdisc noop state DOWN 
group default
link/ether ba:25:bc:7a:0d:c8 brd ff:ff:ff:ff:ff:ff

Signed-off-by: Vincent Bernat 
---
 drivers/net/veth.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index f37a6e61d4ad..9726c4dbf659 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -432,10 +432,6 @@ static int veth_newlink(struct net *src_net, struct 
net_device *dev,
 
netif_carrier_off(peer);
 
-   err = rtnl_configure_link(peer, ifmp);
-   if (err < 0)
-   goto err_configure_peer;
-
/*
 * register dev last
 *
@@ -466,6 +462,10 @@ static int veth_newlink(struct net *src_net, struct 
net_device *dev,
 
priv = netdev_priv(peer);
rcu_assign_pointer(priv->peer, dev);
+
+   err = rtnl_configure_link(peer, ifmp);
+   if (err < 0)
+   goto err_configure_peer;
return 0;
 
 err_register_dev:
-- 
2.8.1



[PATCHv2 net] sctp: sctp_diag should dump sctp socket type

2016-05-29 Thread Xin Long
Now we cannot distinguish that one sk is a udp or sctp style when
we use ss to dump sctp_info. it's necessary to dump it as well.

For sctp_diag, ss support is not officially available, thus there
are no official users of this yet, so we can add this field in the
middle of sctp_info without breaking user API.

v1->v2:
  - move 'sctpi_s_type' field to the end of struct sctp_info, so
that it won't cause incompatibility with applications already
built.
  - add __reserved3 in sctp_info to make sure sctp_info is 8-byte
alignment.

Signed-off-by: Xin Long 
---
 include/linux/sctp.h | 2 ++
 net/sctp/socket.c| 1 +
 2 files changed, 3 insertions(+)

diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index dacb5e7..de1f643 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -765,6 +765,8 @@ struct sctp_info {
__u8sctpi_s_disable_fragments;
__u8sctpi_s_v4mapped;
__u8sctpi_s_frag_interleave;
+   __u32   sctpi_s_type;
+   __u32   __reserved3;
 };
 
 struct sctp_infox {
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 777d032..67154b8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4220,6 +4220,7 @@ int sctp_get_sctp_info(struct sock *sk, struct 
sctp_association *asoc,
info->sctpi_s_disable_fragments = sp->disable_fragments;
info->sctpi_s_v4mapped = sp->v4mapped;
info->sctpi_s_frag_interleave = sp->frag_interleave;
+   info->sctpi_s_type = sp->type;
 
return 0;
}
-- 
2.1.0