* Re: [PATCH net 1/1] driver: macvlan: Destroy new macvlan port if macvlan_common_newlink failed.
From: Feng Gao @ 2016-11-07 13:11 UTC (permalink / raw)
To: David S. Miller, Patrick McHardy, Linux Kernel Network Developers,
Feng Gao
Cc: Gao Feng
In-Reply-To: <1478226529-26766-1-git-send-email-fgao@ikuai8.com>
On Fri, Nov 4, 2016 at 10:28 AM, <fgao@ikuai8.com> wrote:
> From: Gao Feng <fgao@ikuai8.com>
>
> When there is no existing macvlan port in lowdev, one new macvlan port
> would be created. But it doesn't be destoried when something failed later.
> It casues some memleak.
>
> Now add one flag to indicate if new macvlan port is created.
>
> Signed-off-by: Gao Feng <fgao@ikuai8.com>
> ---
> drivers/net/macvlan.c | 31 ++++++++++++++++++++++---------
> 1 file changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 3234fcd..d2d6f12 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -1278,6 +1278,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
> struct net_device *lowerdev;
> int err;
> int macmode;
> + bool create = false;
>
> if (!tb[IFLA_LINK])
> return -EINVAL;
> @@ -1304,12 +1305,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
> err = macvlan_port_create(lowerdev);
> if (err < 0)
> return err;
> + create = true;
> }
> port = macvlan_port_get_rtnl(lowerdev);
>
> /* Only 1 macvlan device can be created in passthru mode */
> - if (port->passthru)
> - return -EINVAL;
> + if (port->passthru) {
> + /* The macvlan port must be not created this time,
> + * still goto destroy_macvlan_port for readability.
> + */
> + err = -EINVAL;
> + goto destroy_macvlan_port;
> + }
>
> vlan->lowerdev = lowerdev;
> vlan->dev = dev;
> @@ -1325,24 +1332,28 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
> vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
>
> if (vlan->mode == MACVLAN_MODE_PASSTHRU) {
> - if (port->count)
> - return -EINVAL;
> + if (port->count) {
> + err = -EINVAL;
> + goto destroy_macvlan_port;
> + }
> port->passthru = true;
> eth_hw_addr_inherit(dev, lowerdev);
> }
>
> if (data && data[IFLA_MACVLAN_MACADDR_MODE]) {
> - if (vlan->mode != MACVLAN_MODE_SOURCE)
> - return -EINVAL;
> + if (vlan->mode != MACVLAN_MODE_SOURCE) {
> + err = -EINVAL;
> + goto destroy_macvlan_port;
> + }
> macmode = nla_get_u32(data[IFLA_MACVLAN_MACADDR_MODE]);
> err = macvlan_changelink_sources(vlan, macmode, data);
> if (err)
> - return err;
> + goto destroy_macvlan_port;
> }
>
> err = register_netdevice(dev);
> if (err < 0)
> - return err;
> + goto destroy_macvlan_port;
>
> dev->priv_flags |= IFF_MACVLAN;
> err = netdev_upper_dev_link(lowerdev, dev);
> @@ -1357,7 +1368,9 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
>
> unregister_netdev:
> unregister_netdevice(dev);
> -
> +destroy_macvlan_port:
> + if (create)
> + macvlan_port_destroy(port->dev);
> return err;
> }
> EXPORT_SYMBOL_GPL(macvlan_common_newlink);
> --
> 1.9.1
>
>
Hi all,
How about this fix ? Is there any issue ?
Regards
Feng
^ permalink raw reply
* [PATCH net] net: bgmac: fix reversed checks for clock control flag
From: Rafał Miłecki @ 2016-11-07 12:53 UTC (permalink / raw)
To: David S . Miller, netdev
Cc: f.fainelli, bcm-kernel-feedback-list, Rafał Miłecki,
Jon Mason
From: Rafał Miłecki <rafal@milecki.pl>
This fixes regression introduced by patch adding feature flags. It was
already reported and patch followed (it got accepted) but it appears it
was incorrect. Instead of fixing reversed condition it broke a good one.
This patch was verified to actually fix SoC hanges caused by bgmac on
BCM47186B0.
Fixes: db791eb2970b ("net: ethernet: bgmac: convert to feature flags")
Fixes: 4af1474e6198 ("net: bgmac: Fix errant feature flag check")
Cc: Jon Mason <jon.mason@broadcom.com>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
It seems 4af1474e6198 was never backported to the 4.8, so I'm not Cc-ing
stable. I'll send separated patch for 4.8 once this one gets accepted.
---
drivers/net/ethernet/broadcom/bgmac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 91cbf92..49f4cafe 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1049,9 +1049,9 @@ static void bgmac_enable(struct bgmac *bgmac)
mode = (bgmac_read(bgmac, BGMAC_DEV_STATUS) & BGMAC_DS_MM_MASK) >>
BGMAC_DS_MM_SHIFT;
- if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) || mode != 0)
+ if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST || mode != 0)
bgmac_set(bgmac, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
- if (bgmac->feature_flags & BGMAC_FEAT_CLKCTLST && mode == 2)
+ if (!(bgmac->feature_flags & BGMAC_FEAT_CLKCTLST) && mode == 2)
bgmac_cco_ctl_maskset(bgmac, 1, ~0,
BGMAC_CHIPCTL_1_RXC_DLL_BYPASS);
--
2.10.1
^ permalink raw reply related
* [PATCH] igb: drop field "tail" of struct igb_ring
From: Cao jin @ 2016-11-07 12:44 UTC (permalink / raw)
To: linux-kernel, netdev; +Cc: intel-wired-lan, jeffrey.t.kirsher, izumi.taku
Under certain condition, I find guest will oops on writel() in
igb_configure_tx_ring(), because hw->hw_address is NULL. While other
register access won't oops kernel because they use wr32/rd32 which have
a defense against NULL pointer. The oops message are as following:
[ 141.225449] pcieport 0000:00:1c.0: AER: Multiple Uncorrected (Fatal)
error received: id=0101
[ 141.225523] igb 0000:01:00.1: PCIe Bus Error: severity=Uncorrected
(Fatal), type=Unaccessible, id=0101(Unregistered Agent ID)
[ 141.299442] igb 0000:01:00.1: broadcast error_detected message
[ 141.300539] igb 0000:01:00.0 enp1s0f0: PCIe link lost, device now
detached
[ 141.351019] igb 0000:01:00.1 enp1s0f1: PCIe link lost, device now
detached
[ 143.465904] pcieport 0000:00:1c.0: Root Port link has been reset
[ 143.465994] igb 0000:01:00.1: broadcast slot_reset message
[ 143.466039] igb 0000:01:00.0: enabling device (0000 -> 0002)
[ 144.389078] igb 0000:01:00.1: enabling device (0000 -> 0002)
[ 145.312078] igb 0000:01:00.1: broadcast resume message
[ 145.322211] BUG: unable to handle kernel paging request at
0000000000003818
[ 145.361275] IP: [<ffffffffa02fd38d>] igb_configure_tx_ring+0x14d/0x280 [igb]
[ 145.438007] Oops: 0002 [#1] SMP
On the other hand, commit 238ac817 does some optimization which
dropped the field "head". So I think it is time to drop "tail" as well.
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
drivers/net/ethernet/intel/igb/igb.h | 1 -
drivers/net/ethernet/intel/igb/igb_main.c | 16 +++++++++-------
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
index d11093d..0df06bc 100644
--- a/drivers/net/ethernet/intel/igb/igb.h
+++ b/drivers/net/ethernet/intel/igb/igb.h
@@ -247,7 +247,6 @@ struct igb_ring {
};
void *desc; /* descriptor ring memory */
unsigned long flags; /* ring specific flags */
- void __iomem *tail; /* pointer to ring tail register */
dma_addr_t dma; /* phys address of the ring */
unsigned int size; /* length of desc. ring in bytes */
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index edc9a6a..e177d0e 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -3390,9 +3390,8 @@ void igb_configure_tx_ring(struct igb_adapter *adapter,
tdba & 0x00000000ffffffffULL);
wr32(E1000_TDBAH(reg_idx), tdba >> 32);
- ring->tail = hw->hw_addr + E1000_TDT(reg_idx);
wr32(E1000_TDH(reg_idx), 0);
- writel(0, ring->tail);
+ wr32(E1000_TDT(reg_idx), 0);
txdctl |= IGB_TX_PTHRESH;
txdctl |= IGB_TX_HTHRESH << 8;
@@ -3729,9 +3728,8 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,
ring->count * sizeof(union e1000_adv_rx_desc));
/* initialize head and tail */
- ring->tail = hw->hw_addr + E1000_RDT(reg_idx);
wr32(E1000_RDH(reg_idx), 0);
- writel(0, ring->tail);
+ wr32(E1000_RDT(reg_idx), 0);
/* set descriptor configuration */
srrctl = IGB_RX_HDR_LEN << E1000_SRRCTL_BSIZEHDRSIZE_SHIFT;
@@ -5130,6 +5128,8 @@ static void igb_tx_map(struct igb_ring *tx_ring,
u32 tx_flags = first->tx_flags;
u32 cmd_type = igb_tx_cmd_type(skb, tx_flags);
u16 i = tx_ring->next_to_use;
+ struct igb_adapter *adapter = netdev_priv(tx_ring->netdev);
+ struct e1000_hw *hw = &adapter->hw;
tx_desc = IGB_TX_DESC(tx_ring, i);
@@ -5223,7 +5223,7 @@ static void igb_tx_map(struct igb_ring *tx_ring,
igb_maybe_stop_tx(tx_ring, DESC_NEEDED);
if (netif_xmit_stopped(txring_txq(tx_ring)) || !skb->xmit_more) {
- writel(i, tx_ring->tail);
+ wr32(E1000_TDT(tx_ring->reg_idx), i);
/* we need this if more than one processor can write to our tail
* at a time, it synchronizes IO on IA64/Altix systems
@@ -6756,7 +6756,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector, int napi_budget)
" desc.status <%x>\n",
tx_ring->queue_index,
rd32(E1000_TDH(tx_ring->reg_idx)),
- readl(tx_ring->tail),
+ rd32(E1000_TDT(tx_ring->reg_idx)),
tx_ring->next_to_use,
tx_ring->next_to_clean,
tx_buffer->time_stamp,
@@ -7265,6 +7265,8 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count)
union e1000_adv_rx_desc *rx_desc;
struct igb_rx_buffer *bi;
u16 i = rx_ring->next_to_use;
+ struct igb_adapter *adapter = netdev_priv(rx_ring->netdev);
+ struct e1000_hw *hw = &adapter->hw;
/* nothing to do */
if (!cleaned_count)
@@ -7313,7 +7315,7 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count)
* such as IA-64).
*/
wmb();
- writel(i, rx_ring->tail);
+ wr32(E1000_RDT(rx_ring->reg_idx), i);
}
}
--
2.1.0
^ permalink raw reply related
* RE: [PATCH net-next] qed: Prevent stack corruption on MFW interaction
From: Mintz, Yuval @ 2016-11-07 12:25 UTC (permalink / raw)
To: David Laight, davem@davemloft.net, netdev@vger.kernel.org
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DB021652B@AcuExch.aculab.com>
> > Driver uses a union for copying data to & from management firmware
> > when interacting with it.
> > Problem is that the function always copies sizeof(union) while commit
> > 2edbff8dcb5d ("qed: Learn resources from management firmware") is
> > casting a union elements which is of smaller size [24-byte instead of 88-bytes].
> >
> > Also, the union contains some inappropriate elements which increase
> > its size [should have been 32-bytes]. While this shouldn't corrupt
> > other PF messages to the MFW [as management firmware enforces
> > permissions so that each PF is allowed to write only to its own
> > mailbox] we fix this here as well.
> ...
>
> Is it worth adding a compile-time assert on the size of the union?
>
> David
I don't think so; The MFW team defines the elements and already enforces that.
It was simply a slip in my initial submission, where I omitted some
stuff that was already part of their HSI and wasn't required for that
submission, and missed the fact it was a union and not a struct
[hence uniting the removed fields to retain 'correct offsets' of fields].
^ permalink raw reply
* RE: [PATCH net-next] qed: Prevent stack corruption on MFW interaction
From: David Laight @ 2016-11-07 12:17 UTC (permalink / raw)
To: 'Yuval Mintz', davem@davemloft.net,
netdev@vger.kernel.org
In-Reply-To: <1478445147-23163-1-git-send-email-Yuval.Mintz@cavium.com>
From: Yuval Mintz
> Sent: 06 November 2016 15:12
> Driver uses a union for copying data to & from management firmware
> when interacting with it.
> Problem is that the function always copies sizeof(union) while commit
> 2edbff8dcb5d ("qed: Learn resources from management firmware") is casting
> a union elements which is of smaller size [24-byte instead of 88-bytes].
>
> Also, the union contains some inappropriate elements which increase its
> size [should have been 32-bytes]. While this shouldn't corrupt other
> PF messages to the MFW [as management firmware enforces permissions so
> that each PF is allowed to write only to its own mailbox] we fix this
> here as well.
...
Is it worth adding a compile-time assert on the size of the union?
David
^ permalink raw reply
* Re: [PATCH v3 2/2] net: ethernet: nb8800: handle all RGMII definitions
From: Måns Rullgård @ 2016-11-07 11:51 UTC (permalink / raw)
To: Sebastian Frias; +Cc: David S. Miller, netdev, LKML, Mason, Andrew Lunn
In-Reply-To: <58205103.4090208@laposte.net>
Sebastian Frias <sf84@laposte.net> writes:
> Hi Måns,
>
> On 11/05/2016 01:58 PM, Måns Rullgård wrote:
>>> if (gigabit) {
>>> - if (priv->phy_mode == PHY_INTERFACE_MODE_RGMII)
>>> + if (phy_interface_is_rgmii(phydev))
>>> mac_mode |= RGMII_MODE;
>>>
>>> mac_mode |= GMAC_MODE;
>>
>> As I said before, this part can/should be applied separately, although
>> personally I probably wouldn't have bothered adding a single-use variable.
>
> It was for consistency with other functions that use 'phydev', but I don't
> mind making the changes.
>
> Just to be clear, when you say "can/should be applied separately", do you
> mean that this patch should not be part of a series, and that I should split
> the series into separate patches?
I meant that this change should be made regardless of the others and can
be done separately if desired.
--
Måns Rullgård
^ permalink raw reply
* RE: [PATCH for-next 01/11] IB/hns: Add the interface for querying QP1
From: Salil Mehta @ 2016-11-07 11:45 UTC (permalink / raw)
To: Anurup m, dledford@redhat.com
Cc: linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
mehta.salil.lnk@gmail.com, linux-kernel@vger.kernel.org, Linuxarm
In-Reply-To: <582014FF.3070600@huawei.com>
> -----Original Message-----
> From: Anurup m
> Sent: Monday, November 07, 2016 5:46 AM
> To: Salil Mehta; dledford@redhat.com
> Cc: linux-rdma@vger.kernel.org; netdev@vger.kernel.org;
> mehta.salil.lnk@gmail.com; linux-kernel@vger.kernel.org; Linuxarm
> Subject: Re: [PATCH for-next 01/11] IB/hns: Add the interface for
> querying QP1
>
>
>
> On 11/4/2016 10:06 PM, Salil Mehta wrote:
> > From: Lijun Ou <oulijun@huawei.com>
> >
> > In old code, It only added the interface for querying non-specific
> > QP. This patch mainly adds an interface for querying QP1.
> >
> > Signed-off-by: Lijun Ou <oulijun@huawei.com>
> > Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> > Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
> > ---
> > drivers/infiniband/hw/hns/hns_roce_hw_v1.c | 87
> +++++++++++++++++++++++++++-
> > drivers/infiniband/hw/hns/hns_roce_hw_v1.h | 6 +-
> > 2 files changed, 90 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> > index 71232e5..ca8b784 100644
> > --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c
> > @@ -2630,8 +2630,82 @@ static int hns_roce_v1_query_qpc(struct
> hns_roce_dev *hr_dev,
> > return ret;
> > }
> >
> > -int hns_roce_v1_query_qp(struct ib_qp *ibqp, struct ib_qp_attr
> *qp_attr,
> > - int qp_attr_mask, struct ib_qp_init_attr
> *qp_init_attr)
> > +static int hns_roce_v1_q_sqp(struct ib_qp *ibqp, struct ib_qp_attr
> *qp_attr,
> > + int qp_attr_mask,
> > + struct ib_qp_init_attr *qp_init_attr)
> > +{
> > + struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
> > + struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> > + struct hns_roce_sqp_context *context;
> > + u32 addr;
> > +
> > + context = kzalloc(sizeof(*context), GFP_KERNEL);
> > + if (!context)
> > + return -ENOMEM;
> > +
> Do we really need dynamic alloc here as the size is fixed and this
> memory scope is
> only inside this function. I think better to use a static allocation.
Agreed. Somehow missed this in the internal review. Will change!
Thanks
Salil
>
> > + mutex_lock(&hr_qp->mutex);
> > +
> > + if (hr_qp->state == IB_QPS_RESET) {
> I think alloc can be moved after this check (if dynamic alloc is really
> needed).
> > + qp_attr->qp_state = IB_QPS_RESET;
> > + goto done;
> > + }
> > +
> > + addr = ROCEE_QP1C_CFG0_0_REG + hr_qp->port * sizeof(*context);
> > + context->qp1c_bytes_4 = roce_read(hr_dev, addr);
> > + context->sq_rq_bt_l = roce_read(hr_dev, addr + 1);
> > + context->qp1c_bytes_12 = roce_read(hr_dev, addr + 2);
> > + context->qp1c_bytes_16 = roce_read(hr_dev, addr + 3);
> > + context->qp1c_bytes_20 = roce_read(hr_dev, addr + 4);
> > + context->cur_rq_wqe_ba_l = roce_read(hr_dev, addr + 5);
> > + context->qp1c_bytes_28 = roce_read(hr_dev, addr + 6);
> > + context->qp1c_bytes_32 = roce_read(hr_dev, addr + 7);
> > + context->cur_sq_wqe_ba_l = roce_read(hr_dev, addr + 8);
> > + context->qp1c_bytes_40 = roce_read(hr_dev, addr + 9);
> > +
> > + hr_qp->state = roce_get_field(context->qp1c_bytes_4,
> > + QP1C_BYTES_4_QP_STATE_M,
> > + QP1C_BYTES_4_QP_STATE_S);
> > + qp_attr->qp_state = hr_qp->state;
> > + qp_attr->path_mtu = IB_MTU_256;
> > + qp_attr->path_mig_state = IB_MIG_ARMED;
> > + qp_attr->qkey = QKEY_VAL;
> > + qp_attr->rq_psn = 0;
> > + qp_attr->sq_psn = 0;
> > + qp_attr->dest_qp_num = 1;
> > + qp_attr->qp_access_flags = 6;
> > +
> > + qp_attr->pkey_index = roce_get_field(context->qp1c_bytes_20,
> > + QP1C_BYTES_20_PKEY_IDX_M,
> > + QP1C_BYTES_20_PKEY_IDX_S);
> > + qp_attr->port_num = hr_qp->port + 1;
> > + qp_attr->sq_draining = 0;
> > + qp_attr->max_rd_atomic = 0;
> > + qp_attr->max_dest_rd_atomic = 0;
> > + qp_attr->min_rnr_timer = 0;
> > + qp_attr->timeout = 0;
> > + qp_attr->retry_cnt = 0;
> > + qp_attr->rnr_retry = 0;
> > + qp_attr->alt_timeout = 0;
> > +
> > +done:
> > + qp_attr->cur_qp_state = qp_attr->qp_state;
> > + qp_attr->cap.max_recv_wr = hr_qp->rq.wqe_cnt;
> > + qp_attr->cap.max_recv_sge = hr_qp->rq.max_gs;
> > + qp_attr->cap.max_send_wr = hr_qp->sq.wqe_cnt;
> > + qp_attr->cap.max_send_sge = hr_qp->sq.max_gs;
> > + qp_attr->cap.max_inline_data = 0;
> > + qp_init_attr->cap = qp_attr->cap;
> > + qp_init_attr->create_flags = 0;
> > +
> > + mutex_unlock(&hr_qp->mutex);
> > + kfree(context);
> > +
> > + return 0;
> > +}
> > +
> > +static int hns_roce_v1_q_qp(struct ib_qp *ibqp, struct ib_qp_attr
> *qp_attr,
> > + int qp_attr_mask,
> > + struct ib_qp_init_attr *qp_init_attr)
> > {
> > struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device);
> > struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> > @@ -2767,6 +2841,15 @@ int hns_roce_v1_query_qp(struct ib_qp *ibqp,
> struct ib_qp_attr *qp_attr,
> > return ret;
> > }
> >
> > +int hns_roce_v1_query_qp(struct ib_qp *ibqp, struct ib_qp_attr
> *qp_attr,
> > + int qp_attr_mask, struct ib_qp_init_attr
> *qp_init_attr)
> > +{
> > + struct hns_roce_qp *hr_qp = to_hr_qp(ibqp);
> > +
> > + return hr_qp->doorbell_qpn <= 1 ?
> > + hns_roce_v1_q_sqp(ibqp, qp_attr, qp_attr_mask,
> qp_init_attr) :
> > + hns_roce_v1_q_qp(ibqp, qp_attr, qp_attr_mask,
> qp_init_attr);
> > +}
> > static void hns_roce_v1_destroy_qp_common(struct hns_roce_dev
> *hr_dev,
> > struct hns_roce_qp *hr_qp,
> > int is_user)
> > diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.h
> b/drivers/infiniband/hw/hns/hns_roce_hw_v1.h
> > index 539b0a3b..2e1878b 100644
> > --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.h
> > +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.h
> > @@ -480,13 +480,17 @@ struct hns_roce_sqp_context {
> > u32 qp1c_bytes_12;
> > u32 qp1c_bytes_16;
> > u32 qp1c_bytes_20;
> > - u32 qp1c_bytes_28;
> > u32 cur_rq_wqe_ba_l;
> > + u32 qp1c_bytes_28;
> > u32 qp1c_bytes_32;
> > u32 cur_sq_wqe_ba_l;
> > u32 qp1c_bytes_40;
> > };
> >
> > +#define QP1C_BYTES_4_QP_STATE_S 0
> > +#define QP1C_BYTES_4_QP_STATE_M \
> > + (((1UL << 3) - 1) << QP1C_BYTES_4_QP_STATE_S)
> > +
> > #define QP1C_BYTES_4_SQ_WQE_SHIFT_S 8
> > #define QP1C_BYTES_4_SQ_WQE_SHIFT_M \
> > (((1UL << 4) - 1) << QP1C_BYTES_4_SQ_WQE_SHIFT_S)
> >
^ permalink raw reply
* [Regression w/ patch] Restore network resistance to weird ICMP messages
From: Vicente Jiménez @ 2016-11-07 11:11 UTC (permalink / raw)
To: David S. Miller, Alexey Kuznetsov, James Morris,
Hideaki YOSHIFUJI, Patrick McHardy
Cc: netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2187 bytes --]
Handle weird ICMP fragmentation needed messages with next hop MTU
equal to (or exceeding) dropped packet size
Fixes: 46517008e116 ("ipv4: Kill ip_rt_frag_needed().")
In a large corporate network, we spotted this weird ICMP message after
a long troubleshooting. See attached capture file. Those ICMP "network
unreachable - fragmentation needed and don't fragment bit set"
messages are sent by a router that drop 1500 bytes IP packets and fill
the next hop MTU ICMP field with 1500.
Those messages cause the TCP connection to stall but only on newer
kernels. Older kernels set path MTU to 1492 and communicates
successfully.
After checking code and commit history, I spotted how commit
46517008e116 ("ipv4: Kill ip_rt_frag_needed().") from June 2012
changed ICMP messages handling by removing ip_rt_frag_needed function.
The relevant part of the ip_rt_frag_needed function that was removed is:
if (new_mtu < 68 || new_mtu >= old_mtu) {
/* BSD 4.2 derived systems incorrectly adjust
* tot_len by the IP header length, and report
* a zero MTU in the ICMP message.
*/
if (mtu == 0 &&
old_mtu >= 68 + (iph->ihl << 2))
old_mtu -= iph->ihl << 2;
mtu = guess_mtu(old_mtu);
}
This condition handled the cases when next hop MTU where zero (less
than 68). Now this is handled by the protocol and fixed by commit
68b7107b6298 "ipv4: icmp: Fix pMTU handling for rare case".
But the rarest case when (next hop MTU) new_mtu >= old_mtu (dropped
packet length) was also removed. This commit restores this check.
Instead of using a table lookup like function guess_mtu uses, it just
try to set the path MTU decrementing by 2 bytes the dropped packet
size.
In our case, setting the path MTU to just 1498 (one iteration) worked.
This solution should converge in any case to a good value by small
steps. I don't think there's a need to a more complex solution.
The patched kernel worked perfectly setting the path MTU to 1498 from
the initial default interface value of 1500. This time I don't have a
capture file from inside the affected center, but all received packed
had a maximum size of 1498.
--
cheers
vicente
[-- Attachment #2: ICMP discarting and sugesting 1500 2.pcapng --]
[-- Type: application/x-pcapng, Size: 89664 bytes --]
[-- Attachment #3: 0001-ipv4-icmp-Fix-pMTU-handling-for-rarest-case.patch --]
[-- Type: text/x-patch, Size: 1241 bytes --]
From bfc9a00e6b78d8eb60e46dacd7d761669d29a573 Mon Sep 17 00:00:00 2001
From: Vicente Jimenez Aguilar <googuy@gmail.com>
Date: Mon, 31 Oct 2016 13:10:29 +0100
Subject: [PATCH] ipv4: icmp: Fix pMTU handling for rarest case
Restore network resistance to weird ICMP fragmentation needed messages
with next hop MTU equal to (or exceeding) dropped packet size
Fixes: 46517008e116 ("ipv4: Kill ip_rt_frag_needed().")
Signed-off-by: Vicente Jimenez Aguilar <googuy@gmail.com>
---
net/ipv4/icmp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 38abe70..c0af1d2 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -776,6 +776,7 @@ static bool icmp_unreach(struct sk_buff *skb)
struct icmphdr *icmph;
struct net *net;
u32 info = 0;
+ unsigned short old_mtu;
net = dev_net(skb_dst(skb)->dev);
@@ -819,6 +820,12 @@ static bool icmp_unreach(struct sk_buff *skb)
/* fall through */
case 0:
info = ntohs(icmph->un.frag.mtu);
+ /* Handle weird case where next hop MTU is
+ * equal to or exceeding dropped packet size
+ */
+ old_mtu = ntohs(iph->tot_len);
+ if ( info >= old_mtu )
+ info = old_mtu - 2;
}
break;
case ICMP_SR_FAILED:
--
2.7.3
^ permalink raw reply related
* Re: [PATCH 00/12] xen: add common function for reading optional value
From: David Vrabel @ 2016-11-07 11:08 UTC (permalink / raw)
To: Juergen Gross, linux-kernel, xen-devel
Cc: boris.ostrovsky, konrad.wilk, roger.pau, peterhuewe, tpmdd,
jarkko.sakkinen, jgunthorpe, tpmdd-devel, dmitry.torokhov,
linux-input, wei.liu2, paul.durrant, netdev, bhelgaas, linux-pci,
tomi.valkeinen, linux-fbdev
In-Reply-To: <1477932510-28594-1-git-send-email-jgross@suse.com>
On 31/10/16 16:48, Juergen Gross wrote:
> There are multiple instances of code reading an optional unsigned
> parameter from Xenstore via xenbus_scanf(). Instead of repeating the
> same code over and over add a service function doing the job and
> replace the call of xenbus_scanf() with the call of the new function
> where appropriate.
Acked-by: David Vrabel <david.vrabel@citrix.com>
Please queue for the next release.
David
^ permalink raw reply
* Re: [PATCH] usbnet: prevent device rpm suspend in usbnet_probe function
From: Oliver Neukum @ 2016-11-07 11:02 UTC (permalink / raw)
To: Kai-Heng Feng; +Cc: linux-kernel, linux-usb, netdev
In-Reply-To: <20161104095735.21071-1-kai.heng.feng@canonical.com>
On Fri, 2016-11-04 at 17:57 +0800, Kai-Heng Feng wrote:
> Sometimes cdc_mbim failed to probe if runtime pm is enabled:
> [ 9.305626] cdc_mbim: probe of 2-2:1.12 failed with error -22
>
> This can be solved by increase its pm usage counter.
>
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
For the record:
NAK. This fixes a symptom. If this patch helps something is broken in
device core. We need to find that.
Regards
Oliver
^ permalink raw reply
* RE: Coding Style: Reverse XMAS tree declarations ?
From: David Laight @ 2016-11-07 11:00 UTC (permalink / raw)
To: 'Lino Sanfilippo', Joe Perches, David Miller,
lsanfil@marvell.com
Cc: madalin.bucur@nxp.com, akpm@linux-foundation.org, corbet@lwn.net,
netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org, oss@buserror.net,
ppc@mindchasers.com, pebolle@tiscali.nl,
joakim.tjernlund@transmode.se, Randy Dunlap
In-Reply-To: <31ace8dd-1e42-2762-6367-028068d4d816@gmx.de>
From: Lino Sanfilippo
> Sent: 04 November 2016 20:07
...
> In this case it is IMHO rather the declaration + initialization that makes
> "bar" hard to find at one glance, not the use of RXT. You could do something like
>
> [longish list of reverse xmas tree identifiers...]
> struct foobarbaz *qux;
> struct foo *bar;
>
> bar = longish_function(args, ...);
>
> to increase readability.
>
> Personally I find it more readable to always use a separate line for initializations
> by means of functions (regardless of whether the RXT scheme is used or not).
I find it best to only use initialisers for 'variables' that are (mostly) constant.
If something need to be set to NULL in case a search fails, set it to NULL
just before the loop.
Don't put initialisation on the declaration 'because you can'.
Difficulty in spotting the type of a variable is why (IMHO) you should
but all declarations at the top of a function
(except, maybe, temporaries needed for a few lines).
David
^ permalink raw reply
* Re: stmmac/RTL8211F/Meson GXBB: TX throughput problems
From: Giuseppe CAVALLARO @ 2016-11-07 10:59 UTC (permalink / raw)
To: Jerome Brunet, André Roth, Martin Blumenstingl,
Alexandre Torgue
Cc: Johnson Leung, linux-amlogic, netdev
In-Reply-To: <1478192276.6632.34.camel@baylibre.com>
Hi Jerome
We met, on some platform, problems that, in a glance,
look similar to yours and those were related to EEE and
LPI interrupts.
We had a subset of patches to disable EEE but, indeed,
if you disable from PHY, the STMMAC will never act
the protocol. We can provide you these patches... I will
ask Alex to decide how to proceed.
There is a issue on lpi timer and I have another patch to
share but I am not sure this can help.
In sum, if EEE is a suspected problem we can share and review
some patches.
In the meantime, I will read again the thread just to see if
there is something I am missing.
Regards
Peppe
On 11/3/2016 5:57 PM, Jerome Brunet wrote:
> On Mon, 2016-10-31 at 11:25 +0100, André Roth wrote:
>> Hi all,
>>
>>>
>>> on my device this results in:
>>> [0xc9410018] = 0x2000000
>>> [0xc9410030] = 0x0
>>> [0xc941003c] = 0x0
>>> [0xc9411000] = 0x1100802
>>> [0xc9411018] = 0x2202006
>>> [0xc9411028] = 0x0
>>>
>>> maybe someone else could try the command from above on his device
>>> (running the original Amlogic kernel).
>>
>> those registers have the same value on an original image from
>> hardkernel:
>>
>> Linux odroid64 3.14.65-65 #1 SMP PREEMPT Sat May 28
>> 02:50:51 BRT 2016 aarch64 aarch64 aarch64 GNU/Linux
>>
>>>
>>> please also state if ethernet is working properly on the original
>>> kernel (and preferably which device/board this is).
>>
>> yes, the ethernet works flawless in 100 and 1000 Mbit/s on the 3.14
>> kernel.
>
> Andre, the 3.14 kernel you are talking, is it this one ? :
> https://github.com/hardkernel/linux/tree/odroidc2-3.14.y
>
> Because in drivers/net/phy/realtek.c, they disable EEE, but
> also 1000Base-T Full Duplex advertisement ?
>
> + /* disable 1000m adv*/
> + val = phy_read(phydev, 0x9);
> + phy_write(phydev, 0x9, val&(~(1<<9)));
>
> If this is the kernel you are running, you should not be able to have
> ethernet at 1000MB/s ? Or is it in half duplex mode ?
>
>>
>> I can now confirm that both 100 and 1000 Mbit/s do not work properly
>> on the 4.8/integ branch. the network connection is interrupted after
>> some outbound traffic. it can be recovered by running a ifdown/ifup
>> which restarts dhclient, which I think is able to somehow reset the
>> interface.
>>
>> Anything I can help to debug the issue further ?
>>
>> Regards,
>>
>> André
>>
>>
>>
>> _______________________________________________
>> linux-amlogic mailing list
>> linux-amlogic@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-amlogic
>
^ permalink raw reply
* Re: [PATCH] usbnet: prevent device rpm suspend in usbnet_probe function
From: Oliver Neukum @ 2016-11-07 10:32 UTC (permalink / raw)
To: Alan Stern; +Cc: Kai-Heng Feng, linux-kernel, linux-usb, netdev
In-Reply-To: <Pine.LNX.4.44L0.1611040923110.6787-100000@netrider.rowland.org>
On Fri, 2016-11-04 at 09:26 -0400, Alan Stern wrote:
> On Fri, 4 Nov 2016, Kai-Heng Feng wrote:
>
> > Sometimes cdc_mbim failed to probe if runtime pm is enabled:
> > [ 9.305626] cdc_mbim: probe of 2-2:1.12 failed with error -22
> >
> > This can be solved by increase its pm usage counter.
>
> This should not be needed. The USB core increments the PM usage
> counter of a device before probing its interfaces.
Indeed. Yet we have experimental evidence.
Kai-Heng Feng, could you please enable dynamic debugging
for
drivers/usb/core/driver.c
so that we can see what is going on with the usage counters?
Regards
Oliver
^ permalink raw reply
* [PATCH] bna: Add synchronization for tx ring.
From: Benjamin Poirier @ 2016-11-07 9:57 UTC (permalink / raw)
To: netdev; +Cc: Rasesh Mody, Sudarsana Kalluru, Dept-GELinuxNICDev
We received two reports of BUG_ON in bnad_txcmpl_process() where
hw_consumer_index appeared to be ahead of producer_index. Out of order
write/read of these variables could explain these reports.
bnad_start_xmit(), as a producer of tx descriptors, has a few memory
barriers sprinkled around writes to producer_index and the device's
doorbell but they're not paired with anything in bnad_txcmpl_process(), a
consumer.
Since we are synchronizing with a device, we must use mandatory barriers,
not smp_*. Also, I didn't see the purpose of the last smp_mb() in
bnad_start_xmit().
Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
---
drivers/net/ethernet/brocade/bna/bnad.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index f9df4b5a..f42f672 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -177,6 +177,7 @@ bnad_txcmpl_process(struct bnad *bnad, struct bna_tcb *tcb)
return 0;
hw_cons = *(tcb->hw_consumer_index);
+ rmb();
cons = tcb->consumer_index;
q_depth = tcb->q_depth;
@@ -3094,7 +3095,7 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
BNA_QE_INDX_INC(prod, q_depth);
tcb->producer_index = prod;
- smp_mb();
+ wmb();
if (unlikely(!test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags)))
return NETDEV_TX_OK;
@@ -3102,7 +3103,6 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
skb_tx_timestamp(skb);
bna_txq_prod_indx_doorbell(tcb);
- smp_mb();
return NETDEV_TX_OK;
}
--
2.9.3
^ permalink raw reply related
* Re: [PATCH net-next 06/11] net: l3mdev: remove redundant calls
From: Lorenzo Colitti @ 2016-11-07 10:13 UTC (permalink / raw)
To: David Ahern; +Cc: netdev@vger.kernel.org, shm
In-Reply-To: <1473534602-23602-7-git-send-email-dsa@cumulusnetworks.com>
On Sun, Sep 11, 2016 at 4:09 AM, David Ahern <dsa@cumulusnetworks.com> wrote:
> A previous patch added l3mdev flow update making these hooks
> redundant. Remove them.
> [...]
> @@ -1582,8 +1582,7 @@ void ip_send_unicast_reply(struct sock *sk, struct sk_buff *skb,
> }
>
> oif = arg->bound_dev_if;
> - if (!oif && netif_index_is_l3_master(net, skb->skb_iif))
> - oif = skb->skb_iif;
> + oif = oif ? : skb->skb_iif;
>
> flowi4_init_output(&fl4, oif,
> IP4_REPLY_MARK(net, skb->mark),
This broke one of our unit tests. The expectation in the test was that
the RST replying to a SYN sent to a closed port should be generated
with oif=0. In other words it should not prefer the interface where
the SYN came in on, but instead should follow whatever the routing
table says it should do.
As far as I can tell this changed ~2 months ago, on 2016-09-10, when
e0d56fd was applied (step #2 below). Previously, oif was either a
passed-in sk_bound_dev_if or 0. Specifically:
1. "f7ba868 net: Use VRF index for oif in ip_send_unicast_reply" set
oif if the interface was an L3 master.
- flowi4_init_output(&fl4, arg->bound_dev_if,
+ oif = arg->bound_dev_if;
+ if (!oif && netif_index_is_vrf(net, skb->skb_iif))
+ oif = skb->skb_iif;
+
+ flowi4_init_output(&fl4, oif,
2. "e0d56fd net: l3mdev: remove redundant calls" removed the
netif_index_is_l3_master call and just set oif to skb_iif. This
changed the behaviour:
oif = arg->bound_dev_if;
- if (!oif && netif_index_is_l3_master(net, skb->skb_iif))
- oif = skb->skb_iif;
+ oif = oif ? : skb->skb_iif;
3. Later, netif_index_is_l3_master was removed by 19664c6a0009 ("net:
l3mdev: Remove netif_index_is_l3_master"). The removal was reverted by
"6104e11 net: ipv4: Do not drop to make_route if oif is l3mdev". But
this revert didn't change ip_send_unicast_reply back to what it was.
What should we do here? It would seem that now that
netif_index_is_l3_master has been resurrected, it's appropriate to use
it here as well. The user-visible behaviour changed only two months
ago. Unless we think that RSTs should always mirror the iif, in which
case I can change our tests accordingly.
Cheers,
Lorenzo
^ permalink raw reply
* Re: [PATCH for-next 10/11] IB/hns: Implement the add_gid/del_gid and optimize the GIDs management
From: Shaobo Xu @ 2016-11-07 10:04 UTC (permalink / raw)
To: Anurup M, Salil Mehta, dledford-H+wXaHxf7aLQT0dZR+AlfA
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
mehta.salil.lnk-Re5JQEeQqe8AvxtiuMwx3w,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linuxarm-hv44wF8Li93QT0dZR+AlfA
In-Reply-To: <58203884.6040808-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
On 2016/11/7 16:17, Anurup M wrote:
>
>
> On 11/4/2016 10:06 PM, Salil Mehta wrote:
>> From: Shaobo Xu <xushaobo2-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>>
>> IB core has implemented the calculation of GIDs and the management
>> of GID tables, and it is now responsible to supply query function
>> for GIDs. So the calculation of GIDs and the management of GID
>> tables in the RoCE driver is redundant.
>>
>> The patch is to implement the add_gid/del_gid to set the GIDs in
>> the RoCE driver, remove the redundant calculation and management of
>> GIDs in the notifier call of the net device and the inet, and
>> update the query_gid.
>>
>> Signed-off-by: Shaobo Xu <xushaobo2-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> Reviewed-by: Wei Hu (Xavier) <xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> Signed-off-by: Salil Mehta <salil.mehta-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> ---
>> drivers/infiniband/hw/hns/hns_roce_device.h | 2 -
>> drivers/infiniband/hw/hns/hns_roce_main.c | 270 +++++----------------------
>> 2 files changed, 48 insertions(+), 224 deletions(-)
>>
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
>> index 593a42a..9ef1cc3 100644
>> --- a/drivers/infiniband/hw/hns/hns_roce_device.h
>> +++ b/drivers/infiniband/hw/hns/hns_roce_device.h
>> @@ -429,8 +429,6 @@ struct hns_roce_ib_iboe {
>> struct net_device *netdevs[HNS_ROCE_MAX_PORTS];
>> struct notifier_block nb;
>> struct notifier_block nb_inet;
>> - /* 16 GID is shared by 6 port in v1 engine. */
>> - union ib_gid gid_table[HNS_ROCE_MAX_GID_NUM];
>> u8 phy_port[HNS_ROCE_MAX_PORTS];
>> };
>>
>> diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
>> index 6770171..795ef97 100644
>> --- a/drivers/infiniband/hw/hns/hns_roce_main.c
>> +++ b/drivers/infiniband/hw/hns/hns_roce_main.c
>> @@ -35,52 +35,13 @@
>> #include <rdma/ib_addr.h>
>> #include <rdma/ib_smi.h>
>> #include <rdma/ib_user_verbs.h>
>> +#include <rdma/ib_cache.h>
>> #include "hns_roce_common.h"
>> #include "hns_roce_device.h"
>> #include "hns_roce_user.h"
>> #include "hns_roce_hem.h"
>>
>> /**
>> - * hns_roce_addrconf_ifid_eui48 - Get default gid.
>> - * @eui: eui.
>> - * @vlan_id: gid
>> - * @dev: net device
>> - * Description:
>> - * MAC convert to GID
>> - * gid[0..7] = fe80 0000 0000 0000
>> - * gid[8] = mac[0] ^ 2
>> - * gid[9] = mac[1]
>> - * gid[10] = mac[2]
>> - * gid[11] = ff (VLAN ID high byte (4 MS bits))
>> - * gid[12] = fe (VLAN ID low byte)
>> - * gid[13] = mac[3]
>> - * gid[14] = mac[4]
>> - * gid[15] = mac[5]
>> - */
>> -static void hns_roce_addrconf_ifid_eui48(u8 *eui, u16 vlan_id,
>> - struct net_device *dev)
>> -{
>> - memcpy(eui, dev->dev_addr, 3);
>> - memcpy(eui + 5, dev->dev_addr + 3, 3);
>> - if (vlan_id < 0x1000) {
>> - eui[3] = vlan_id >> 8;
>> - eui[4] = vlan_id & 0xff;
>> - } else {
>> - eui[3] = 0xff;
>> - eui[4] = 0xfe;
>> - }
>> - eui[0] ^= 2;
>> -}
>> -
>> -static void hns_roce_make_default_gid(struct net_device *dev, union ib_gid *gid)
>> -{
>> - memset(gid, 0, sizeof(*gid));
>> - gid->raw[0] = 0xFE;
>> - gid->raw[1] = 0x80;
>> - hns_roce_addrconf_ifid_eui48(&gid->raw[8], 0xffff, dev);
>> -}
>> -
>> -/**
>> * hns_get_gid_index - Get gid index.
>> * @hr_dev: pointer to structure hns_roce_dev.
>> * @port: port, value range: 0 ~ MAX
>> @@ -96,30 +57,6 @@ int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index)
>> return gid_index * hr_dev->caps.num_ports + port;
>> }
>>
>> -static int hns_roce_set_gid(struct hns_roce_dev *hr_dev, u8 port, int gid_index,
>> - union ib_gid *gid)
>> -{
>> - struct device *dev = &hr_dev->pdev->dev;
>> - u8 gid_idx = 0;
>> -
>> - if (gid_index >= hr_dev->caps.gid_table_len[port]) {
>> - dev_err(dev, "gid_index %d illegal, port %d gid range: 0~%d\n",
>> - gid_index, port, hr_dev->caps.gid_table_len[port] - 1);
>> - return -EINVAL;
>> - }
>> -
>> - gid_idx = hns_get_gid_index(hr_dev, port, gid_index);
>> -
>> - if (!memcmp(gid, &hr_dev->iboe.gid_table[gid_idx], sizeof(*gid)))
>> - return -EINVAL;
>> -
>> - memcpy(&hr_dev->iboe.gid_table[gid_idx], gid, sizeof(*gid));
>> -
>> - hr_dev->hw->set_gid(hr_dev, port, gid_index, gid);
>> -
>> - return 0;
>> -}
>> -
>> static void hns_roce_set_mac(struct hns_roce_dev *hr_dev, u8 port, u8 *addr)
>> {
>> u8 phy_port;
>> @@ -147,15 +84,44 @@ static void hns_roce_set_mtu(struct hns_roce_dev *hr_dev, u8 port, int mtu)
>> hr_dev->hw->set_mtu(hr_dev, phy_port, tmp);
>> }
>>
>> -static void hns_roce_update_gids(struct hns_roce_dev *hr_dev, int port)
>> +static int hns_roce_add_gid(struct ib_device *device, u8 port_num,
>> + unsigned int index, const union ib_gid *gid,
>> + const struct ib_gid_attr *attr, void **context)
>> +{
>> + struct hns_roce_dev *hr_dev = to_hr_dev(device);
>> + u8 port = port_num - 1;
>> + unsigned long flags;
>> +
>> + if (port >= hr_dev->caps.num_ports)
>> + return -EINVAL;
>> +
>> + spin_lock_irqsave(&hr_dev->iboe.lock, flags);
>> +
>> + hr_dev->hw->set_gid(hr_dev, port, index, (union ib_gid *)gid);
>> +
>> + spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
>> +
>> + return 0;
>> +}
>> +
>> +static int hns_roce_del_gid(struct ib_device *device, u8 port_num,
>> + unsigned int index, void **context)
>> {
>> - struct ib_event event;
>> + struct hns_roce_dev *hr_dev = to_hr_dev(device);
>> + union ib_gid zgid = { {0} };
>> + u8 port = port_num - 1;
>> + unsigned long flags;
>> +
>> + if (port >= hr_dev->caps.num_ports)
>> + return -EINVAL;
>>
>> - /* Refresh gid in ib_cache */
>> - event.device = &hr_dev->ib_dev;
>> - event.element.port_num = port + 1;
>> - event.event = IB_EVENT_GID_CHANGE;
>> - ib_dispatch_event(&event);
>> + spin_lock_irqsave(&hr_dev->iboe.lock, flags);
>> +
>> + hr_dev->hw->set_gid(hr_dev, port, index, &zgid);
> zgid has value zero. and after this call, where is zgid used?
While deleting the GIDs of the specified port, it needs to set zgid to the port GID configure register,
which means no GID to this port.
Best Regards,
>> +
>> + spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
>> +
>> + return 0;
>> }
>>
>> static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
>> @@ -164,8 +130,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
>> struct device *dev = &hr_dev->pdev->dev;
>> struct net_device *netdev;
>> unsigned long flags;
>> - union ib_gid gid;
>> - int ret = 0;
>>
>> netdev = hr_dev->iboe.netdevs[port];
>> if (!netdev) {
>> @@ -181,10 +145,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
>> case NETDEV_REGISTER:
>> case NETDEV_CHANGEADDR:
>> hns_roce_set_mac(hr_dev, port, netdev->dev_addr);
>> - hns_roce_make_default_gid(netdev, &gid);
>> - ret = hns_roce_set_gid(hr_dev, port, 0, &gid);
>> - if (!ret)
>> - hns_roce_update_gids(hr_dev, port);
>> break;
>> case NETDEV_DOWN:
>> /*
>> @@ -197,7 +157,7 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
>> }
>>
>> spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
>> - return ret;
>> + return 0;
>> }
>>
>> static int hns_roce_netdev_event(struct notifier_block *self,
>> @@ -224,118 +184,17 @@ static int hns_roce_netdev_event(struct notifier_block *self,
>> return NOTIFY_DONE;
>> }
>>
>> -static void hns_roce_addr_event(int event, struct net_device *event_netdev,
>> - struct hns_roce_dev *hr_dev, union ib_gid *gid)
>> -{
>> - struct hns_roce_ib_iboe *iboe = NULL;
>> - int gid_table_len = 0;
>> - unsigned long flags;
>> - union ib_gid zgid;
>> - u8 gid_idx = 0;
>> - u8 port = 0;
>> - int i = 0;
>> - int free;
>> - struct net_device *real_dev = rdma_vlan_dev_real_dev(event_netdev) ?
>> - rdma_vlan_dev_real_dev(event_netdev) :
>> - event_netdev;
>> -
>> - if (event != NETDEV_UP && event != NETDEV_DOWN)
>> - return;
>> -
>> - iboe = &hr_dev->iboe;
>> - while (port < hr_dev->caps.num_ports) {
>> - if (real_dev == iboe->netdevs[port])
>> - break;
>> - port++;
>> - }
>> -
>> - if (port >= hr_dev->caps.num_ports) {
>> - dev_dbg(&hr_dev->pdev->dev, "can't find netdev\n");
>> - return;
>> - }
>> -
>> - memset(zgid.raw, 0, sizeof(zgid.raw));
>> - free = -1;
>> - gid_table_len = hr_dev->caps.gid_table_len[port];
>> -
>> - spin_lock_irqsave(&hr_dev->iboe.lock, flags);
>> -
>> - for (i = 0; i < gid_table_len; i++) {
>> - gid_idx = hns_get_gid_index(hr_dev, port, i);
>> - if (!memcmp(gid->raw, iboe->gid_table[gid_idx].raw,
>> - sizeof(gid->raw)))
>> - break;
>> - if (free < 0 && !memcmp(zgid.raw,
>> - iboe->gid_table[gid_idx].raw, sizeof(zgid.raw)))
>> - free = i;
>> - }
>> -
>> - if (i >= gid_table_len) {
>> - if (free < 0) {
>> - spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
>> - dev_dbg(&hr_dev->pdev->dev,
>> - "gid_index overflow, port(%d)\n", port);
>> - return;
>> - }
>> - if (!hns_roce_set_gid(hr_dev, port, free, gid))
>> - hns_roce_update_gids(hr_dev, port);
>> - } else if (event == NETDEV_DOWN) {
>> - if (!hns_roce_set_gid(hr_dev, port, i, &zgid))
>> - hns_roce_update_gids(hr_dev, port);
>> - }
>> -
>> - spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
>> -}
>> -
>> -static int hns_roce_inet_event(struct notifier_block *self, unsigned long event,
>> - void *ptr)
>> -{
>> - struct in_ifaddr *ifa = ptr;
>> - struct hns_roce_dev *hr_dev;
>> - struct net_device *dev = ifa->ifa_dev->dev;
>> - union ib_gid gid;
>> -
>> - ipv6_addr_set_v4mapped(ifa->ifa_address, (struct in6_addr *)&gid);
>> -
>> - hr_dev = container_of(self, struct hns_roce_dev, iboe.nb_inet);
>> -
>> - hns_roce_addr_event(event, dev, hr_dev, &gid);
>> -
>> - return NOTIFY_DONE;
>> -}
>> -
>> -static int hns_roce_setup_mtu_gids(struct hns_roce_dev *hr_dev)
>> +static int hns_roce_setup_mtu_mac(struct hns_roce_dev *hr_dev)
>> {
>> - struct in_ifaddr *ifa_list = NULL;
>> - union ib_gid gid = {{0} };
>> - u32 ipaddr = 0;
>> - int index = 0;
>> - int ret = 0;
>> - u8 i = 0;
>> + u8 i;
>>
>> for (i = 0; i < hr_dev->caps.num_ports; i++) {
>> hns_roce_set_mtu(hr_dev, i,
>> ib_mtu_enum_to_int(hr_dev->caps.max_mtu));
>> hns_roce_set_mac(hr_dev, i, hr_dev->iboe.netdevs[i]->dev_addr);
>> -
>> - if (hr_dev->iboe.netdevs[i]->ip_ptr) {
>> - ifa_list = hr_dev->iboe.netdevs[i]->ip_ptr->ifa_list;
>> - index = 1;
>> - while (ifa_list) {
>> - ipaddr = ifa_list->ifa_address;
>> - ipv6_addr_set_v4mapped(ipaddr,
>> - (struct in6_addr *)&gid);
>> - ret = hns_roce_set_gid(hr_dev, i, index, &gid);
>> - if (ret)
>> - break;
>> - index++;
>> - ifa_list = ifa_list->ifa_next;
>> - }
>> - hns_roce_update_gids(hr_dev, i);
>> - }
>> }
>>
>> - return ret;
>> + return 0;
>> }
>>
>> static int hns_roce_query_device(struct ib_device *ib_dev,
>> @@ -444,31 +303,6 @@ static enum rdma_link_layer hns_roce_get_link_layer(struct ib_device *device,
>> static int hns_roce_query_gid(struct ib_device *ib_dev, u8 port_num, int index,
>> union ib_gid *gid)
>> {
>> - struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);
>> - struct device *dev = &hr_dev->pdev->dev;
>> - u8 gid_idx = 0;
>> - u8 port;
>> -
>> - if (port_num < 1 || port_num > hr_dev->caps.num_ports ||
>> - index >= hr_dev->caps.gid_table_len[port_num - 1]) {
>> - dev_err(dev,
>> - "port_num %d index %d illegal! correct range: port_num 1~%d index 0~%d!\n",
>> - port_num, index, hr_dev->caps.num_ports,
>> - hr_dev->caps.gid_table_len[port_num - 1] - 1);
>> - return -EINVAL;
>> - }
>> -
>> - port = port_num - 1;
>> - gid_idx = hns_get_gid_index(hr_dev, port, index);
>> - if (gid_idx >= HNS_ROCE_MAX_GID_NUM) {
>> - dev_err(dev, "port_num %d index %d illegal! total gid num %d!\n",
>> - port_num, index, HNS_ROCE_MAX_GID_NUM);
>> - return -EINVAL;
>> - }
>> -
>> - memcpy(gid->raw, hr_dev->iboe.gid_table[gid_idx].raw,
>> - HNS_ROCE_GID_SIZE);
>> -
>> return 0;
>> }
>>
>> @@ -646,6 +480,8 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
>> ib_dev->get_link_layer = hns_roce_get_link_layer;
>> ib_dev->get_netdev = hns_roce_get_netdev;
>> ib_dev->query_gid = hns_roce_query_gid;
>> + ib_dev->add_gid = hns_roce_add_gid;
>> + ib_dev->del_gid = hns_roce_del_gid;
>> ib_dev->query_pkey = hns_roce_query_pkey;
>> ib_dev->alloc_ucontext = hns_roce_alloc_ucontext;
>> ib_dev->dealloc_ucontext = hns_roce_dealloc_ucontext;
>> @@ -688,32 +524,22 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
>> return ret;
>> }
>>
>> - ret = hns_roce_setup_mtu_gids(hr_dev);
>> + ret = hns_roce_setup_mtu_mac(hr_dev);
>> if (ret) {
>> - dev_err(dev, "roce_setup_mtu_gids failed!\n");
>> - goto error_failed_setup_mtu_gids;
>> + dev_err(dev, "setup_mtu_mac failed!\n");
>> + goto error_failed_setup_mtu_mac;
>> }
>>
>> iboe->nb.notifier_call = hns_roce_netdev_event;
>> ret = register_netdevice_notifier(&iboe->nb);
>> if (ret) {
>> dev_err(dev, "register_netdevice_notifier failed!\n");
>> - goto error_failed_setup_mtu_gids;
>> - }
>> -
>> - iboe->nb_inet.notifier_call = hns_roce_inet_event;
>> - ret = register_inetaddr_notifier(&iboe->nb_inet);
>> - if (ret) {
>> - dev_err(dev, "register inet addr notifier failed!\n");
>> - goto error_failed_register_inetaddr_notifier;
>> + goto error_failed_setup_mtu_mac;
>> }
>>
>> return 0;
>>
>> -error_failed_register_inetaddr_notifier:
>> - unregister_netdevice_notifier(&iboe->nb);
>> -
>> -error_failed_setup_mtu_gids:
>> +error_failed_setup_mtu_mac:
>> ib_unregister_device(ib_dev);
>>
>> return ret;
>>
>
> _______________________________________________
> linuxarm mailing list
> linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org
> http://rnd-openeuler.huawei.com/mailman/listinfo/linuxarm
>
> .
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v3 2/2] net: ethernet: nb8800: handle all RGMII definitions
From: Sebastian Frias @ 2016-11-07 10:01 UTC (permalink / raw)
To: Måns Rullgård; +Cc: David S. Miller, netdev, LKML, Mason, Andrew Lunn
In-Reply-To: <yw1xoa1uhylu.fsf@unicorn.mansr.com>
Hi Måns,
On 11/05/2016 01:58 PM, Måns Rullgård wrote:
>> if (gigabit) {
>> - if (priv->phy_mode == PHY_INTERFACE_MODE_RGMII)
>> + if (phy_interface_is_rgmii(phydev))
>> mac_mode |= RGMII_MODE;
>>
>> mac_mode |= GMAC_MODE;
>
> As I said before, this part can/should be applied separately, although
> personally I probably wouldn't have bothered adding a single-use variable.
It was for consistency with other functions that use 'phydev', but I don't
mind making the changes.
Just to be clear, when you say "can/should be applied separately", do you
mean that this patch should not be part of a series, and that I should split
the series into separate patches?
Best regards,
Sebastian
^ permalink raw reply
* Re: [lkp] [net] af1fee9821: BUG:spinlock_trylock_failure_on_UP_on_CPU
From: Allan W. Nielsen @ 2016-11-07 9:55 UTC (permalink / raw)
To: Andrew Lunn
Cc: kernel test robot, Raju Lakkaraju, David S. Miller, LKML, netdev,
lkp
In-Reply-To: <20161107093148.GA27001@lunn.ch>
Hi,
I'm quite surprised too.
I asked Raju to see if he can re-produce, and then try again with the
microsemi_phy disabled and see it that makes a difference.
If Raju gets stuck on this, then I will try to help our during the after-noon.
/Allan
On 07/11/16 10:31, Andrew Lunn wrote:
> EXTERNAL EMAIL
>
>
> On Mon, Nov 07, 2016 at 10:26:28AM +0800, kernel test robot wrote:
> >
> > FYI, we noticed the following commit:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
> > commit af1fee98219992ba2c12441a447719652ed7e983 ("net: phy: Add support for Microsemi VSC 8530/40 Fast Ethernet PHY")
>
> Humm, interesting. I've no idea how this patch can trigger such a
> warning. The USB gadget does not have an Ethernet PHY, let alone a
> Microsemi 8530/40 Fast Ethernet PHY this patch adds.
>
> However, it seems nicely documented how to reproduce this. Allan, can
> you setup such a system? Reproduce it, then revert the change and see
> if it still happens.
>
> Andrew
^ permalink raw reply
* Re: [lkp] [net] af1fee9821: BUG:spinlock_trylock_failure_on_UP_on_CPU
From: Andrew Lunn @ 2016-11-07 9:31 UTC (permalink / raw)
To: kernel test robot
Cc: Raju Lakkaraju, David S. Miller, Allan W. Nielsen, LKML, netdev,
lkp
In-Reply-To: <20161107022628.GA21529@yexl-desktop>
On Mon, Nov 07, 2016 at 10:26:28AM +0800, kernel test robot wrote:
>
> FYI, we noticed the following commit:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
> commit af1fee98219992ba2c12441a447719652ed7e983 ("net: phy: Add support for Microsemi VSC 8530/40 Fast Ethernet PHY")
Humm, interesting. I've no idea how this patch can trigger such a
warning. The USB gadget does not have an Ethernet PHY, let alone a
Microsemi 8530/40 Fast Ethernet PHY this patch adds.
However, it seems nicely documented how to reproduce this. Allan, can
you setup such a system? Reproduce it, then revert the change and see
if it still happens.
Andrew
^ permalink raw reply
* Re: [PATCH] virtio-net: drop legacy features in virtio 1 mode
From: Jason Wang @ 2016-11-07 9:17 UTC (permalink / raw)
To: Michael S. Tsirkin, linux-kernel; +Cc: netdev, stable, virtualization
In-Reply-To: <1478256865-29003-1-git-send-email-mst@redhat.com>
On 2016年11月04日 18:55, Michael S. Tsirkin wrote:
> Virtio 1.0 spec says VIRTIO_F_ANY_LAYOUT and VIRTIO_NET_F_GSO are
> legacy-only feature bits. Do not negotiate them in virtio 1 mode. Note
> this is a spec violation so we need to backport it to stable/downstream
> kernels.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/net/virtio_net.c | 30 ++++++++++++++++++++----------
> 1 file changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7a00365..b19fb4d 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2089,23 +2089,33 @@ static struct virtio_device_id id_table[] = {
> { 0 },
> };
>
> +#define VIRTNET_FEATURES \
> + VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM, \
> + VIRTIO_NET_F_MAC, \
> + VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, \
> + VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, \
> + VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, \
> + VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, \
> + VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, \
> + VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, \
> + VIRTIO_NET_F_CTRL_MAC_ADDR, \
> + VIRTIO_NET_F_MTU
> +
> static unsigned int features[] = {
> - VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
> - VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
> - VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
> - VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
> - VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
> - VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
> - VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
> - VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,
> - VIRTIO_NET_F_CTRL_MAC_ADDR,
> + VIRTNET_FEATURES,
> +};
> +
> +static unsigned int features_legacy[] = {
> + VIRTNET_FEATURES,
> + VIRTIO_NET_F_GSO,
> VIRTIO_F_ANY_LAYOUT,
> - VIRTIO_NET_F_MTU,
> };
>
> static struct virtio_driver virtio_net_driver = {
> .feature_table = features,
> .feature_table_size = ARRAY_SIZE(features),
> + .feature_table_legacy = features_legacy,
> + .feature_table_size_legacy = ARRAY_SIZE(features_legacy),
> .driver.name = KBUILD_MODNAME,
> .driver.owner = THIS_MODULE,
> .id_table = id_table,
Acked-by: Jason Wang <jasowang@redhat.com>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* Re: [PATCH for-next 10/11] IB/hns: Implement the add_gid/del_gid and optimize the GIDs management
From: Anurup M @ 2016-11-07 8:17 UTC (permalink / raw)
To: Salil Mehta, dledford
Cc: linux-rdma, netdev, mehta.salil.lnk, linux-kernel, linuxarm
In-Reply-To: <20161104163633.141880-11-salil.mehta@huawei.com>
On 11/4/2016 10:06 PM, Salil Mehta wrote:
> From: Shaobo Xu <xushaobo2@huawei.com>
>
> IB core has implemented the calculation of GIDs and the management
> of GID tables, and it is now responsible to supply query function
> for GIDs. So the calculation of GIDs and the management of GID
> tables in the RoCE driver is redundant.
>
> The patch is to implement the add_gid/del_gid to set the GIDs in
> the RoCE driver, remove the redundant calculation and management of
> GIDs in the notifier call of the net device and the inet, and
> update the query_gid.
>
> Signed-off-by: Shaobo Xu <xushaobo2@huawei.com>
> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
> ---
> drivers/infiniband/hw/hns/hns_roce_device.h | 2 -
> drivers/infiniband/hw/hns/hns_roce_main.c | 270 +++++----------------------
> 2 files changed, 48 insertions(+), 224 deletions(-)
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h
> index 593a42a..9ef1cc3 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_device.h
> +++ b/drivers/infiniband/hw/hns/hns_roce_device.h
> @@ -429,8 +429,6 @@ struct hns_roce_ib_iboe {
> struct net_device *netdevs[HNS_ROCE_MAX_PORTS];
> struct notifier_block nb;
> struct notifier_block nb_inet;
> - /* 16 GID is shared by 6 port in v1 engine. */
> - union ib_gid gid_table[HNS_ROCE_MAX_GID_NUM];
> u8 phy_port[HNS_ROCE_MAX_PORTS];
> };
>
> diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c
> index 6770171..795ef97 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_main.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_main.c
> @@ -35,52 +35,13 @@
> #include <rdma/ib_addr.h>
> #include <rdma/ib_smi.h>
> #include <rdma/ib_user_verbs.h>
> +#include <rdma/ib_cache.h>
> #include "hns_roce_common.h"
> #include "hns_roce_device.h"
> #include "hns_roce_user.h"
> #include "hns_roce_hem.h"
>
> /**
> - * hns_roce_addrconf_ifid_eui48 - Get default gid.
> - * @eui: eui.
> - * @vlan_id: gid
> - * @dev: net device
> - * Description:
> - * MAC convert to GID
> - * gid[0..7] = fe80 0000 0000 0000
> - * gid[8] = mac[0] ^ 2
> - * gid[9] = mac[1]
> - * gid[10] = mac[2]
> - * gid[11] = ff (VLAN ID high byte (4 MS bits))
> - * gid[12] = fe (VLAN ID low byte)
> - * gid[13] = mac[3]
> - * gid[14] = mac[4]
> - * gid[15] = mac[5]
> - */
> -static void hns_roce_addrconf_ifid_eui48(u8 *eui, u16 vlan_id,
> - struct net_device *dev)
> -{
> - memcpy(eui, dev->dev_addr, 3);
> - memcpy(eui + 5, dev->dev_addr + 3, 3);
> - if (vlan_id < 0x1000) {
> - eui[3] = vlan_id >> 8;
> - eui[4] = vlan_id & 0xff;
> - } else {
> - eui[3] = 0xff;
> - eui[4] = 0xfe;
> - }
> - eui[0] ^= 2;
> -}
> -
> -static void hns_roce_make_default_gid(struct net_device *dev, union ib_gid *gid)
> -{
> - memset(gid, 0, sizeof(*gid));
> - gid->raw[0] = 0xFE;
> - gid->raw[1] = 0x80;
> - hns_roce_addrconf_ifid_eui48(&gid->raw[8], 0xffff, dev);
> -}
> -
> -/**
> * hns_get_gid_index - Get gid index.
> * @hr_dev: pointer to structure hns_roce_dev.
> * @port: port, value range: 0 ~ MAX
> @@ -96,30 +57,6 @@ int hns_get_gid_index(struct hns_roce_dev *hr_dev, u8 port, int gid_index)
> return gid_index * hr_dev->caps.num_ports + port;
> }
>
> -static int hns_roce_set_gid(struct hns_roce_dev *hr_dev, u8 port, int gid_index,
> - union ib_gid *gid)
> -{
> - struct device *dev = &hr_dev->pdev->dev;
> - u8 gid_idx = 0;
> -
> - if (gid_index >= hr_dev->caps.gid_table_len[port]) {
> - dev_err(dev, "gid_index %d illegal, port %d gid range: 0~%d\n",
> - gid_index, port, hr_dev->caps.gid_table_len[port] - 1);
> - return -EINVAL;
> - }
> -
> - gid_idx = hns_get_gid_index(hr_dev, port, gid_index);
> -
> - if (!memcmp(gid, &hr_dev->iboe.gid_table[gid_idx], sizeof(*gid)))
> - return -EINVAL;
> -
> - memcpy(&hr_dev->iboe.gid_table[gid_idx], gid, sizeof(*gid));
> -
> - hr_dev->hw->set_gid(hr_dev, port, gid_index, gid);
> -
> - return 0;
> -}
> -
> static void hns_roce_set_mac(struct hns_roce_dev *hr_dev, u8 port, u8 *addr)
> {
> u8 phy_port;
> @@ -147,15 +84,44 @@ static void hns_roce_set_mtu(struct hns_roce_dev *hr_dev, u8 port, int mtu)
> hr_dev->hw->set_mtu(hr_dev, phy_port, tmp);
> }
>
> -static void hns_roce_update_gids(struct hns_roce_dev *hr_dev, int port)
> +static int hns_roce_add_gid(struct ib_device *device, u8 port_num,
> + unsigned int index, const union ib_gid *gid,
> + const struct ib_gid_attr *attr, void **context)
> +{
> + struct hns_roce_dev *hr_dev = to_hr_dev(device);
> + u8 port = port_num - 1;
> + unsigned long flags;
> +
> + if (port >= hr_dev->caps.num_ports)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&hr_dev->iboe.lock, flags);
> +
> + hr_dev->hw->set_gid(hr_dev, port, index, (union ib_gid *)gid);
> +
> + spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
> +
> + return 0;
> +}
> +
> +static int hns_roce_del_gid(struct ib_device *device, u8 port_num,
> + unsigned int index, void **context)
> {
> - struct ib_event event;
> + struct hns_roce_dev *hr_dev = to_hr_dev(device);
> + union ib_gid zgid = { {0} };
> + u8 port = port_num - 1;
> + unsigned long flags;
> +
> + if (port >= hr_dev->caps.num_ports)
> + return -EINVAL;
>
> - /* Refresh gid in ib_cache */
> - event.device = &hr_dev->ib_dev;
> - event.element.port_num = port + 1;
> - event.event = IB_EVENT_GID_CHANGE;
> - ib_dispatch_event(&event);
> + spin_lock_irqsave(&hr_dev->iboe.lock, flags);
> +
> + hr_dev->hw->set_gid(hr_dev, port, index, &zgid);
zgid has value zero. and after this call, where is zgid used?
> +
> + spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
> +
> + return 0;
> }
>
> static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
> @@ -164,8 +130,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
> struct device *dev = &hr_dev->pdev->dev;
> struct net_device *netdev;
> unsigned long flags;
> - union ib_gid gid;
> - int ret = 0;
>
> netdev = hr_dev->iboe.netdevs[port];
> if (!netdev) {
> @@ -181,10 +145,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
> case NETDEV_REGISTER:
> case NETDEV_CHANGEADDR:
> hns_roce_set_mac(hr_dev, port, netdev->dev_addr);
> - hns_roce_make_default_gid(netdev, &gid);
> - ret = hns_roce_set_gid(hr_dev, port, 0, &gid);
> - if (!ret)
> - hns_roce_update_gids(hr_dev, port);
> break;
> case NETDEV_DOWN:
> /*
> @@ -197,7 +157,7 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port,
> }
>
> spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
> - return ret;
> + return 0;
> }
>
> static int hns_roce_netdev_event(struct notifier_block *self,
> @@ -224,118 +184,17 @@ static int hns_roce_netdev_event(struct notifier_block *self,
> return NOTIFY_DONE;
> }
>
> -static void hns_roce_addr_event(int event, struct net_device *event_netdev,
> - struct hns_roce_dev *hr_dev, union ib_gid *gid)
> -{
> - struct hns_roce_ib_iboe *iboe = NULL;
> - int gid_table_len = 0;
> - unsigned long flags;
> - union ib_gid zgid;
> - u8 gid_idx = 0;
> - u8 port = 0;
> - int i = 0;
> - int free;
> - struct net_device *real_dev = rdma_vlan_dev_real_dev(event_netdev) ?
> - rdma_vlan_dev_real_dev(event_netdev) :
> - event_netdev;
> -
> - if (event != NETDEV_UP && event != NETDEV_DOWN)
> - return;
> -
> - iboe = &hr_dev->iboe;
> - while (port < hr_dev->caps.num_ports) {
> - if (real_dev == iboe->netdevs[port])
> - break;
> - port++;
> - }
> -
> - if (port >= hr_dev->caps.num_ports) {
> - dev_dbg(&hr_dev->pdev->dev, "can't find netdev\n");
> - return;
> - }
> -
> - memset(zgid.raw, 0, sizeof(zgid.raw));
> - free = -1;
> - gid_table_len = hr_dev->caps.gid_table_len[port];
> -
> - spin_lock_irqsave(&hr_dev->iboe.lock, flags);
> -
> - for (i = 0; i < gid_table_len; i++) {
> - gid_idx = hns_get_gid_index(hr_dev, port, i);
> - if (!memcmp(gid->raw, iboe->gid_table[gid_idx].raw,
> - sizeof(gid->raw)))
> - break;
> - if (free < 0 && !memcmp(zgid.raw,
> - iboe->gid_table[gid_idx].raw, sizeof(zgid.raw)))
> - free = i;
> - }
> -
> - if (i >= gid_table_len) {
> - if (free < 0) {
> - spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
> - dev_dbg(&hr_dev->pdev->dev,
> - "gid_index overflow, port(%d)\n", port);
> - return;
> - }
> - if (!hns_roce_set_gid(hr_dev, port, free, gid))
> - hns_roce_update_gids(hr_dev, port);
> - } else if (event == NETDEV_DOWN) {
> - if (!hns_roce_set_gid(hr_dev, port, i, &zgid))
> - hns_roce_update_gids(hr_dev, port);
> - }
> -
> - spin_unlock_irqrestore(&hr_dev->iboe.lock, flags);
> -}
> -
> -static int hns_roce_inet_event(struct notifier_block *self, unsigned long event,
> - void *ptr)
> -{
> - struct in_ifaddr *ifa = ptr;
> - struct hns_roce_dev *hr_dev;
> - struct net_device *dev = ifa->ifa_dev->dev;
> - union ib_gid gid;
> -
> - ipv6_addr_set_v4mapped(ifa->ifa_address, (struct in6_addr *)&gid);
> -
> - hr_dev = container_of(self, struct hns_roce_dev, iboe.nb_inet);
> -
> - hns_roce_addr_event(event, dev, hr_dev, &gid);
> -
> - return NOTIFY_DONE;
> -}
> -
> -static int hns_roce_setup_mtu_gids(struct hns_roce_dev *hr_dev)
> +static int hns_roce_setup_mtu_mac(struct hns_roce_dev *hr_dev)
> {
> - struct in_ifaddr *ifa_list = NULL;
> - union ib_gid gid = {{0} };
> - u32 ipaddr = 0;
> - int index = 0;
> - int ret = 0;
> - u8 i = 0;
> + u8 i;
>
> for (i = 0; i < hr_dev->caps.num_ports; i++) {
> hns_roce_set_mtu(hr_dev, i,
> ib_mtu_enum_to_int(hr_dev->caps.max_mtu));
> hns_roce_set_mac(hr_dev, i, hr_dev->iboe.netdevs[i]->dev_addr);
> -
> - if (hr_dev->iboe.netdevs[i]->ip_ptr) {
> - ifa_list = hr_dev->iboe.netdevs[i]->ip_ptr->ifa_list;
> - index = 1;
> - while (ifa_list) {
> - ipaddr = ifa_list->ifa_address;
> - ipv6_addr_set_v4mapped(ipaddr,
> - (struct in6_addr *)&gid);
> - ret = hns_roce_set_gid(hr_dev, i, index, &gid);
> - if (ret)
> - break;
> - index++;
> - ifa_list = ifa_list->ifa_next;
> - }
> - hns_roce_update_gids(hr_dev, i);
> - }
> }
>
> - return ret;
> + return 0;
> }
>
> static int hns_roce_query_device(struct ib_device *ib_dev,
> @@ -444,31 +303,6 @@ static enum rdma_link_layer hns_roce_get_link_layer(struct ib_device *device,
> static int hns_roce_query_gid(struct ib_device *ib_dev, u8 port_num, int index,
> union ib_gid *gid)
> {
> - struct hns_roce_dev *hr_dev = to_hr_dev(ib_dev);
> - struct device *dev = &hr_dev->pdev->dev;
> - u8 gid_idx = 0;
> - u8 port;
> -
> - if (port_num < 1 || port_num > hr_dev->caps.num_ports ||
> - index >= hr_dev->caps.gid_table_len[port_num - 1]) {
> - dev_err(dev,
> - "port_num %d index %d illegal! correct range: port_num 1~%d index 0~%d!\n",
> - port_num, index, hr_dev->caps.num_ports,
> - hr_dev->caps.gid_table_len[port_num - 1] - 1);
> - return -EINVAL;
> - }
> -
> - port = port_num - 1;
> - gid_idx = hns_get_gid_index(hr_dev, port, index);
> - if (gid_idx >= HNS_ROCE_MAX_GID_NUM) {
> - dev_err(dev, "port_num %d index %d illegal! total gid num %d!\n",
> - port_num, index, HNS_ROCE_MAX_GID_NUM);
> - return -EINVAL;
> - }
> -
> - memcpy(gid->raw, hr_dev->iboe.gid_table[gid_idx].raw,
> - HNS_ROCE_GID_SIZE);
> -
> return 0;
> }
>
> @@ -646,6 +480,8 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
> ib_dev->get_link_layer = hns_roce_get_link_layer;
> ib_dev->get_netdev = hns_roce_get_netdev;
> ib_dev->query_gid = hns_roce_query_gid;
> + ib_dev->add_gid = hns_roce_add_gid;
> + ib_dev->del_gid = hns_roce_del_gid;
> ib_dev->query_pkey = hns_roce_query_pkey;
> ib_dev->alloc_ucontext = hns_roce_alloc_ucontext;
> ib_dev->dealloc_ucontext = hns_roce_dealloc_ucontext;
> @@ -688,32 +524,22 @@ static int hns_roce_register_device(struct hns_roce_dev *hr_dev)
> return ret;
> }
>
> - ret = hns_roce_setup_mtu_gids(hr_dev);
> + ret = hns_roce_setup_mtu_mac(hr_dev);
> if (ret) {
> - dev_err(dev, "roce_setup_mtu_gids failed!\n");
> - goto error_failed_setup_mtu_gids;
> + dev_err(dev, "setup_mtu_mac failed!\n");
> + goto error_failed_setup_mtu_mac;
> }
>
> iboe->nb.notifier_call = hns_roce_netdev_event;
> ret = register_netdevice_notifier(&iboe->nb);
> if (ret) {
> dev_err(dev, "register_netdevice_notifier failed!\n");
> - goto error_failed_setup_mtu_gids;
> - }
> -
> - iboe->nb_inet.notifier_call = hns_roce_inet_event;
> - ret = register_inetaddr_notifier(&iboe->nb_inet);
> - if (ret) {
> - dev_err(dev, "register inet addr notifier failed!\n");
> - goto error_failed_register_inetaddr_notifier;
> + goto error_failed_setup_mtu_mac;
> }
>
> return 0;
>
> -error_failed_register_inetaddr_notifier:
> - unregister_netdevice_notifier(&iboe->nb);
> -
> -error_failed_setup_mtu_gids:
> +error_failed_setup_mtu_mac:
> ib_unregister_device(ib_dev);
>
> return ret;
>
^ permalink raw reply
* Re: Coding Style: Reverse XMAS tree declarations ? (was Re: [PATCH net-next v6 02/10] dpaa_eth: add support for DPAA Ethernet)
From: Michael Ellerman @ 2016-11-07 8:05 UTC (permalink / raw)
To: Joe Perches, David Miller, madalin.bucur, Andrew Morton,
Jonathan Corbet
Cc: pebolle, joakim.tjernlund, netdev, linux-kernel, ppc, oss,
linuxppc-dev
In-Reply-To: <1478242438.1924.31.camel@perches.com>
Joe Perches <joe@perches.com> writes:
> On Thu, 2016-11-03 at 15:58 -0400, David Miller wrote:
>> From: Madalin Bucur <madalin.bucur@nxp.com>
>> Date: Wed, 2 Nov 2016 22:17:26 +0200
>>
>> > This introduces the Freescale Data Path Acceleration Architecture
>> > +static inline size_t bpool_buffer_raw_size(u8 index, u8 cnt)
>> > +{
>> > + u8 i;
>> > + size_t res = DPAA_BP_RAW_SIZE / 2;
>>
>> Always order local variable declarations from longest to shortest line,
>> also know as Reverse Christmas Tree Format.
>
> I think this declaration sorting order is misguided but
> here's a possible change to checkpatch adding a test for it
> that does this test just for net/ and drivers/net/
And arch/powerpc too please.
cheers
^ permalink raw reply
* Re: rhashtable: how to use insecure_elasticity of rhashtable_params
From: Herbert Xu @ 2016-11-07 7:55 UTC (permalink / raw)
To: Xin Long; +Cc: network dev, davem, Phil Sutter
In-Reply-To: <CADvbK_cPQVT-icKn_2WpKqTyWgVEJikSAbg6=xB3+dt=zcdk0Q@mail.gmail.com>
On Sun, Nov 06, 2016 at 09:15:07PM +0800, Xin Long wrote:
> Now when I don't set insecure_elasticity, ht->elasticity would be
> set 16, it would be checked in the loop of __rhashtable_insert_fast
> and rhashtable_lookup_one.
This is now obsolete. Please use the new rhlist interface.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [PATCH net] igmp: do not remove igmp souce list info when set link down
From: kbuild test robot @ 2016-11-07 7:49 UTC (permalink / raw)
To: Hangbin Liu
Cc: kbuild-all, netdev, Hannes Frederic Sowa, Daniel Borkmann,
Hangbin Liu
In-Reply-To: <1478502122-6570-1-git-send-email-liuhangbin@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1203 bytes --]
Hi Hangbin,
[auto build test ERROR on net/master]
url: https://github.com/0day-ci/linux/commits/Hangbin-Liu/igmp-do-not-remove-igmp-souce-list-info-when-set-link-down/20161107-151122
config: i386-randconfig-x016-201645 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
net/ipv4/igmp.c: In function 'ip_mc_destroy_dev':
>> net/ipv4/igmp.c:1728:2: error: implicit declaration of function 'igmpv3_clear_delrec' [-Werror=implicit-function-declaration]
igmpv3_clear_delrec(in_dev);
^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/igmpv3_clear_delrec +1728 net/ipv4/igmp.c
1722 struct ip_mc_list *i;
1723
1724 ASSERT_RTNL();
1725
1726 /* Deactivate timers */
1727 ip_mc_down(in_dev);
> 1728 igmpv3_clear_delrec(in_dev);
1729
1730 while ((i = rtnl_dereference(in_dev->mc_list)) != NULL) {
1731 in_dev->mc_list = i->next_rcu;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29567 bytes --]
^ permalink raw reply
* Re: [PATCH net] igmp: do not remove igmp souce list info when set link down
From: kbuild test robot @ 2016-11-07 7:35 UTC (permalink / raw)
To: Hangbin Liu
Cc: kbuild-all, netdev, Hannes Frederic Sowa, Daniel Borkmann,
Hangbin Liu
In-Reply-To: <1478502122-6570-1-git-send-email-liuhangbin@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]
Hi Hangbin,
[auto build test ERROR on net/master]
url: https://github.com/0day-ci/linux/commits/Hangbin-Liu/igmp-do-not-remove-igmp-souce-list-info-when-set-link-down/20161107-151122
config: i386-randconfig-x007-201645 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
net/ipv4/igmp.c: In function 'igmpv3_del_delrec':
>> net/ipv4/igmp.c:1160:35: error: 'sysctl_igmp_qrv' undeclared (first use in this function)
im->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv;
^~~~~~~~~~~~~~~
net/ipv4/igmp.c:1160:35: note: each undeclared identifier is reported only once for each function it appears in
vim +/sysctl_igmp_qrv +1160 net/ipv4/igmp.c
1154 }
1155 spin_unlock_bh(&in_dev->mc_tomb_lock);
1156
1157 spin_lock_bh(&im->lock);
1158 if (pmc) {
1159 im->interface = pmc->interface;
> 1160 im->crcount = in_dev->mr_qrv ?: sysctl_igmp_qrv;
1161 im->sfmode = pmc->sfmode;
1162 if (pmc->sfmode == MCAST_INCLUDE) {
1163 im->tomb = pmc->tomb;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24903 bytes --]
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox