Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] Add pch ieee1588 driver for Intel EG20T PCH
From: Richard Cochran @ 2011-08-03 19:23 UTC (permalink / raw)
  To: Toshiharu Okada
  Cc: richard.cochran, netdev, linux-kernel, qi.wang, yong.y.wang,
	joel.clark, kok.howg.ewe, tomoya-linux
In-Reply-To: <1312352861-10955-1-git-send-email-toshiharu-linux@dsn.okisemi.com>

On Wed, Aug 03, 2011 at 03:27:41PM +0900, Toshiharu Okada wrote:
> This patch is for IEEE1588 driver of Intel EG20T PCH.
> EG20T PCH is the platform controller hub that is used in Intel's
> general embedded platform.
> This driver adds support for using the EG20T PCH as a PTP clock.
> 
> Would you review this patch, although this driver has not been tested yet?

Thanks for offering this patch. Please see my comments, below.

> 
> Signed-off-by: Toshiharu Okada <toshiharu-linux@dsn.okisemi.com>
> ---
>  drivers/ptp/Kconfig   |   13 +
>  drivers/ptp/Makefile  |    1 +
>  drivers/ptp/ptp_pch.c |  629 +++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 643 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/ptp/ptp_pch.c
> 
> diff --git a/drivers/ptp/Kconfig b/drivers/ptp/Kconfig
> index 68d7201..cd9bc3b 100644
> --- a/drivers/ptp/Kconfig
> +++ b/drivers/ptp/Kconfig
> @@ -72,4 +72,17 @@ config DP83640_PHY
>  	  In order for this to work, your MAC driver must also
>  	  implement the skb_tx_timetamp() function.
>  
> +config PTP_1588_CLOCK_PCH
> +	tristate "Intel PCH EG20T as PTP clock"
> +	depends on PTP_1588_CLOCK
> +	depends on PCH_GBE
> +	help
> +	  This driver adds support for using the PCH EG20T as a PTP
> +	  clock. This clock is only useful if your PTP programs are
> +	  getting hardware time stamps on the PTP Ethernet packets
> +	  using the SO_TIMESTAMPING API.
> +
> +	  To compile this driver as a module, choose M here: the module
> +	  will be called ptp_pch.
> +
>  endmenu
> diff --git a/drivers/ptp/Makefile b/drivers/ptp/Makefile
> index f6933e8..8b58597 100644
> --- a/drivers/ptp/Makefile
> +++ b/drivers/ptp/Makefile
> @@ -5,3 +5,4 @@
>  ptp-y					:= ptp_clock.o ptp_chardev.o ptp_sysfs.o
>  obj-$(CONFIG_PTP_1588_CLOCK)		+= ptp.o
>  obj-$(CONFIG_PTP_1588_CLOCK_IXP46X)	+= ptp_ixp46x.o
> +obj-$(CONFIG_PTP_1588_CLOCK_PCH)	+= ptp_pch.o
> diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c
> new file mode 100644
> index 0000000..0a804dc
> --- /dev/null
> +++ b/drivers/ptp/ptp_pch.c
> @@ -0,0 +1,629 @@
> +/*
> + * PTP 1588 clock using the EG20T PCH
> + *
> + * Copyright (C) 2010 OMICRON electronics GmbH
> + * Copyright (C) 2010 OKI SEMICONDUCTOR Co., LTD.
> + *
> + * This code was derived from the IXP46X driver.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/irq.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/pci.h>
> +#include <linux/ptp_clock_kernel.h>
> +
> +#define STATION_ADDR_LEN	20
> +#define PCI_DEVICE_ID_PCH_1588	0x8819
> +#define IO_MEM_BAR 1
> +
> +
> +/* Register read/write macros */
> +#define PCH_BIT_SET_CHECK(addr, bitmask) \
> +		((ioread32(addr) & (bitmask)) == (bitmask))
> +#define PCH_SET_ADDR_BIT(addr, bitmask)\
> +		iowrite32((ioread32(addr) | (bitmask)), (addr))
> +#define PCH_CLR_ADDR_BIT(addr, bitmask)\
> +		iowrite32((ioread32(addr) & ~(bitmask)), (addr))

I don't really like macros of this sort, just to set and clear
register bits. It doesn't make any fewer lines nor does it clarify the
code. Every driver author will know what is meant by the plain old C,
like:

    x = x | mask;
    x = x & ~mask;

Also, you should consider whether you need to protect against
concurrent access on a register.

> +
> +#define DEFAULT_ADDEND 0xF0000029
> +#define TICKS_NS_SHIFT  4

This driver is based on my ixp46x driver, which is fine because,
looking at the data sheet, it appears that the time stamping unit in
the EG20T PCH is fairly similar.

However, I doubt that these ADDEND and SHIFT values will work for you,
since they were calculated for the frequency compensated clock on the
IXP. They reflect an input clock frequency of 66.666666 MHz and a
nominal frequency of 62.5 MHz (or a period of 16 nanoseconds, thus
SHIFT is 4).

Section 14.6.1.10 in the data sheet seems to imply that the input
clock is 50 MHz. In that case you could use a nominal frequency of
31.25 MHz (period 32 ns, SHIFT 5). However, you need to find out
the actual input clock frequency. If this can vary, then the driver
should allow changing these values.

> +#define N_EXT_TS	2
> +
> +enum pch_status {
> +	PCH_SUCCESS,
> +	PCH_INVALIDPARAM,
> +	PCH_NOTIMESTAMP,
> +	PCH_INTERRUPTMODEINUSE,
> +	PCH_FAILED,
> +	PCH_UNSUPPORTED,
> +};
> +/**
> + * struct pch_ts_regs - IEEE 1588 registers
> + */
> +struct pch_ts_regs {
> +	u32 control;
> +	u32 event;
> +	u32 addend;
> +	u32 accum;
> +	u32 test;
> +	u32 ts_compare;
> +	u32 rsystime_lo;
> +	u32 rsystime_hi;
> +	u32 systime_lo;
> +	u32 systime_hi;
> +	u32 trgt_lo;
> +	u32 trgt_hi;
> +	u32 asms_lo;
> +	u32 asms_hi;
> +	u32 amms_lo;
> +	u32 amms_hi;
> +	u32 ch_control;

You never program this register. But I think the "Mode" field should
be set to 2. The other settings really make no sense at all.  Or do
you set this in the MAC driver?

(I wonder why Intel retained the very limited PTP V1 modes from the
IXP time stamping unit.)

> +	u32 ch_event;
> +	u32 tx_snap_lo;
> +	u32 tx_snap_hi;
> +	u32 rx_snap_lo;
> +	u32 rx_snap_hi;
> +	u32 src_uuid_lo;
> +	u32 src_uuid_hi;
> +	u32 can_status;
> +	u32 can_snap_lo;
> +	u32 can_snap_hi;
> +	u32 ts_sel;
> +	u32 ts_st[6];
> +	u32 reserve1[15];
> +	u32 stl_max_set_en;
> +	u32 stl_max_set;
> +	u32 reserve2[13];
> +	u32 srst;
> +};
> +
> +#define PCH_TSC_RESET		(1 << 0)
> +#define PCH_TSC_TTM_MASK	(1 << 1)
> +#define PCH_TSC_ASMS_MASK	(1 << 2)
> +#define PCH_TSC_AMMS_MASK	(1 << 3)
> +#define PCH_TSC_PPSM_MASK	(1 << 4)
> +#define PCH_TSE_TTIPEND		(1 << 1)
> +#define PCH_TSE_SNS		(1 << 2)
> +#define PCH_TSE_SNM		(1 << 3)
> +#define PCH_TSE_PPS		(1 << 4)
> +#define PCH_CC_MM		(1 << 0)
> +#define PCH_CC_TA		(1 << 1)
> +
> +#define PCH_CC_MODE_SHIFT	16
> +#define PCH_CC_MODE_MASK	0x001F0000
> +#define PCH_CC_VERSION		(1 << 31)
> +#define PCH_CE_TXS		(1 << 0)
> +#define PCH_CE_RXS		(1 << 1)
> +#define PCH_CE_OVR		(1 << 0)
> +#define PCH_CE_VAL		(1 << 1)
> +#define PCH_ECS_ETH		(1 << 0)
> +
> +#define PCH_ECS_CAN		(1 << 1)
> +#define PCH_STATION_BYTES	6
> +
> +#define PCH_IEEE1588_ETH	(1 << 0)
> +#define PCH_IEEE1588_CAN	(1 << 1)
> +/**
> + * struct pch_dev - Driver private data
> + */
> +struct pch_dev {
> +	struct pch_ts_regs *regs;
> +	struct ptp_clock *ptp_clock;
> +	struct ptp_clock_info caps;
> +	int exts0_enabled;
> +	int exts1_enabled;
> +
> +	u32 mem_base;
> +	u32 mem_size;
> +	u32 irq;
> +	u32 suspend:1;
> +	u32 initialized:1;
> +	struct pci_dev *pdev;
> +	spinlock_t lock;

It would be nice to have a short comment telling what this lock
protects. (Yes, I know what it protects, but still that is good
practice to have a comment.)

> +};
> +
> +static inline void pch_eth_enable_set(struct pch_dev *chip)
> +{
> +	/* SET the eth_enable bit */
> +	PCH_SET_ADDR_BIT(&chip->regs->ts_sel, PCH_ECS_ETH);
> +}

I really don't like this or the other similar helper functions,
below. They don't make the driver more understandable or shorter.
This function is only used in one place. You need at least two callers
to justify this.

> +
> +/*
> + * Register access functions
> + */
> +
> +static u64 pch_systime_read(struct pch_ts_regs *regs)
> +{
> +	u64 ns;
> +	u32 lo, hi;
> +
> +	lo = ioread32(&regs->systime_lo);
> +	hi = ioread32(&regs->systime_hi);
> +
> +	ns = ((u64) hi) << 32;
> +	ns |= lo;
> +	ns <<= TICKS_NS_SHIFT;

Here 'ns' will only be in nanoseconds when the ADDEND and SHIFT macros
are correct for the actual machine, as I mentioned above.

> +
> +	return ns;
> +}
> +
> +static void pch_systime_write(struct pch_ts_regs *regs, u64 ns)
> +{
> +	u32 hi, lo;
> +
> +	ns >>= TICKS_NS_SHIFT;
> +	hi = ns >> 32;
> +	lo = ns & 0xffffffff;
> +
> +	iowrite32(lo, &regs->systime_lo);
> +	iowrite32(hi, &regs->systime_hi);
> +}
> +

I think the following helper functions ...

> +static inline u32 pch_pps_evt_get(struct pch_dev *chip)
> +{
> +	/* Poll for PPS event */
> +	return PCH_BIT_SET_CHECK(&chip->regs->event, PCH_TSE_PPS);
> +}
> +
> +static inline u32 pch_amms_evt_get(struct pch_dev *chip)
> +{
> +	/* Poll for Auxiliary Master Mode Snapshot Captured event */
> +	return PCH_BIT_SET_CHECK(&chip->regs->event, PCH_TSE_SNM);
> +}
> +
> +static inline u32 pch_asms_evt_get(struct pch_dev *chip)
> +{
> +	/* Poll for Auxiliary Slave Mode Snapshot Captured event */
> +	return PCH_BIT_SET_CHECK(&chip->regs->event, PCH_TSE_SNS);
> +}
> +
> +static inline u32 pch_ttm_evt_get(struct pch_dev *chip)
> +{
> +	/* Poll for Target Time Reached event */
> +	return PCH_BIT_SET_CHECK(&chip->regs->event, PCH_TSE_TTIPEND);
> +}
> +
> +static inline void pch_pps_evt_clear(struct pch_dev *chip)
> +{
> +	/* Clear PPS event */
> +	PCH_SET_ADDR_BIT(&chip->regs->event, PCH_TSE_PPS);
> +}
> +
> +static inline void pch_amms_evt_clear(struct pch_dev *chip)
> +{
> +	/* Clear Auxiliary Master Mode Snapshot Captured event */
> +	PCH_SET_ADDR_BIT(&chip->regs->event, PCH_TSE_SNM);
> +}
> +
> +static inline void pch_asms_evt_clear(struct pch_dev *chip)
> +{
> +	/* Clear Auxiliary Slave Mode Snapshot Captured event */
> +	PCH_SET_ADDR_BIT(&chip->regs->event, PCH_TSE_SNS);
> +}
> +
> +static inline void pch_ttm_evt_clear(struct pch_dev *chip)
> +{
> +	/* Clear Target Time Reached event */
> +	PCH_SET_ADDR_BIT(&chip->regs->event, PCH_TSE_TTIPEND);
> +}

... are just noise and add nothing useful to the driver.

> +
> +static inline void pch_block_reset(struct pch_dev *chip)
> +{
> +	/* Reset Hardware Assist block */
> +	PCH_SET_ADDR_BIT(&chip->regs->control, PCH_TSC_RESET);
> +	PCH_CLR_ADDR_BIT(&chip->regs->control, PCH_TSC_RESET);
> +}
> +
> +/* This function enables all 64 bits in system time registers [high & low].
> +This is a work-around for non continuous value in the SystemTime Register*/
> +static void pch_set_system_time_count(struct pch_dev *chip)
> +{
> +	iowrite32(0x01, &chip->regs->stl_max_set_en);
> +	iowrite32(0xFFFFFFFF, &chip->regs->stl_max_set);
> +	iowrite32(0x00, &chip->regs->stl_max_set_en);
> +}
> +
> +static void pch_reset(struct pch_dev *chip)
> +{
> +	/* Reset Hardware Assist */
> +	pch_block_reset(chip);
> +
> +	/* enable all 32 bits in system time registers */
> +	pch_set_system_time_count(chip);
> +}

These three, above, are okay, since they encapsulate one logical
operation that takes more than one register access.

However, you might consider whether you need locking here.

> +
> +static void pch_eth_enable(struct pch_dev *chip)
> +{
> +	pch_eth_enable_set(chip);
> +}

Again, this helper only has one caller. Why not just set the bit that
you need in line?

> +
> +/*
> + * Interrupt service routine
> + */
> +static irqreturn_t isr(int irq, void *priv)
> +{
> +	struct pch_dev *pch_dev = priv;
> +	struct pch_ts_regs *regs = pch_dev->regs;
> +	struct ptp_clock_event event;
> +	u32 ack = 0, lo, hi, val;
> +
> +	val = ioread32(&regs->event);
> +
> +	if (val & PCH_TSE_SNS) {
> +		ack |= PCH_TSE_SNS;
> +		if (pch_dev->exts0_enabled) {
> +			hi = ioread32(&regs->asms_hi);
> +			lo = ioread32(&regs->asms_lo);
> +			event.type = PTP_CLOCK_EXTTS;
> +			event.index = 0;
> +			event.timestamp = ((u64) hi) << 32;
> +			event.timestamp |= lo;
> +			event.timestamp <<= TICKS_NS_SHIFT;
> +			ptp_clock_event(pch_dev->ptp_clock, &event);
> +		}
> +	}
> +
> +	if (val & PCH_TSE_SNM) {
> +		ack |= PCH_TSE_SNM;
> +		if (pch_dev->exts1_enabled) {
> +			hi = ioread32(&regs->amms_hi);
> +			lo = ioread32(&regs->amms_lo);
> +			event.type = PTP_CLOCK_EXTTS;
> +			event.index = 1;
> +			event.timestamp = ((u64) hi) << 32;
> +			event.timestamp |= lo;
> +			event.timestamp <<= TICKS_NS_SHIFT;
> +			ptp_clock_event(pch_dev->ptp_clock, &event);
> +		}
> +	}
> +
> +	if (val & PCH_TSE_TTIPEND)
> +		ack |= PCH_TSE_TTIPEND; /* this bit seems to be always set */

This ISR code (and much of the rest of the driver) is copied from the
IXP driver. It would be nice to know if it actually works on the atom
hardware. Do have any hardware to try it on?

> +
> +	if (ack) {
> +		iowrite32(ack, &regs->event);
> +		return IRQ_HANDLED;
> +	} else
> +		return IRQ_NONE;
> +}
> +
> +/*
> + * PTP clock operations
> + */
> +
> +static int ptp_pch_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
> +{
> +	u64 adj;
> +	u32 diff, addend;
> +	int neg_adj = 0;
> +	struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
> +	struct pch_ts_regs *regs = pch_dev->regs;
> +
> +	if (ppb < 0) {
> +		neg_adj = 1;
> +		ppb = -ppb;
> +	}
> +	addend = DEFAULT_ADDEND;
> +	adj = addend;
> +	adj *= ppb;
> +	diff = div_u64(adj, 1000000000ULL);
> +
> +	addend = neg_adj ? addend - diff : addend + diff;
> +
> +	iowrite32(addend, &regs->addend);
> +
> +	return 0;
> +}
> +
> +static int ptp_pch_adjtime(struct ptp_clock_info *ptp, s64 delta)
> +{
> +	s64 now;
> +	unsigned long flags;
> +	struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
> +	struct pch_ts_regs *regs = pch_dev->regs;
> +
> +	spin_lock_irqsave(&pch_dev->lock, flags);
> +	now = pch_systime_read(regs);
> +	now += delta;
> +	pch_systime_write(regs, now);
> +	spin_unlock_irqrestore(&pch_dev->lock, flags);
> +
> +	return 0;
> +}
> +
> +static int ptp_pch_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
> +{
> +	u64 ns;
> +	u32 remainder;
> +	unsigned long flags;
> +	struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
> +	struct pch_ts_regs *regs = pch_dev->regs;
> +
> +	spin_lock_irqsave(&pch_dev->lock, flags);
> +	ns = pch_systime_read(regs);
> +	spin_unlock_irqrestore(&pch_dev->lock, flags);
> +
> +	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
> +	ts->tv_nsec = remainder;
> +	return 0;
> +}
> +
> +static int ptp_pch_settime(struct ptp_clock_info *ptp,
> +			   const struct timespec *ts)
> +{
> +	u64 ns;
> +	unsigned long flags;
> +	struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
> +	struct pch_ts_regs *regs = pch_dev->regs;
> +
> +	ns = ts->tv_sec * 1000000000ULL;
> +	ns += ts->tv_nsec;
> +
> +	spin_lock_irqsave(&pch_dev->lock, flags);
> +	pch_systime_write(regs, ns);
> +	spin_unlock_irqrestore(&pch_dev->lock, flags);
> +
> +	return 0;
> +}
> +
> +static int ptp_pch_enable(struct ptp_clock_info *ptp,
> +			  struct ptp_clock_request *rq, int on)
> +{
> +	struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
> +
> +	switch (rq->type) {
> +	case PTP_CLK_REQ_EXTTS:
> +		switch (rq->extts.index) {
> +		case 0:
> +			pch_dev->exts0_enabled = on ? 1 : 0;
> +			break;
> +		case 1:
> +			pch_dev->exts1_enabled = on ? 1 : 0;
> +			break;
> +		default:
> +			return -EINVAL;
> +		}
> +		return 0;
> +	default:
> +		break;
> +	}
> +
> +	return -EOPNOTSUPP;
> +}
> +
> +static struct ptp_clock_info ptp_pch_caps = {
> +	.owner		= THIS_MODULE,
> +	.name		= "PCH timer",
> +	.max_adj	= 66666655,

This should be recalculated once you figure out the input clock and
nominal frequency.

> +	.n_ext_ts	= N_EXT_TS,
> +	.pps		= 0,
> +	.adjfreq	= ptp_pch_adjfreq,
> +	.adjtime	= ptp_pch_adjtime,
> +	.gettime	= ptp_pch_gettime,
> +	.settime	= ptp_pch_settime,
> +	.enable		= ptp_pch_enable,
> +};
> +
> +
> +#ifdef CONFIG_PM
> +static s32 pch_suspend(struct pci_dev *pdev, pm_message_t state)
> +{
> +	struct pch_dev *chip = pci_get_drvdata(pdev);
> +
> +	chip->suspend = 1;

You set this flag here ...

> +	pci_disable_device(pdev);
> +	pci_enable_wake(pdev, PCI_D3hot, 0);
> +
> +	if (pci_save_state(pdev) != 0) {
> +		dev_err(&pdev->dev,
> +			"%s: could not save PCI config state\n", __func__);
> +		return -ENOMEM;
> +	}
> +	pci_set_power_state(pdev, pci_choose_state(pdev, state));
> +
> +	return 0;
> +}
> +
> +static s32 pch_resume(struct pci_dev *pdev)
> +{
> +	s32 ret;
> +	struct pch_dev *chip = pci_get_drvdata(pdev);
> +
> +	pci_set_power_state(pdev, PCI_D0);
> +	pci_restore_state(pdev);
> +	ret = pci_enable_device(pdev);
> +	if (ret) {
> +		dev_err(&pdev->dev, "%s: pci_enable_device failed\n", __func__);
> +		return ret;
> +	}
> +	pci_enable_wake(pdev, PCI_D3hot, 0);
> +	chip->suspend = 0;

... and clear it again here. Why?

> +	return 0;
> +}
> +#else
> +#define pch_suspend NULL
> +#define pch_resume NULL
> +#endif
> +
> +static void __devexit pch_remove(struct pci_dev *pdev)
> +{
> +	struct pch_dev *chip = pci_get_drvdata(pdev);
> +
> +	ptp_clock_unregister(chip->ptp_clock);
> +	/* free the interrupt */
> +	if (pdev->irq != 0)
> +		free_irq(pdev->irq, chip);
> +
> +	/* unmap the virtual IO memory space */
> +	if (chip->regs != 0) {
> +		iounmap(chip->regs);
> +		chip->regs = 0;
> +	}
> +	/* release the reserved IO memory space */
> +	if (chip->mem_base != 0) {
> +		release_mem_region(chip->mem_base, chip->mem_size);
> +		chip->mem_base = 0;
> +	}
> +	pci_disable_device(pdev);
> +	kfree(chip);
> +	dev_info(&pdev->dev, "%s: complete\n", __func__);
> +}
> +
> +static s32 __devinit
> +pch_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> +{
> +	s32 ret;
> +	struct pch_dev *chip;
> +
> +	chip = kzalloc(sizeof(struct pch_dev), GFP_KERNEL);
> +	if (chip == NULL)
> +		return -ENOMEM;
> +
> +	/* enable the 1588 pci device */
> +	ret = pci_enable_device(pdev);
> +	if (ret != 0) {
> +		dev_err(&pdev->dev,
> +			"%s:could not enable the pci device\n", __func__);
> +		goto err_pci_en;
> +	}
> +
> +	chip->mem_base = pci_resource_start(pdev, IO_MEM_BAR);
> +	if (!chip->mem_base) {
> +		dev_err(&pdev->dev,
> +			"%s: could not locate IO memory address\n", __func__);
> +		ret = -ENODEV;
> +		goto err_pci_start;
> +	}
> +
> +	/* retreive the available length of the IO memory space */
> +	chip->mem_size = pci_resource_len(pdev, IO_MEM_BAR);
> +
> +	/* allocate the memory for the device registers */
> +	if (!request_mem_region
> +			    (chip->mem_base, chip->mem_size, "1588_regs")) {

Poor statement break (and this would fit all on one line).

> +		dev_err(&pdev->dev,
> +		    "%s: could not allocate register memory space\n", __func__);

Bad indentation.

> +		ret = -EBUSY;
> +		goto err_req_mem_region;
> +	}
> +
> +	/* get the virtual address to the 1588 registers */
> +	chip->regs = ioremap(chip->mem_base, chip->mem_size);
> +
> +	if (!chip->regs) {
> +		dev_err(&pdev->dev,
> +			"%s: Could not get virtual address\n", __func__);
> +		ret = -ENOMEM;
> +		goto err_ioremap;
> +	}
> +
> +	chip->caps = ptp_pch_caps;
> +	chip->ptp_clock = ptp_clock_register(&chip->caps);
> +
> +	if (IS_ERR(chip->ptp_clock))
> +		return PTR_ERR(chip->ptp_clock);
> +
> +	spin_lock_init(&chip->lock);
> +
> +	ret = request_irq(pdev->irq, &isr, IRQF_SHARED, KBUILD_MODNAME, chip);
> +	if (ret != 0) {
> +		dev_err(&pdev->dev,
> +			"%s: failed to get irq %d\n", __func__, pdev->irq);
> +		goto err_req_irq;
> +	}
> +
> +	chip->initialized = 1;

You set this flag, but never use it.

> +	/* indicate success */
> +	chip->irq = pdev->irq;
> +	chip->pdev = pdev;
> +	pci_set_drvdata(pdev, chip);
> +
> +	/* reset the ieee1588 h/w */
> +	pch_reset(chip);
> +
> +	iowrite32(DEFAULT_ADDEND, &chip->regs->addend);
> +	iowrite32(1, &chip->regs->trgt_lo);
> +	iowrite32(0, &chip->regs->trgt_hi);
> +	iowrite32(PCH_TSE_TTIPEND, &chip->regs->event);
> +	pch_eth_enable(chip);
> +
> +	return 0;
> +
> +err_req_irq:
> +	ptp_clock_unregister(chip->ptp_clock);
> +	iounmap(chip->regs);
> +	chip->regs = 0;
> +
> +err_ioremap:
> +	release_mem_region(chip->mem_base, chip->mem_size);
> +
> +err_req_mem_region:
> +	chip->mem_base = 0;
> +
> +err_pci_start:
> +	pci_disable_device(pdev);
> +
> +err_pci_en:
> +	kfree(chip);
> +	dev_err(&pdev->dev, "%s: probe failed(ret=0x%x)\n", __func__, ret);
> +
> +	return ret;
> +}
> +
> +static DEFINE_PCI_DEVICE_TABLE(pch_gbe_pcidev_id) = {
> +	{.vendor = PCI_VENDOR_ID_INTEL,

Needs a space (or newline) before the dot.

> +	 .device = PCI_DEVICE_ID_PCH_1588
> +	 },
> +	{0}
> +};
> +
> +static struct pci_driver pch_pcidev = {
> +	.name = KBUILD_MODNAME,
> +	.id_table = pch_pcidev_id,

Here you meant "pch_gbe_pcidev_id" instead (or no "gbe" in the PCI
device table).

> +	.probe = pch_probe,
> +	.remove = pch_remove,
> +	.suspend = pch_suspend,
> +	.resume = pch_resume,
> +};
> +
> +static void __exit ptp_pch_exit(void)
> +{
> +	pci_unregister_driver(&pch_pcidev);
> +}
> +
> +static s32 __init ptp_pch_init(void)
> +{
> +	s32 ret;
> +
> +	/* register the driver with the pci core */
> +	ret = pci_register_driver(&pch_pcidev);
> +
> +	return ret;
> +}
> +
> +module_init(ptp_pch_init);
> +module_exit(ptp_pch_exit);
> +
> +MODULE_AUTHOR("OKI SEMICONDUCTOR, <toshiharu-linux@dsn.okisemi.com>");
> +MODULE_DESCRIPTION("PTP clock using the EG20T timer");
> +MODULE_LICENSE("GPL");

Overall, the driver looks okay. I would appreciate if you would take a
look at the comments and submit a revised patch.

I would also like to see how the time stamps are done in the MAC
driver. Have you already posted that?

Feature request: I notice in the data sheet that the time stamping
unit can produce a PPS output. Any chance that you could program this
feature?

Thanks,

Richard


> +
> -- 
> 1.7.4.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: [PATCH] mlx4: Fixing Ethernet unicast packet steering
From: Roland Dreier @ 2011-08-03 19:06 UTC (permalink / raw)
  To: Yevgeny Petrilin, David Miller
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <CAL1RGDU+=wX40J_uktWxMiHNx5Sed-d3b2J4_4JTg=tyqbKsEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Wed, Aug 3, 2011 at 11:58 AM, Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org> wrote:
>> For older FW versions, fixing the usage of per port Mac table.
>> For each port we must define the base QP number, which is passed
>> to the HW.
>> Setting the correct value in SET_PORT FW command to enable the steering.

> Thanks, testing this now.

Yep, works well on my backrev FW boards.  Dave, you want to merge this
or should I?

 - R.
--
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: bonding and ifenslave version.
From: Andy Gospodarek @ 2011-08-03 19:03 UTC (permalink / raw)
  To: Nicolas de Pesloüan; +Cc: Jay Vosburgh, netdev
In-Reply-To: <4E38EE23.8030703@gmail.com>

On Wed, Aug 3, 2011 at 2:43 AM, Nicolas de Pesloüan
<nicolas.2p.debian@gmail.com> wrote:
> Le 02/08/2011 22:06, Nicolas de Pesloüan a écrit :
>>
>> Commit 655f8919d549ad1872e24d826b6ce42530516d2e
>>     bonding: add min links parameter to 802.3ad
>>
>> and commit ebd8e4977a87cb81d93c62a9bff0102a9713722f
>>     bonding: add all_slaves_active parameter
>>
>> introduced new options to bonding, but didn't provide the documentation
>> for those options.
>>
>> Signed-off-by: Nicolas de Pesloüan<nicolas.2p.debian@free.fr>
>> ---
>
> Jay, Andy,
>
> While working at this patch, I noticed that the bonding driver version
> wasn't bumped up at the time those options were introduced.
>
> I thought introducing a new option should cause the driver version to
> change. Am I right?

When a significant change happens, we try to change the version
number.  The version number probably should have been changed when
those were added.  Inspecting the module options or sysfs parameters
indicate whether or not these patches were added, so it is less of a
priority than when some internal infrastructure (like moving to use
rx_handler) changes.

I consider it more critical to change the bonding module version when
something changes that cannot be detected by inspecting the module or
sysfs parameters.  This is more helpful to users reporting problems.

> On a different but related topic, the version in
> Documentation/networking/ifenslave.c (1.1.0) didn't change since the git
> origin and probably since 2003.
>
> Arguably, none of the commit regarding this file introduced a significant
> change (with the possible exception of commit
> e6d184e33109010412ad1d59719af74755a935f4, [NET]: Fix ifenslave to not fail
> on lack of IP information). But if we never change a 3-level version number,
> whatever the level of change, this version number might be useless. Any
> comment?
>
>        Nicolas.
>

Distributions benefit from version numbers on userspace utils.  It
would probably be better to keep ifenslave's version number as it is
to help those maintaining those distro packages.

^ permalink raw reply

* Re: [net-next v2 70/71] tile: Move the Tilera driver
From: Chris Metcalf @ 2011-08-03 19:02 UTC (permalink / raw)
  To: jeffrey.t.kirsher
  Cc: davem@davemloft.net, netdev@vger.kernel.org, gospo@redhat.com,
	sassmann@redhat.com
In-Reply-To: <1312350454.2294.86.camel@jtkirshe-mobl>

On 8/3/2011 1:47 AM, Jeff Kirsher wrote:
> On 7/30/2011 11:27 PM, Jeff Kirsher wrote:
>>> Move the Tilera driver into drivers/net/ethernet/tile and
>>> make the necessary Kconfig and Makefile changes.
>>>
>>> CC: Chris Metcalf <cmetcalf@tilera.com>
>>> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
>>> [...]
>>> +++ b/drivers/net/ethernet/tile/Kconfig
>>> @@ -0,0 +1,28 @@
>>> +#
>>> +# Tilera network device configuration
>>> +#
>>> +
>>> +config NET_VENDOR_TILERA
>>> +	bool "Tilera devices"
>>> +	depends on TILE
>>> +	---help---
>>> +	  If you have a network (Ethernet) card belonging to this class, say Y
>>> +	  and read the Ethernet-HOWTO, available from
>>> +	  <http://www.tldp.org/docs.html#howto>.
>>> +
>>> +	  Note that the answer to this question doesn't directly affect the
>>> +	  kernel: saying N will just cause the configurator to skip all
>>> +	  the questions about Tilera cards. If you say Y, you will be asked for
>>> +	  your specific card in the following questions.
>>> +
>>> +config TILE_NET
>>> +	tristate "Tilera GBE/XGBE network driver support"
>>> +	depends on NET_VENDOR_TILERA && TILE
>>> +	default y
>>> +	select CRC32
>>> +	---help---
>>> +	  This is a standard Linux network device driver for the
>>> +	  on-chip Tilera Gigabit Ethernet and XAUI interfaces.
>>> +
>>> +	  To compile this driver as a module, choose M here: the module
>>> +	  will be called tile_net.
>>>
> [...]
>
> This Kconfig would automatically default to y for TILE kernels and would
> allow you to easily add additional future drivers for Tilera silicon,
> and if you expand to other architectures/systems in the future it would
> also allow for that as well.  Your thoughts?
>
> Otherwise I can have it just as this:
> +config TILE_NET
> +       tristate "Tilera GBE/XGBE network driver support"
> +       depends on TILE
> +       default y
> +       select CRC32
> +       ---help---
> +         This is a standard Linux network device driver for the
> +         on-chip Tilera Gigabit Ethernet and XAUI interfaces.
> +
> +         To compile this driver as a module, choose M here: the module
> +         will be called tile_net.
>
> Because you only have 1 driver, there is no large need to add the
> NET_VENDOR_<blah> and it can always be added in the future if the need
> arises.

Honestly, I think I'd prefer the simple TILE_NET solution.  My sense is
that even for the next generation of the chip, we're likely to keep using
TILE_NET to enable it in the config.  Note that we have done this now for
both tilepro and tilegx, though we haven't pushed the tilegx driver back to
the community yet; look at the conditionals in drivers/net/tile/Makefile to
see what I mean.  So let's stick with the simple thing for now.  Thanks!

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply

* Re: [PATCH] mlx4: Fixing Ethernet unicast packet steering
From: Roland Dreier @ 2011-08-03 18:58 UTC (permalink / raw)
  To: Yevgeny Petrilin; +Cc: Roland Dreier, linux-rdma, netdev
In-Reply-To: <4E39594C.4090808@mellanox.co.il>

> For older FW versions, fixing the usage of per port Mac table.
> For each port we must define the base QP number, which is passed
> to the HW.
> Setting the correct value in SET_PORT FW command to enable the steering.
>
> Reported-by: Roland Dreier <roland@purestorage.com>

Thanks, testing this now.

^ permalink raw reply

* [resend PATCH] ixgbe: remove unused #define
From: Jon Mason @ 2011-08-03 16:42 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Jeff Kirsher, Jesse Brandeburg, Bruce Allan,
	Carolyn Wyborny, Don Skidmore, Greg Rose, PJ Waskiewicz,
	Alex Duyck, John Ronciak, e1000-devel

Remove unused IXGBE_INTEL_VENDOR_ID #define

Signed-off-by: Jon Mason <jdmason@kudzu.us>
---
 drivers/net/ixgbe/ixgbe_type.h |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index e0d970e..b5bf2e1 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -32,9 +32,6 @@
 #include <linux/mdio.h>
 #include <linux/netdevice.h>
 
-/* Vendor ID */
-#define IXGBE_INTEL_VENDOR_ID   0x8086
-
 /* Device IDs */
 #define IXGBE_DEV_ID_82598               0x10B6
 #define IXGBE_DEV_ID_82598_BX            0x1508
-- 
1.7.6


^ permalink raw reply related

* [resend PATCH] ixgb: use PCI_VENDOR_ID_*
From: Jon Mason @ 2011-08-03 16:42 UTC (permalink / raw)
  To: David S. Miller
  Cc: netdev, Jeff Kirsher, Jesse Brandeburg, Bruce Allan,
	Carolyn Wyborny, Don Skidmore, Greg Rose, PJ Waskiewicz,
	Alex Duyck, John Ronciak, e1000-devel

Use PCI_VENDOR_ID_* from pci_ids.h instead of creating #define locally.

Signed-off-by: Jon Mason <jdmason@kudzu.us>
---
 drivers/net/ixgb/ixgb_hw.c   |    5 +++--
 drivers/net/ixgb/ixgb_ids.h  |    5 -----
 drivers/net/ixgb/ixgb_main.c |   10 +++++-----
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_hw.c b/drivers/net/ixgb/ixgb_hw.c
index 6cb2e42..f32e25b 100644
--- a/drivers/net/ixgb/ixgb_hw.c
+++ b/drivers/net/ixgb/ixgb_hw.c
@@ -32,6 +32,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/pci_ids.h>
 #include "ixgb_hw.h"
 #include "ixgb_ids.h"
 
@@ -96,7 +97,7 @@ static u32 ixgb_mac_reset(struct ixgb_hw *hw)
 	ASSERT(!(ctrl_reg & IXGB_CTRL0_RST));
 #endif
 
-	if (hw->subsystem_vendor_id == SUN_SUBVENDOR_ID) {
+	if (hw->subsystem_vendor_id == PCI_VENDOR_ID_SUN) {
 		ctrl_reg =  /* Enable interrupt from XFP and SerDes */
 			   IXGB_CTRL1_GPI0_EN |
 			   IXGB_CTRL1_SDP6_DIR |
@@ -270,7 +271,7 @@ ixgb_identify_phy(struct ixgb_hw *hw)
 	}
 
 	/* update phy type for sun specific board */
-	if (hw->subsystem_vendor_id == SUN_SUBVENDOR_ID)
+	if (hw->subsystem_vendor_id == PCI_VENDOR_ID_SUN)
 		phy_type = ixgb_phy_type_bcm;
 
 	return phy_type;
diff --git a/drivers/net/ixgb/ixgb_ids.h b/drivers/net/ixgb/ixgb_ids.h
index 2a58847..32c1b30 100644
--- a/drivers/net/ixgb/ixgb_ids.h
+++ b/drivers/net/ixgb/ixgb_ids.h
@@ -33,11 +33,6 @@
 ** The Device and Vendor IDs for 10 Gigabit MACs
 **********************************************************************/
 
-#define INTEL_VENDOR_ID             0x8086
-#define INTEL_SUBVENDOR_ID          0x8086
-#define SUN_VENDOR_ID               0x108E
-#define SUN_SUBVENDOR_ID            0x108E
-
 #define IXGB_DEVICE_ID_82597EX      0x1048
 #define IXGB_DEVICE_ID_82597EX_SR   0x1A48
 #define IXGB_DEVICE_ID_82597EX_LR   0x1B48
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 6a130eb..7dd4f8b 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -54,13 +54,13 @@ MODULE_PARM_DESC(copybreak,
  *   Class, Class Mask, private data (not used) }
  */
 static DEFINE_PCI_DEVICE_TABLE(ixgb_pci_tbl) = {
-	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX,
+	{PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_CX4,
+	{PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX_CX4,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_SR,
+	{PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX_SR,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
-	{INTEL_VENDOR_ID, IXGB_DEVICE_ID_82597EX_LR,
+	{PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX_LR,
 	 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
 
 	/* required last entry */
@@ -195,7 +195,7 @@ ixgb_irq_enable(struct ixgb_adapter *adapter)
 {
 	u32 val = IXGB_INT_RXT0 | IXGB_INT_RXDMT0 |
 		  IXGB_INT_TXDW | IXGB_INT_LSC;
-	if (adapter->hw.subsystem_vendor_id == SUN_SUBVENDOR_ID)
+	if (adapter->hw.subsystem_vendor_id == PCI_VENDOR_ID_SUN)
 		val |= IXGB_INT_GPI0;
 	IXGB_WRITE_REG(&adapter->hw, IMS, val);
 	IXGB_WRITE_FLUSH(&adapter->hw);
-- 
1.7.6


^ permalink raw reply related

* [resend PATCH] irda: use PCI_VENDOR_ID_*
From: Jon Mason @ 2011-08-03 16:42 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Samuel Ortiz

Use PCI_VENDOR_ID_* from pci_ids.h instead of creating #define locally.

Signed-off-by: Jon Mason <jdmason@kudzu.us>
---
 drivers/net/irda/smsc-ircc2.c |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index 954f6e93..8b1c348 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -2405,8 +2405,6 @@ static int __init smsc_superio_lpc(unsigned short cfg_base)
  * addresses making a subsystem device table necessary.
  */
 #ifdef CONFIG_PCI
-#define PCIID_VENDOR_INTEL 0x8086
-#define PCIID_VENDOR_ALI 0x10b9
 static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __initdata = {
 	/*
 	 * Subsystems needing entries:
@@ -2416,7 +2414,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 	 */
 	{
 		/* Guessed entry */
-		.vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
+		.vendor = PCI_VENDOR_ID_INTEL, /* Intel 82801DBM LPC bridge */
 		.device = 0x24cc,
 		.subvendor = 0x103c,
 		.subdevice = 0x08bc,
@@ -2429,7 +2427,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 		.name = "HP nx5000 family",
 	},
 	{
-		.vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
+		.vendor = PCI_VENDOR_ID_INTEL, /* Intel 82801DBM LPC bridge */
 		.device = 0x24cc,
 		.subvendor = 0x103c,
 		.subdevice = 0x088c,
@@ -2443,7 +2441,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 		.name = "HP nc8000 family",
 	},
 	{
-		.vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
+		.vendor = PCI_VENDOR_ID_INTEL, /* Intel 82801DBM LPC bridge */
 		.device = 0x24cc,
 		.subvendor = 0x103c,
 		.subdevice = 0x0890,
@@ -2456,7 +2454,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 		.name = "HP nc6000 family",
 	},
 	{
-		.vendor = PCIID_VENDOR_INTEL, /* Intel 82801DBM LPC bridge */
+		.vendor = PCI_VENDOR_ID_INTEL, /* Intel 82801DBM LPC bridge */
 		.device = 0x24cc,
 		.subvendor = 0x0e11,
 		.subdevice = 0x0860,
@@ -2471,7 +2469,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 	},
 	{
 		/* Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge */
-		.vendor = PCIID_VENDOR_INTEL,
+		.vendor = PCI_VENDOR_ID_INTEL,
 		.device = 0x24c0,
 		.subvendor = 0x1179,
 		.subdevice = 0xffff, /* 0xffff is "any" */
@@ -2484,7 +2482,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 		.name = "Toshiba laptop with Intel 82801DB/DBL LPC bridge",
 	},
 	{
-		.vendor = PCIID_VENDOR_INTEL, /* Intel 82801CAM ISA bridge */
+		.vendor = PCI_VENDOR_ID_INTEL, /* Intel 82801CAM ISA bridge */
 		.device = 0x248c,
 		.subvendor = 0x1179,
 		.subdevice = 0xffff, /* 0xffff is "any" */
@@ -2498,7 +2496,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 	},
 	{
 		/* 82801DBM (ICH4-M) LPC Interface Bridge */
-		.vendor = PCIID_VENDOR_INTEL,
+		.vendor = PCI_VENDOR_ID_INTEL,
 		.device = 0x24cc,
 		.subvendor = 0x1179,
 		.subdevice = 0xffff, /* 0xffff is "any" */
@@ -2512,7 +2510,7 @@ static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __ini
 	},
 	{
 		/* ALi M1533/M1535 PCI to ISA Bridge [Aladdin IV/V/V+] */
-		.vendor = PCIID_VENDOR_ALI,
+		.vendor = PCI_VENDOR_ID_AL,
 		.device = 0x1533,
 		.subvendor = 0x1179,
 		.subdevice = 0xffff, /* 0xffff is "any" */
-- 
1.7.6


^ permalink raw reply related

* Re: [PATCH ] cdc_ncm: fixes for big-endian architecture / MIPS
From: Giuseppe Scrivano @ 2011-08-03 15:46 UTC (permalink / raw)
  To: Alexey ORISHKO
  Cc: netdev@vger.kernel.org, oliver@neukum.org,
	linux-usb@vger.kernel.org, gregkh@suse.de,
	alexey.orishko@gmail.com
In-Reply-To: <2AC7D4AD8BA1C640B4C60C61C8E520153E3DEF6C26-8ZTw5gFVCTjVH5byLeRTJxkTb7+GphCuwzqs5ZKRSiY@public.gmane.org>

Alexey ORISHKO <alexey.orishko-0IS4wlFg1OjSUeElwK9/Pw@public.gmane.org> writes:

> Since it was incorrect to use struct usb_cdc_notification I would rather
> remove cdc_ncm_do_request() function and provide u16 parameters directly to 
> usb_control_msg without creating yet additional structure for usb control request.

here another version, I have removed cdc_ncm_do_request and call
directly usb_control_msg.  Tested on mips.

Cheers,
Giuseppe



>From 7ba49d858103acb2ce4043127e3512ea29dff307 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <giuseppe-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
Date: Fri, 15 Jul 2011 15:34:14 +0200
Subject: [PATCH] cdc_ncm: fix endianess problem.

Signed-off-by: Giuseppe Scrivano <giuseppe-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
---
 drivers/net/usb/cdc_ncm.c |  156 ++++++++++++++++-----------------------------
 1 files changed, 56 insertions(+), 100 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index f33ca6a..9c37d54 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -54,7 +54,7 @@
 #include <linux/usb/usbnet.h>
 #include <linux/usb/cdc.h>
 
-#define	DRIVER_VERSION				"01-June-2011"
+#define	DRIVER_VERSION				"03-Aug-2011"
 
 /* CDC NCM subclass 3.2.1 */
 #define USB_CDC_NCM_NDP16_LENGTH_MIN		0x10
@@ -164,35 +164,8 @@ cdc_ncm_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
 	usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info));
 }
 
-static int
-cdc_ncm_do_request(struct cdc_ncm_ctx *ctx, struct usb_cdc_notification *req,
-		   void *data, u16 flags, u16 *actlen, u16 timeout)
-{
-	int err;
-
-	err = usb_control_msg(ctx->udev, (req->bmRequestType & USB_DIR_IN) ?
-				usb_rcvctrlpipe(ctx->udev, 0) :
-				usb_sndctrlpipe(ctx->udev, 0),
-				req->bNotificationType, req->bmRequestType,
-				req->wValue,
-				req->wIndex, data,
-				req->wLength, timeout);
-
-	if (err < 0) {
-		if (actlen)
-			*actlen = 0;
-		return err;
-	}
-
-	if (actlen)
-		*actlen = err;
-
-	return 0;
-}
-
 static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 {
-	struct usb_cdc_notification req;
 	u32 val;
 	u8 flags;
 	u8 iface_no;
@@ -201,14 +174,14 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 
 	iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
 
-	req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE;
-	req.bNotificationType = USB_CDC_GET_NTB_PARAMETERS;
-	req.wValue = 0;
-	req.wIndex = cpu_to_le16(iface_no);
-	req.wLength = cpu_to_le16(sizeof(ctx->ncm_parm));
-
-	err = cdc_ncm_do_request(ctx, &req, &ctx->ncm_parm, 0, NULL, 1000);
-	if (err) {
+	err = usb_control_msg(ctx->udev,
+				usb_rcvctrlpipe(ctx->udev, 0),
+				USB_CDC_GET_NTB_PARAMETERS,
+				USB_TYPE_CLASS | USB_DIR_IN
+				 | USB_RECIP_INTERFACE,
+				0, iface_no, &ctx->ncm_parm,
+				sizeof(ctx->ncm_parm), 10000);
+	if (err < 0) {
 		pr_debug("failed GET_NTB_PARAMETERS\n");
 		return 1;
 	}
@@ -254,31 +227,26 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 
 	/* inform device about NTB input size changes */
 	if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) {
-		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
-							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_SET_NTB_INPUT_SIZE;
-		req.wValue = 0;
-		req.wIndex = cpu_to_le16(iface_no);
 
 		if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) {
 			struct usb_cdc_ncm_ndp_input_size ndp_in_sz;
-
-			req.wLength = 8;
-			ndp_in_sz.dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
-			ndp_in_sz.wNtbInMaxDatagrams =
-					cpu_to_le16(CDC_NCM_DPT_DATAGRAMS_MAX);
-			ndp_in_sz.wReserved = 0;
-			err = cdc_ncm_do_request(ctx, &req, &ndp_in_sz, 0, NULL,
-									1000);
+			err = usb_control_msg(ctx->udev,
+					usb_sndctrlpipe(ctx->udev, 0),
+					USB_CDC_SET_NTB_INPUT_SIZE,
+					USB_TYPE_CLASS | USB_DIR_OUT
+					 | USB_RECIP_INTERFACE,
+					0, iface_no, &ndp_in_sz, 8, 1000);
 		} else {
 			__le32 dwNtbInMaxSize = cpu_to_le32(ctx->rx_max);
-
-			req.wLength = 4;
-			err = cdc_ncm_do_request(ctx, &req, &dwNtbInMaxSize, 0,
-								NULL, 1000);
+			err = usb_control_msg(ctx->udev,
+					usb_sndctrlpipe(ctx->udev, 0),
+					USB_CDC_SET_NTB_INPUT_SIZE,
+					USB_TYPE_CLASS | USB_DIR_OUT
+					 | USB_RECIP_INTERFACE,
+					0, iface_no, &dwNtbInMaxSize, 4, 1000);
 		}
 
-		if (err)
+		if (err < 0)
 			pr_debug("Setting NTB Input Size failed\n");
 	}
 
@@ -333,29 +301,24 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 
 	/* set CRC Mode */
 	if (flags & USB_CDC_NCM_NCAP_CRC_MODE) {
-		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
-							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_SET_CRC_MODE;
-		req.wValue = cpu_to_le16(USB_CDC_NCM_CRC_NOT_APPENDED);
-		req.wIndex = cpu_to_le16(iface_no);
-		req.wLength = 0;
-
-		err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
-		if (err)
+		err = usb_control_msg(ctx->udev, usb_sndctrlpipe(ctx->udev, 0),
+				USB_CDC_SET_CRC_MODE,
+				USB_TYPE_CLASS | USB_DIR_OUT
+				 | USB_RECIP_INTERFACE,
+				USB_CDC_NCM_CRC_NOT_APPENDED,
+				iface_no, NULL, 0, 1000);
+		if (err < 0)
 			pr_debug("Setting CRC mode off failed\n");
 	}
 
 	/* set NTB format, if both formats are supported */
 	if (ntb_fmt_supported & USB_CDC_NCM_NTH32_SIGN) {
-		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
-							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_SET_NTB_FORMAT;
-		req.wValue = cpu_to_le16(USB_CDC_NCM_NTB16_FORMAT);
-		req.wIndex = cpu_to_le16(iface_no);
-		req.wLength = 0;
-
-		err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
-		if (err)
+		err = usb_control_msg(ctx->udev, usb_sndctrlpipe(ctx->udev, 0),
+				USB_CDC_SET_NTB_FORMAT, USB_TYPE_CLASS
+				 | USB_DIR_OUT | USB_RECIP_INTERFACE,
+				USB_CDC_NCM_NTB16_FORMAT,
+				iface_no, NULL, 0, 1000);
+		if (err < 0)
 			pr_debug("Setting NTB format to 16-bit failed\n");
 	}
 
@@ -365,17 +328,13 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 	if (flags & USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE) {
 		__le16 max_datagram_size;
 		u16 eth_max_sz = le16_to_cpu(ctx->ether_desc->wMaxSegmentSize);
-
-		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN |
-							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_GET_MAX_DATAGRAM_SIZE;
-		req.wValue = 0;
-		req.wIndex = cpu_to_le16(iface_no);
-		req.wLength = cpu_to_le16(2);
-
-		err = cdc_ncm_do_request(ctx, &req, &max_datagram_size, 0, NULL,
-									1000);
-		if (err) {
+		err = usb_control_msg(ctx->udev, usb_rcvctrlpipe(ctx->udev, 0),
+				USB_CDC_GET_MAX_DATAGRAM_SIZE,
+				USB_TYPE_CLASS | USB_DIR_IN
+				 | USB_RECIP_INTERFACE,
+				0, iface_no, &max_datagram_size,
+				2, 1000);
+		if (err < 0) {
 			pr_debug("GET_MAX_DATAGRAM_SIZE failed, use size=%u\n",
 						CDC_NCM_MIN_DATAGRAM_SIZE);
 		} else {
@@ -396,17 +355,15 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 					CDC_NCM_MIN_DATAGRAM_SIZE;
 
 			/* if value changed, update device */
-			req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
-							USB_RECIP_INTERFACE;
-			req.bNotificationType = USB_CDC_SET_MAX_DATAGRAM_SIZE;
-			req.wValue = 0;
-			req.wIndex = cpu_to_le16(iface_no);
-			req.wLength = 2;
-			max_datagram_size = cpu_to_le16(ctx->max_datagram_size);
-
-			err = cdc_ncm_do_request(ctx, &req, &max_datagram_size,
-								0, NULL, 1000);
-			if (err)
+			err = usb_control_msg(ctx->udev,
+						usb_sndctrlpipe(ctx->udev, 0),
+						USB_CDC_SET_MAX_DATAGRAM_SIZE,
+						USB_TYPE_CLASS | USB_DIR_OUT
+						 | USB_RECIP_INTERFACE,
+						0,
+						iface_no, &max_datagram_size,
+						2, 1000);
+			if (err < 0)
 				pr_debug("SET_MAX_DATAGRAM_SIZE failed\n");
 		}
 
@@ -672,7 +629,7 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
 	u32 rem;
 	u32 offset;
 	u32 last_offset;
-	u16 n = 0;
+	u16 n = 0, index;
 	u8 ready2send = 0;
 
 	/* if there is a remaining skb, it gets priority */
@@ -860,8 +817,8 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
 					cpu_to_le16(sizeof(ctx->tx_ncm.nth16));
 	ctx->tx_ncm.nth16.wSequence = cpu_to_le16(ctx->tx_seq);
 	ctx->tx_ncm.nth16.wBlockLength = cpu_to_le16(last_offset);
-	ctx->tx_ncm.nth16.wNdpIndex = ALIGN(sizeof(struct usb_cdc_ncm_nth16),
-							ctx->tx_ndp_modulus);
+	index = ALIGN(sizeof(struct usb_cdc_ncm_nth16), ctx->tx_ndp_modulus);
+	ctx->tx_ncm.nth16.wNdpIndex = cpu_to_le16(index);
 
 	memcpy(skb_out->data, &(ctx->tx_ncm.nth16), sizeof(ctx->tx_ncm.nth16));
 	ctx->tx_seq++;
@@ -874,12 +831,11 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
 	ctx->tx_ncm.ndp16.wLength = cpu_to_le16(rem);
 	ctx->tx_ncm.ndp16.wNextNdpIndex = 0; /* reserved */
 
-	memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex,
+	memcpy(((u8 *)skb_out->data) + index,
 						&(ctx->tx_ncm.ndp16),
 						sizeof(ctx->tx_ncm.ndp16));
 
-	memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex +
-					sizeof(ctx->tx_ncm.ndp16),
+	memcpy(((u8 *)skb_out->data) + index + sizeof(ctx->tx_ncm.ndp16),
 					&(ctx->tx_ncm.dpe16),
 					(ctx->tx_curr_frame_num + 1) *
 					sizeof(struct usb_cdc_ncm_dpe16));
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" 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 related

* Re: [PATCH 2/2] Create a new connector proc_event for successful calls to accept.
From: Samir Bellabes @ 2011-08-03 15:02 UTC (permalink / raw)
  To: Joe Damato; +Cc: zbr, netdev
In-Reply-To: <1312221865-3012-3-git-send-email-joe@boundary.com>

Joe Damato <joe@boundary.com> writes:

> diff --git a/net/socket.c b/net/socket.c
> index b4f9a6c..d21a266 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1544,6 +1544,9 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
>  			goto out_fd;
>  	}
>  
> +	proc_accept_connector(current, newsock,
> +			      (struct sockaddr *)&address, len);
> +
>  	/* File flags are not inherited via accept() unlike another OSes. */
>  
>  	fd_install(newfd, newfile);

Hi Joe,
adding a specific function here is not very suitable.
I have already proposed such a patch by adding my own hooks, then I
moved to the LSM hooks
http://www.mail-archive.com/netdev@vger.kernel.org/msg33814.html

I have rewrite the projet to directly use netlink socket (in fact
generic netlink socket) and move to a new protocol between userspace and
kernel
you can find patch here :
http://www.synack.fr/project/snet/snet.html

sam


^ permalink raw reply

* pull request: wireless 2011-08-03
From: John W. Linville @ 2011-08-03 14:47 UTC (permalink / raw)
  To: davem; +Cc: linux-wireless, netdev, linux-kernel

Dave,

This is mostly a replay of the mangled pull request I sent yesterday.
The body of that request message is here:

	Here are a few more fixes intended for 3.1.  Dan Carpenter
	gives us an off-by-one fix in the scan trigger code for
	nl80211.  Felix gives us a fix for tx power initialization
	for ath9k.  Larry fixes an oops on ARM by rewriting some init
	code to avoid checking something that doesn't get initialized
	on ARM.  This round's big hero is Stanislaw, who gives us a
	brown paper bag fix for some skb handling in rt2x00, an ath9k
	fix to avoid hangs on systems w/ ASPM disabled, and an iwlegacy
	fix to ensure that tx power settings are applied properly.

In addition to that, I have a few more fixes to squeeze in here!  A fix
from Emmanuel Grumbach for iwlagn reverts a buggy portion of an
earlier patch.  A fix from Helmut Schaa corrects a build problem w/
rt2x00 discovered by Randy Dunlap.  Stanislaw brings us yet another fix,
this one for a NULL pointer access in rt2x00.  Finally, Wey-Yi gives us
a fix to turn-off idel support for iwl5000 devices since using it makes
them unstable.

As usual, please let me know if there are problems!

John

P.S.  I apologize for the confusion I've created lately, with the previous
pull request and others.  The summer heat (and the screaming kids) must
be getting to me!  I'll work harder on tightening things up...

---

The following changes since commit 28f4881cbf9ce285edfc245a8990af36d21c062f:

  bnx2x: Clear MDIO access warning during first driver load (2011-08-03 03:22:18 -0700)

are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless.git for-davem

Dan Carpenter (1):
      cfg80211: off by one in nl80211_trigger_scan()

Emmanuel Grumbach (1):
      iwlagn: sysfs couldn't find the priv pointer

Felix Fietkau (1):
      ath9k: initialize tx chainmask before testing channel tx power values

Helmut Schaa (1):
      rt2x00: Fix compilation without CONFIG_RT2X00_LIB_CRYPTO

John W. Linville (1):
      Merge git://git.kernel.org/.../linville/wireless-next into for-davem

Larry Finger (1):
      rtlwifi: Fix kernel oops on ARM SOC

Stanislaw Gruszka (4):
      iwlegacy: set tx power after rxon_assoc
      ath9k: skip ->config_pci_powersave() if PCIe port has ASPM disabled
      rt2x00: rt2800: fix zeroing skb structure
      rt2x00: fix usage of NULL queue

Wey-Yi Guy (1):
      iwlagn: 5000 do not support idle mode

 drivers/net/wireless/ath/ath9k/ar9002_hw.c |    6 +-----
 drivers/net/wireless/ath/ath9k/ar9003_hw.c |    6 +-----
 drivers/net/wireless/ath/ath9k/hw.c        |   11 +++++++++--
 drivers/net/wireless/ath/ath9k/hw.h        |    3 ++-
 drivers/net/wireless/ath/ath9k/init.c      |    2 ++
 drivers/net/wireless/ath/ath9k/pci.c       |   27 +++++++++++++++++++++++++++
 drivers/net/wireless/iwlegacy/iwl-3945.c   |    6 +++++-
 drivers/net/wireless/iwlegacy/iwl-4965.c   |    8 ++++++--
 drivers/net/wireless/iwlwifi/iwl-5000.c    |    1 +
 drivers/net/wireless/iwlwifi/iwl-core.h    |    2 ++
 drivers/net/wireless/iwlwifi/iwl-pci.c     |   18 +++++++++---------
 drivers/net/wireless/iwlwifi/iwl-power.c   |    3 ++-
 drivers/net/wireless/rt2x00/rt2800lib.c    |    3 +--
 drivers/net/wireless/rt2x00/rt2x00lib.h    |    3 ++-
 drivers/net/wireless/rt2x00/rt2x00mac.c    |    5 +++--
 drivers/net/wireless/rtlwifi/pci.c         |   20 +++++++++++---------
 net/wireless/nl80211.c                     |    2 +-
 17 files changed, 85 insertions(+), 41 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
index 9ff7c30..44d9d8d 100644
--- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c
@@ -309,11 +309,7 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,
 	u8 i;
 	u32 val;
 
-	if (ah->is_pciexpress != true)
-		return;
-
-	/* Do not touch SerDes registers */
-	if (ah->config.pcie_powersave_enable == 2)
+	if (ah->is_pciexpress != true || ah->aspm_enabled != true)
 		return;
 
 	/* Nothing to do on restore for 11N */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_hw.c b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
index 8efdec2..ad2bb2b 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
@@ -519,11 +519,7 @@ static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
 					 int restore,
 					 int power_off)
 {
-	if (ah->is_pciexpress != true)
-		return;
-
-	/* Do not touch SerDes registers */
-	if (ah->config.pcie_powersave_enable == 2)
+	if (ah->is_pciexpress != true || ah->aspm_enabled != true)
 		return;
 
 	/* Nothing to do on restore for 11N */
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 8006ce0..8dcefe7 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -318,6 +318,14 @@ static void ath9k_hw_disablepcie(struct ath_hw *ah)
 	REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
 }
 
+static void ath9k_hw_aspm_init(struct ath_hw *ah)
+{
+	struct ath_common *common = ath9k_hw_common(ah);
+
+	if (common->bus_ops->aspm_init)
+		common->bus_ops->aspm_init(common);
+}
+
 /* This should work for all families including legacy */
 static bool ath9k_hw_chip_test(struct ath_hw *ah)
 {
@@ -378,7 +386,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
 	ah->config.additional_swba_backoff = 0;
 	ah->config.ack_6mb = 0x0;
 	ah->config.cwm_ignore_extcca = 0;
-	ah->config.pcie_powersave_enable = 0;
 	ah->config.pcie_clock_req = 0;
 	ah->config.pcie_waen = 0;
 	ah->config.analog_shiftreg = 1;
@@ -598,7 +605,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
 
 
 	if (ah->is_pciexpress)
-		ath9k_hw_configpcipowersave(ah, 0, 0);
+		ath9k_hw_aspm_init(ah);
 	else
 		ath9k_hw_disablepcie(ah);
 
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 6acd0f9..c798890 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -219,7 +219,6 @@ struct ath9k_ops_config {
 	int additional_swba_backoff;
 	int ack_6mb;
 	u32 cwm_ignore_extcca;
-	u8 pcie_powersave_enable;
 	bool pcieSerDesWrite;
 	u8 pcie_clock_req;
 	u32 pcie_waen;
@@ -673,6 +672,7 @@ struct ath_hw {
 
 	bool sw_mgmt_crypto;
 	bool is_pciexpress;
+	bool aspm_enabled;
 	bool is_monitoring;
 	bool need_an_top2_fixup;
 	u16 tx_trig_level;
@@ -874,6 +874,7 @@ struct ath_bus_ops {
 	bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
 	void (*bt_coex_prep)(struct ath_common *common);
 	void (*extn_synch_en)(struct ath_common *common);
+	void (*aspm_init)(struct ath_common *common);
 };
 
 static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index ac51071..aa0ff7e 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -670,8 +670,10 @@ static void ath9k_init_band_txpower(struct ath_softc *sc, int band)
 static void ath9k_init_txpower_limits(struct ath_softc *sc)
 {
 	struct ath_hw *ah = sc->sc_ah;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct ath9k_channel *curchan = ah->curchan;
 
+	ah->txchainmask = common->tx_chainmask;
 	if (ah->caps.hw_caps & ATH9K_HW_CAP_2GHZ)
 		ath9k_init_band_txpower(sc, IEEE80211_BAND_2GHZ);
 	if (ah->caps.hw_caps & ATH9K_HW_CAP_5GHZ)
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 3bad0b2..be4ea13 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -16,6 +16,7 @@
 
 #include <linux/nl80211.h>
 #include <linux/pci.h>
+#include <linux/pci-aspm.h>
 #include <linux/ath9k_platform.h>
 #include "ath9k.h"
 
@@ -115,12 +116,38 @@ static void ath_pci_extn_synch_enable(struct ath_common *common)
 	pci_write_config_byte(pdev, sc->sc_ah->caps.pcie_lcr_offset, lnkctl);
 }
 
+static void ath_pci_aspm_init(struct ath_common *common)
+{
+	struct ath_softc *sc = (struct ath_softc *) common->priv;
+	struct ath_hw *ah = sc->sc_ah;
+	struct pci_dev *pdev = to_pci_dev(sc->dev);
+	struct pci_dev *parent;
+	int pos;
+	u8 aspm;
+
+	if (!pci_is_pcie(pdev))
+		return;
+
+	parent = pdev->bus->self;
+	if (WARN_ON(!parent))
+		return;
+
+	pos = pci_pcie_cap(parent);
+	pci_read_config_byte(parent, pos +  PCI_EXP_LNKCTL, &aspm);
+	if (aspm & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)) {
+		ah->aspm_enabled = true;
+		/* Initialize PCIe PM and SERDES registers. */
+		ath9k_hw_configpcipowersave(ah, 0, 0);
+	}
+}
+
 static const struct ath_bus_ops ath_pci_bus_ops = {
 	.ath_bus_type = ATH_PCI,
 	.read_cachesize = ath_pci_read_cachesize,
 	.eeprom_read = ath_pci_eeprom_read,
 	.bt_coex_prep = ath_pci_bt_coex_prep,
 	.extn_synch_en = ath_pci_extn_synch_enable,
+	.aspm_init = ath_pci_aspm_init,
 };
 
 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c
index dab67a1..73fe3cd 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945.c
@@ -1746,7 +1746,11 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
 		}
 
 		memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
-
+		/*
+		 * We do not commit tx power settings while channel changing,
+		 * do it now if tx power changed.
+		 */
+		iwl_legacy_set_tx_power(priv, priv->tx_power_next, false);
 		return 0;
 	}
 
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c
index bd4b000..ecdc6e5 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965.c
@@ -1235,7 +1235,12 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c
 
 		memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon));
 		iwl_legacy_print_rx_config_cmd(priv, ctx);
-		goto set_tx_power;
+		/*
+		 * We do not commit tx power settings while channel changing,
+		 * do it now if tx power changed.
+		 */
+		iwl_legacy_set_tx_power(priv, priv->tx_power_next, false);
+		return 0;
 	}
 
 	/* If we are currently associated and the new config requires
@@ -1315,7 +1320,6 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c
 
 	iwl4965_init_sensitivity(priv);
 
-set_tx_power:
 	/* If we issue a new RXON command which required a tune then we must
 	 * send a new TXPOWER command or we won't be able to Tx any frames */
 	ret = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true);
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index 3eeb12e..c95cefd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -365,6 +365,7 @@ static struct iwl_base_params iwl5000_base_params = {
 	.chain_noise_scale = 1000,
 	.wd_timeout = IWL_LONG_WD_TIMEOUT,
 	.max_event_log_size = 512,
+	.no_idle_support = true,
 };
 static struct iwl_ht_params iwl5000_ht_params = {
 	.ht_greenfield_support = true,
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index 3e6bb73..02817a4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -135,6 +135,7 @@ struct iwl_mod_params {
  * @temperature_kelvin: temperature report by uCode in kelvin
  * @max_event_log_size: size of event log buffer size for ucode event logging
  * @shadow_reg_enable: HW shadhow register bit
+ * @no_idle_support: do not support idle mode
  */
 struct iwl_base_params {
 	int eeprom_size;
@@ -156,6 +157,7 @@ struct iwl_base_params {
 	bool temperature_kelvin;
 	u32 max_event_log_size;
 	const bool shadow_reg_enable;
+	const bool no_idle_support;
 };
 /*
  * @advanced_bt_coexist: support advanced bt coexist
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c
index fb7e436..69d4ec4 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.c
+++ b/drivers/net/wireless/iwlwifi/iwl-pci.c
@@ -134,6 +134,7 @@ static void iwl_pci_apm_config(struct iwl_bus *bus)
 static void iwl_pci_set_drv_data(struct iwl_bus *bus, void *drv_data)
 {
 	bus->drv_data = drv_data;
+	pci_set_drvdata(IWL_BUS_GET_PCI_DEV(bus), drv_data);
 }
 
 static void iwl_pci_get_hw_id(struct iwl_bus *bus, char buf[],
@@ -454,8 +455,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
 	}
 
-	pci_set_drvdata(pdev, bus);
-
 	bus->dev = &pdev->dev;
 	bus->irq = pdev->irq;
 	bus->ops = &pci_ops;
@@ -494,11 +493,12 @@ static void iwl_pci_down(struct iwl_bus *bus)
 
 static void __devexit iwl_pci_remove(struct pci_dev *pdev)
 {
-	struct iwl_bus *bus = pci_get_drvdata(pdev);
+	struct iwl_priv *priv = pci_get_drvdata(pdev);
+	void *bus_specific = priv->bus->bus_specific;
 
-	iwl_remove(bus->drv_data);
+	iwl_remove(priv);
 
-	iwl_pci_down(bus);
+	iwl_pci_down(bus_specific);
 }
 
 #ifdef CONFIG_PM
@@ -506,20 +506,20 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
 static int iwl_pci_suspend(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
-	struct iwl_bus *bus = pci_get_drvdata(pdev);
+	struct iwl_priv *priv = pci_get_drvdata(pdev);
 
 	/* Before you put code here, think about WoWLAN. You cannot check here
 	 * whether WoWLAN is enabled or not, and your code will run even if
 	 * WoWLAN is enabled - don't kill the NIC, someone may need it in Sx.
 	 */
 
-	return iwl_suspend(bus->drv_data);
+	return iwl_suspend(priv);
 }
 
 static int iwl_pci_resume(struct device *device)
 {
 	struct pci_dev *pdev = to_pci_dev(device);
-	struct iwl_bus *bus = pci_get_drvdata(pdev);
+	struct iwl_priv *priv = pci_get_drvdata(pdev);
 
 	/* Before you put code here, think about WoWLAN. You cannot check here
 	 * whether WoWLAN is enabled or not, and your code will run even if
@@ -532,7 +532,7 @@ static int iwl_pci_resume(struct device *device)
 	 */
 	pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
 
-	return iwl_resume(bus->drv_data);
+	return iwl_resume(priv);
 }
 
 static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume);
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 3ec619c..cd64df0 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -349,7 +349,8 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
 
 	if (priv->wowlan)
 		iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper);
-	else if (priv->hw->conf.flags & IEEE80211_CONF_IDLE)
+	else if (!priv->cfg->base_params->no_idle_support &&
+		 priv->hw->conf.flags & IEEE80211_CONF_IDLE)
 		iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
 	else if (iwl_tt_is_low_power_state(priv)) {
 		/* in thermal throttling low power state */
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 84ab7d1..ef67f67 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -703,8 +703,7 @@ void rt2800_write_beacon(struct queue_entry *entry, struct txentry_desc *txdesc)
 	/*
 	 * Add space for the TXWI in front of the skb.
 	 */
-	skb_push(entry->skb, TXWI_DESC_SIZE);
-	memset(entry->skb, 0, TXWI_DESC_SIZE);
+	memset(skb_push(entry->skb, TXWI_DESC_SIZE), 0, TXWI_DESC_SIZE);
 
 	/*
 	 * Register descriptor details in skb frame descriptor.
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h
index 15cdc7e..4cdf247 100644
--- a/drivers/net/wireless/rt2x00/rt2x00lib.h
+++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
@@ -355,7 +355,8 @@ static inline enum cipher rt2x00crypto_key_to_cipher(struct ieee80211_key_conf *
 	return CIPHER_NONE;
 }
 
-static inline void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry,
+static inline void rt2x00crypto_create_tx_descriptor(struct rt2x00_dev *rt2x00dev,
+						     struct sk_buff *skb,
 						     struct txentry_desc *txdesc)
 {
 }
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c
index 8efab39..4ccf238 100644
--- a/drivers/net/wireless/rt2x00/rt2x00mac.c
+++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
@@ -113,7 +113,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 	 * due to possible race conditions in mac80211.
 	 */
 	if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
-		goto exit_fail;
+		goto exit_free_skb;
 
 	/*
 	 * Use the ATIM queue if appropriate and present.
@@ -127,7 +127,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 		ERROR(rt2x00dev,
 		      "Attempt to send packet over invalid queue %d.\n"
 		      "Please file bug report to %s.\n", qid, DRV_PROJECT);
-		goto exit_fail;
+		goto exit_free_skb;
 	}
 
 	/*
@@ -159,6 +159,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 
  exit_fail:
 	rt2x00queue_pause_queue(queue);
+ exit_free_skb:
 	dev_kfree_skb_any(skb);
 }
 EXPORT_SYMBOL_GPL(rt2x00mac_tx);
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 5efd578..56f1235 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1696,15 +1696,17 @@ static bool _rtl_pci_find_adapter(struct pci_dev *pdev,
 	pcipriv->ndis_adapter.devnumber = PCI_SLOT(pdev->devfn);
 	pcipriv->ndis_adapter.funcnumber = PCI_FUNC(pdev->devfn);
 
-	/*find bridge info */
-	pcipriv->ndis_adapter.pcibridge_vendorid = bridge_pdev->vendor;
-	for (tmp = 0; tmp < PCI_BRIDGE_VENDOR_MAX; tmp++) {
-		if (bridge_pdev->vendor == pcibridge_vendors[tmp]) {
-			pcipriv->ndis_adapter.pcibridge_vendor = tmp;
-			RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
-				 ("Pci Bridge Vendor is found index: %d\n",
-				  tmp));
-			break;
+	if (bridge_pdev) {
+		/*find bridge info if available */
+		pcipriv->ndis_adapter.pcibridge_vendorid = bridge_pdev->vendor;
+		for (tmp = 0; tmp < PCI_BRIDGE_VENDOR_MAX; tmp++) {
+			if (bridge_pdev->vendor == pcibridge_vendors[tmp]) {
+				pcipriv->ndis_adapter.pcibridge_vendor = tmp;
+				RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
+					 ("Pci Bridge Vendor is found index:"
+					 " %d\n", tmp));
+				break;
+			}
 		}
 	}
 
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 28d2aa1..e83e7fe 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3464,7 +3464,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 				    tmp) {
 			enum ieee80211_band band = nla_type(attr);
 
-			if (band < 0 || band > IEEE80211_NUM_BANDS) {
+			if (band < 0 || band >= IEEE80211_NUM_BANDS) {
 				err = -EINVAL;
 				goto out_free;
 			}
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply related

* Re: [Bugme-new] [Bug 39742] New: 2.6.39.3 crash ... 3.0.0 same trap
From: Rustam Afanasyev @ 2011-08-03 14:49 UTC (permalink / raw)
  To: Andrew Morton; +Cc: netdev, bugme-daemon, Patrick McHardy
In-Reply-To: <20110722144214.577718f0.akpm@linux-foundation.org>

I was trying using new kernel, but i have same bug and trap from the kernel:
------------------------------------------------
[98592.361121] ------------[ cut here ]------------
[98592.365040] kernel BUG at include/linux/skbuff.h:1189!
[98592.365040] invalid opcode: 0000 [#1] PREEMPT SMP
[98592.365040] CPU 1
[98592.365040] Modules linked in: cls_fw sch_sfq ip_set_hash_net 
ip_set_hash_ip arc4 ecb ppp_mppe xt_mark nf_conntrack_ipv
4 nf_defrag_ipv4 xt_state xt_TCPMSS ipt_LOG xt_recent xt_NOTRACK 
nf_conntrack xt_statistic ts_kmp xt_tcpudp xt_string xt_m
ultiport xt_set iptable_raw iptable_mangle iptable_filter ip_tables 
act_mirred act_skbedit cls_u32 sch_ingress ip_set nfne
tlink l2tp_ppp l2tp_netlink l2tp_core pptp pppox ppp_generic slhc gre 
ipt_ULOG x_tables 8021q garp stp cls_flow sch_htb if
b dm_multipath scsi_dh dm_mod tg3 i2c_i801 rtc_cmos psmouse pcspkr 
sr_mod ehci_hcd cdrom igb uhci_hcd evdev i2c_core sg se
rio_raw usbcore dca i3000_edac edac_core processor button ext3 jbd 
mbcache sd_mod crc_t10dif ide_pci_generic ide_core pata
_acpi ata_generic ata_piix libata scsi_mod
[98592.365040]
[98592.365040] Pid: 0, comm: kworker/0:0 Not tainted 3.0.0-un-def-alt2 
#1 ASUS RS100-E4/PI2/P5M2-M/RS100-E4
[98592.365040] RIP: 0010:[<ffffffff8136ca2b>]  [<ffffffff8136ca2b>] 
skb_pull+0x2b/0x30
[98592.365040] RSP: 0018:ffff88011fc83ab0  EFLAGS: 00010283
[98592.365040] RAX: 000000000000057e RBX: ffff880117f5f080 RCX: 
000000000000011f
[98592.365040] RDX: 000000000000011f RSI: 0000000000000002 RDI: 
ffff880117f5f080
[98592.365040] RBP: ffff88011fc83ab0 R08: 0000000000000000 R09: 
0000000000000102
[98592.365040] R10: 0000000000000000 R11: 0000000000000001 R12: 
ffff8800378bb000
[98592.365040] R13: ffff880117834c6e R14: 000000000000002f R15: 
ffffffff8168dd80
[98592.365040] FS:  0000000000000000(0000) GS:ffff88011fc80000(0000) 
knlGS:0000000000000000
[98592.365040] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[98592.365040] CR2: 00000000007ced6c CR3: 0000000117faa000 CR4: 
00000000000006e0
[98592.365040] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 
0000000000000000
[98592.365040] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 
0000000000000400
[98592.365040] Process kworker/0:0 (pid: 0, threadinfo ffff880118f5c000, 
task ffff880118f5a480)
[98592.365040] Stack:
[98592.365040]  ffff88011fc83ae0 ffffffffa027b7fa ffff88011fc83ae0 
ffff8800378bb000
[98592.365040]  ffff880117f5f080 ffff8800378bb050 ffff88011fc83b10 
ffffffff8136bddc
[98592.365040]  ffff88011fc83b40 ffff880117f5f080 ffff8800378bb000 
000000000c1a000a
[98592.365040] Call Trace:
[98592.365040]  <IRQ>
[98592.365040]  [<ffffffffa027b7fa>] pptp_rcv_core+0x21a/0x220 [pptp]
[98592.365040]  [<ffffffff8136bddc>] sk_receive_skb+0x13c/0x160
[98592.365040]  [<ffffffffa027b1be>] pptp_rcv+0x15e/0x1b0 [pptp]
[98592.365040]  [<ffffffffa0256133>] gre_rcv+0x73/0xa0 [gre]
[98592.365040]  [<ffffffff813af10d>] ip_local_deliver_finish+0xed/0x2c0
[98592.365040]  [<ffffffff813af360>] ip_local_deliver+0x80/0x90
[98592.365040]  [<ffffffff813ae959>] ip_rcv_finish+0x119/0x3b0
[98592.365040]  [<ffffffff813aef4d>] ip_rcv+0x21d/0x2f0
[98592.365040]  [<ffffffff8137cffc>] __netif_receive_skb+0x20c/0x6c0
[98592.365040]  [<ffffffff81141e15>] ? __kmalloc_node_track_caller+0x55/0x60
[98592.365040]  [<ffffffff8137dbcd>] netif_receive_skb+0xbd/0xd0
[98592.365040]  [<ffffffff8125fcfc>] ? is_swiotlb_buffer+0x3c/0x50
[98593.222041]  [<ffffffff8137dd30>] napi_skb_finish+0x50/0x70
[98593.222041]  [<ffffffff8137e315>] napi_gro_receive+0xc5/0xd0
[98593.222041]  [<ffffffffa01a8e0f>] igb_poll+0x6cf/0xb50 [igb]
[98593.222041]  [<ffffffff8137d004>] ? __netif_receive_skb+0x214/0x6c0
[98593.222041]  [<ffffffff8137d004>] ? __netif_receive_skb+0x214/0x6c0
[98593.222041]  [<ffffffff8137f0d4>] net_rx_action+0x164/0x340
[98593.222041]  [<ffffffff810684b5>] __do_softirq+0xd5/0x270
[98593.222041]  [<ffffffff8143c89c>] call_softirq+0x1c/0x30
[98593.222041]  [<ffffffff8100e6c5>] do_softirq+0x95/0xe0
[98593.222041]  [<ffffffff81068305>] irq_exit+0xd5/0xf0
[98593.222041]  [<ffffffff8100dec1>] do_IRQ+0x61/0xd0
[98593.222041]  [<ffffffff81434753>] common_interrupt+0x13/0x13
[98593.222041]  <EOI>
[98593.222041]  [<ffffffff81015936>] ? mwait_idle+0xe6/0x2b0
[98593.222041]  [<ffffffff8101589a>] ? mwait_idle+0x4a/0x2b0
[98593.222041]  [<ffffffff8100bb76>] cpu_idle+0x66/0xd0
[98593.222041]  [<ffffffff8142c8f9>] start_secondary+0x1bf/0x1c4
[98593.222041] Code: 8b 47 68 55 48 89 e5 39 c6 77 1c 29 f0 3b 47 6c 89 
47 68 72 16 89 f0 48 03 87 e0 00 00 00 48 89 87 e0
  00 00 00 c9 c3 31 c0 c9 c3 <0f> 0b eb fe 90 55 39 77 68 48 89 e5 76 1c 
8b 47 6c 85 c0 75 17
[98593.532028] RIP  [<ffffffff8136ca2b>] skb_pull+0x2b/0x30
[98593.532028]  RSP <ffff88011fc83ab0>
[98593.582191] ---[ end trace 7eee6e2d8ae05a69 ]---
[98593.596115] Kernel panic - not syncing: Fatal exception in interrupt
[98593.596119] Pid: 0, comm: kworker/0:0 Tainted: G      D 
3.0.0-un-def-alt2 #1
------------------------------------------------
Have anybody some ideas?

^ permalink raw reply

* [PATCH] mlx4: Fixing Ethernet unicast packet steering
From: Yevgeny Petrilin @ 2011-08-03 14:24 UTC (permalink / raw)
  To: roland-DgEjT+Ai2ygdnm+yROfE0A
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	yevgenyp-VPRAkNaXOzVS1MOuV/RT9w

For older FW versions, fixing the usage of per port Mac table.
For each port we must define the base QP number, which is passed
to the HW.
Setting the correct value in SET_PORT FW command to enable the steering.

Reported-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Signed-off-by: Yevgeny Petrilin <yevgenyp-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.org>
---
 drivers/net/mlx4/en_port.c |    2 +-
 drivers/net/mlx4/main.c    |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/mlx4/en_port.c b/drivers/net/mlx4/en_port.c
index 5e71091..5ada5b4 100644
--- a/drivers/net/mlx4/en_port.c
+++ b/drivers/net/mlx4/en_port.c
@@ -128,7 +128,7 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
 	memset(context, 0, sizeof *context);
 
 	context->base_qpn = cpu_to_be32(base_qpn);
-	context->n_mac = 0x7;
+	context->n_mac = 0x2;
 	context->promisc = cpu_to_be32(promisc << SET_PORT_PROMISC_SHIFT |
 				       base_qpn);
 	context->mcast = cpu_to_be32(m_promisc << SET_PORT_MC_PROMISC_SHIFT |
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index c94b342..f0ee35d 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -1117,6 +1117,8 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
 	info->port = port;
 	mlx4_init_mac_table(dev, &info->mac_table);
 	mlx4_init_vlan_table(dev, &info->vlan_table);
+	info->base_qpn = dev->caps.reserved_qps_base[MLX4_QP_REGION_ETH_ADDR] +
+			(port - 1) * (1 << log_num_mac);
 
 	sprintf(info->dev_name, "mlx4_port%d", port);
 	info->port_attr.attr.name = info->dev_name;
-- 1.6.0.2 
--
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 related

* [PATCH] mlx4: Fixing Ethernet unicast packet steering
From: Yevgeny Petrilin @ 2011-08-03 14:21 UTC (permalink / raw)
  To: Roland Dreier
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	yevgenyp-VPRAkNaXOzVS1MOuV/RT9w


For older FW versions, fixing the usage of per port Mac table.
For each port we must define the base QP number, which is passed
to the HW.
Setting the correct value in SET_PORT FW command to enable the steering.

Reported-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Signed-off-by: Yevgeny Petrilin <yevgenyp-VPRAkNaXOzVS1MOuV/RT9w@public.gmane.org>
---
 drivers/net/mlx4/en_port.c |    2 +-
 drivers/net/mlx4/main.c    |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/mlx4/en_port.c b/drivers/net/mlx4/en_port.c
index 5e71091..5ada5b4 100644
--- a/drivers/net/mlx4/en_port.c
+++ b/drivers/net/mlx4/en_port.c
@@ -128,7 +128,7 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
 	memset(context, 0, sizeof *context);
 
 	context->base_qpn = cpu_to_be32(base_qpn);
-	context->n_mac = 0x7;
+	context->n_mac = 0x2;
 	context->promisc = cpu_to_be32(promisc << SET_PORT_PROMISC_SHIFT |
 				       base_qpn);
 	context->mcast = cpu_to_be32(m_promisc << SET_PORT_MC_PROMISC_SHIFT |
diff --git a/drivers/net/mlx4/main.c b/drivers/net/mlx4/main.c
index c94b342..f0ee35d 100644
--- a/drivers/net/mlx4/main.c
+++ b/drivers/net/mlx4/main.c
@@ -1117,6 +1117,8 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
 	info->port = port;
 	mlx4_init_mac_table(dev, &info->mac_table);
 	mlx4_init_vlan_table(dev, &info->vlan_table);
+	info->base_qpn = dev->caps.reserved_qps_base[MLX4_QP_REGION_ETH_ADDR] +
+			(port - 1) * (1 << log_num_mac);
 
 	sprintf(info->dev_name, "mlx4_port%d", port);
 	info->port_attr.attr.name = info->dev_name;
-- 
1.6.0.2

--
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 related

* RE: [PATCH ] cdc_ncm: fixes for big-endian architecture / MIPS
From: Alexey ORISHKO @ 2011-08-03 14:07 UTC (permalink / raw)
  To: Giuseppe Scrivano
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	gregkh-l3A5Bk7waGM@public.gmane.org,
	alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
In-Reply-To: <87hb5yock6.fsf-mXXj517/zsQ@public.gmane.org>

> From 8bd65735b4f0db5b6213f59a443c21d0d55dba8e Mon Sep 17 00:00:00 2001
> From: Giuseppe Scrivano <giuseppe-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
> Date: Fri, 15 Jul 2011 15:34:14 +0200
> Subject: [PATCH] cdc_ncm: fix endianess problem.
> 
> Signed-off-by: Giuseppe Scrivano <giuseppe-A9uVI2HLR7kOP4wsBPIw7w@public.gmane.org>
> ---
>  drivers/net/usb/cdc_ncm.c |   65 +++++++++++++++++++++++++-------------------
> -

> +struct cdc_ncm_request {
> +	u8	bRequest;
> +	u8	bmRequestType;
> +	u16	wValue;
> +	u16	wIndex;
> +	u16	wLength;
> +} __packed;

Since it was incorrect to use struct usb_cdc_notification I would rather
remove cdc_ncm_do_request() function and provide u16 parameters directly to 
usb_control_msg without creating yet additional structure for usb control request.

alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" 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: [RFC PATCH] common receive API + r8169 use
From: Michał Mirosław @ 2011-08-03 14:06 UTC (permalink / raw)
  To: Francois Romieu; +Cc: netdev
In-Reply-To: <20110802220108.GA13963@electric-eye.fr.zoreil.com>

On Wed, Aug 03, 2011 at 12:01:08AM +0200, Francois Romieu wrote:
[...a bit of comments...]
> The style is a bit raw but it looks interesting.

I've taken your comments into account. I'll post a new version after I clean it up further.

Thanks,
Michał Mirosław

^ permalink raw reply

* Re: [PATCH] net: Fix security_socket_sendmsg() bypass problem.
From: Anton Blanchard @ 2011-08-03 13:54 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: davem, eparis, casey, mjt, netdev, linux-security-module
In-Reply-To: <201108030325.p733Pplb030986@www262.sakura.ne.jp>

Hi,

> Also, attaching kmalloc()-free version. If performance loss by
> kmalloc()-free version is small enough, can it be a candidate?

Thanks. Running some benchmarks across both versions, will have some
numbers later on today.

Anton

^ permalink raw reply

* Re: [PATCH] net: Fix security_socket_sendmsg() bypass problem.
From: Eduard Sinelnikov @ 2011-08-03 13:37 UTC (permalink / raw)
  To: netdev
In-Reply-To: <20110803232957.5e7a5d0a@kryten>

Hi,

The scenario:
The scenario is:
* Create a bond with 3 interfaces (connect them to switch).
* Change bond's mode to active/backup.
* Physicly remove two cables form interfaces ( not the active interface ).
* Put the cables back
* Change the mode to round robin.
* Try to ping some other computer.

Now only one interface is pinging to remote computer.
Without removing the cables all three interface will ping to remote
computer periodicly.



The problem:
In the kernel 2.6.39.3 ( /drivers/net/bond/bond_main.c).
In the function  ‘bond_xmit_roundrobin’
The code check if the bond is active via
‘bond_is_active_slave(slave)’ Function call.
Which actually checks if the slave is backup or active
What is the meaning of slave being  backup in round robin mode?
Correct me if I wrong but in round robin every slave should send a
packet, regardless of being active or backup.

Thank you,
           Eduard

^ permalink raw reply

* Re: [PATCH] net: Fix security_socket_sendmsg() bypass problem.
From: Anton Blanchard @ 2011-08-03 13:29 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: davem, eparis, casey, mjt, netdev, linux-security-module
In-Reply-To: <201108032120.CHC60420.OVOFQFHMJLSOtF@I-love.SAKURA.ne.jp>

Hi,

> > I much prefer to make the error handling more correct, rather than
> > making sendmmsg() have fundamentally different semantics depending
> > upon the underlying LSM.
> 
> Well, the way how sendmmsg() returns error code is tricky. But
> recvmmsg() has been doing in this way for a while. So, for symmetry
> reason, maybe sendmmsg() should do as with recvmmsg() since it is too
> late to change recvmmsg()'s way.
> 
> So, programmers should be warned (in the man pages) that they should
> always call getsockopt(SO_ERROR) (in order to clear the error code)
> if sendmmsg() or recvmmsg() returned less than requested.

As you suggest, I wanted to mirror how recvmmsg returns errors. But I
now agree with Dave, we should not return an error if we managed to send
any datagrams.

Perhaps we need to modify recvmmsg to do the same?

> By the way, don't we want integer overflow check and/or
> cond_resched() here? I don't know whether there is an arch where
> userspace can allocate (1 << BITS_PER_INT) * sizeof(struct msghdr)
> bytes using malloc() and kernel can allocate huge memory for the
> socket buffer.
> 
> #include <stdio.h>
> int main(int argc, char *argv[])
> {
>         int datagrams = 0;
>         unsigned int vlen = 4294967290U;
>         while (datagrams < vlen)
>                 datagrams++;
>         printf("%u\n", datagrams);
>         return 0;
> }
> 
> I think this program (on x86_32) will print an IS_ERR() value upon
> success.

Good catch. I wonder if we can do something similar to read/write where
we just truncate the length. What value should we use? One option is to
reuse UIO_MAXIOV (1024).

The following patch is compiled tested only so far.

Anton
--

[PATCH] net: Cap number of elements for recvmmsg and sendmmsg 

To limit the amount of time we can spend in recvmmsg and sendmmsg,
cap the number of elements to UIO_MAXIOV (currently 1024). 
       
Signed-off-by: Anton Blanchard <anton@samba.org>
Cc: <stable@kernel.org>
---

diff --git a/net/socket.c b/net/socket.c
index b1cbbcd..ad345b1 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1999,6 +1999,9 @@ int __sys_sendmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 	struct compat_mmsghdr __user *compat_entry;
 	struct msghdr msg_sys;
 
+	if (vlen > UIO_MAXIOV)
+		vlen = UIO_MAXIOV;
+
 	datagrams = 0;
 
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
@@ -2199,6 +2202,9 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 	struct msghdr msg_sys;
 	struct timespec end_time;
 
+	if (vlen > UIO_MAXIOV)
+		vlen = UIO_MAXIOV;
+
 	if (timeout &&
 	    poll_select_set_timeout(&end_time, timeout->tv_sec,
 				    timeout->tv_nsec))

^ permalink raw reply related

* Re: [PATCH ] cdc_ncm: fixes for big-endian architecture / MIPS
From: Giuseppe Scrivano @ 2011-08-03 13:21 UTC (permalink / raw)
  To: alexey.orishko; +Cc: netdev, oliver, linux-usb, gregkh

Hello,

I have reworked the original patch I have submitted to Alexey.

Regards,
Giuseppe



>From 8bd65735b4f0db5b6213f59a443c21d0d55dba8e Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <giuseppe@southpole.se>
Date: Fri, 15 Jul 2011 15:34:14 +0200
Subject: [PATCH] cdc_ncm: fix endianess problem.

Signed-off-by: Giuseppe Scrivano <giuseppe@southpole.se>
---
 drivers/net/usb/cdc_ncm.c |   65 +++++++++++++++++++++++++--------------------
 1 files changed, 36 insertions(+), 29 deletions(-)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index f33ca6a..cd5d819 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -54,7 +54,7 @@
 #include <linux/usb/usbnet.h>
 #include <linux/usb/cdc.h>
 
-#define	DRIVER_VERSION				"01-June-2011"
+#define	DRIVER_VERSION				"03-Aug-2011"
 
 /* CDC NCM subclass 3.2.1 */
 #define USB_CDC_NCM_NDP16_LENGTH_MIN		0x10
@@ -136,6 +136,14 @@ struct cdc_ncm_ctx {
 	u16 connected;
 };
 
+struct cdc_ncm_request {
+	u8	bRequest;
+	u8	bmRequestType;
+	u16	wValue;
+	u16	wIndex;
+	u16	wLength;
+} __packed;
+
 static void cdc_ncm_tx_timeout(unsigned long arg);
 static const struct driver_info cdc_ncm_info;
 static struct usb_driver cdc_ncm_driver;
@@ -165,7 +173,7 @@ cdc_ncm_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
 }
 
 static int
-cdc_ncm_do_request(struct cdc_ncm_ctx *ctx, struct usb_cdc_notification *req,
+cdc_ncm_do_request(struct cdc_ncm_ctx *ctx, struct cdc_ncm_request *req,
 		   void *data, u16 flags, u16 *actlen, u16 timeout)
 {
 	int err;
@@ -173,7 +181,7 @@ cdc_ncm_do_request(struct cdc_ncm_ctx *ctx, struct usb_cdc_notification *req,
 	err = usb_control_msg(ctx->udev, (req->bmRequestType & USB_DIR_IN) ?
 				usb_rcvctrlpipe(ctx->udev, 0) :
 				usb_sndctrlpipe(ctx->udev, 0),
-				req->bNotificationType, req->bmRequestType,
+				req->bRequest, req->bmRequestType,
 				req->wValue,
 				req->wIndex, data,
 				req->wLength, timeout);
@@ -192,7 +200,7 @@ cdc_ncm_do_request(struct cdc_ncm_ctx *ctx, struct usb_cdc_notification *req,
 
 static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 {
-	struct usb_cdc_notification req;
+	struct cdc_ncm_request req;
 	u32 val;
 	u8 flags;
 	u8 iface_no;
@@ -202,10 +210,10 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 	iface_no = ctx->control->cur_altsetting->desc.bInterfaceNumber;
 
 	req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE;
-	req.bNotificationType = USB_CDC_GET_NTB_PARAMETERS;
+	req.bRequest = USB_CDC_GET_NTB_PARAMETERS;
 	req.wValue = 0;
-	req.wIndex = cpu_to_le16(iface_no);
-	req.wLength = cpu_to_le16(sizeof(ctx->ncm_parm));
+	req.wIndex = iface_no;
+	req.wLength = sizeof(ctx->ncm_parm);
 
 	err = cdc_ncm_do_request(ctx, &req, &ctx->ncm_parm, 0, NULL, 1000);
 	if (err) {
@@ -256,9 +264,9 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 	if (ctx->rx_max != le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize)) {
 		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
 							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_SET_NTB_INPUT_SIZE;
+		req.bRequest = USB_CDC_SET_NTB_INPUT_SIZE;
 		req.wValue = 0;
-		req.wIndex = cpu_to_le16(iface_no);
+		req.wIndex = iface_no;
 
 		if (flags & USB_CDC_NCM_NCAP_NTB_INPUT_SIZE) {
 			struct usb_cdc_ncm_ndp_input_size ndp_in_sz;
@@ -335,9 +343,9 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 	if (flags & USB_CDC_NCM_NCAP_CRC_MODE) {
 		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
 							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_SET_CRC_MODE;
-		req.wValue = cpu_to_le16(USB_CDC_NCM_CRC_NOT_APPENDED);
-		req.wIndex = cpu_to_le16(iface_no);
+		req.bRequest = USB_CDC_SET_CRC_MODE;
+		req.wValue = USB_CDC_NCM_CRC_NOT_APPENDED;
+		req.wIndex = iface_no;
 		req.wLength = 0;
 
 		err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
@@ -349,9 +357,9 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 	if (ntb_fmt_supported & USB_CDC_NCM_NTH32_SIGN) {
 		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
 							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_SET_NTB_FORMAT;
-		req.wValue = cpu_to_le16(USB_CDC_NCM_NTB16_FORMAT);
-		req.wIndex = cpu_to_le16(iface_no);
+		req.bRequest = USB_CDC_SET_NTB_FORMAT;
+		req.wValue = USB_CDC_NCM_NTB16_FORMAT;
+		req.wIndex = iface_no;
 		req.wLength = 0;
 
 		err = cdc_ncm_do_request(ctx, &req, NULL, 0, NULL, 1000);
@@ -368,10 +376,10 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 
 		req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN |
 							USB_RECIP_INTERFACE;
-		req.bNotificationType = USB_CDC_GET_MAX_DATAGRAM_SIZE;
+		req.bRequest = USB_CDC_GET_MAX_DATAGRAM_SIZE;
 		req.wValue = 0;
-		req.wIndex = cpu_to_le16(iface_no);
-		req.wLength = cpu_to_le16(2);
+		req.wIndex = iface_no;
+		req.wLength = 2;
 
 		err = cdc_ncm_do_request(ctx, &req, &max_datagram_size, 0, NULL,
 									1000);
@@ -398,9 +406,9 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
 			/* if value changed, update device */
 			req.bmRequestType = USB_TYPE_CLASS | USB_DIR_OUT |
 							USB_RECIP_INTERFACE;
-			req.bNotificationType = USB_CDC_SET_MAX_DATAGRAM_SIZE;
+			req.bRequest = USB_CDC_SET_MAX_DATAGRAM_SIZE;
 			req.wValue = 0;
-			req.wIndex = cpu_to_le16(iface_no);
+			req.wIndex = iface_no;
 			req.wLength = 2;
 			max_datagram_size = cpu_to_le16(ctx->max_datagram_size);
 
@@ -672,7 +680,7 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
 	u32 rem;
 	u32 offset;
 	u32 last_offset;
-	u16 n = 0;
+	u16 n = 0, index;
 	u8 ready2send = 0;
 
 	/* if there is a remaining skb, it gets priority */
@@ -860,8 +868,8 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
 					cpu_to_le16(sizeof(ctx->tx_ncm.nth16));
 	ctx->tx_ncm.nth16.wSequence = cpu_to_le16(ctx->tx_seq);
 	ctx->tx_ncm.nth16.wBlockLength = cpu_to_le16(last_offset);
-	ctx->tx_ncm.nth16.wNdpIndex = ALIGN(sizeof(struct usb_cdc_ncm_nth16),
-							ctx->tx_ndp_modulus);
+	index = ALIGN(sizeof(struct usb_cdc_ncm_nth16), ctx->tx_ndp_modulus);
+	ctx->tx_ncm.nth16.wNdpIndex = cpu_to_le16(index);
 
 	memcpy(skb_out->data, &(ctx->tx_ncm.nth16), sizeof(ctx->tx_ncm.nth16));
 	ctx->tx_seq++;
@@ -874,12 +882,11 @@ cdc_ncm_fill_tx_frame(struct cdc_ncm_ctx *ctx, struct sk_buff *skb)
 	ctx->tx_ncm.ndp16.wLength = cpu_to_le16(rem);
 	ctx->tx_ncm.ndp16.wNextNdpIndex = 0; /* reserved */
 
-	memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex,
+	memcpy(((u8 *)skb_out->data) + index,
 						&(ctx->tx_ncm.ndp16),
 						sizeof(ctx->tx_ncm.ndp16));
 
-	memcpy(((u8 *)skb_out->data) + ctx->tx_ncm.nth16.wNdpIndex +
-					sizeof(ctx->tx_ncm.ndp16),
+	memcpy(((u8 *)skb_out->data) + index + sizeof(ctx->tx_ncm.ndp16),
 					&(ctx->tx_ncm.dpe16),
 					(ctx->tx_curr_frame_num + 1) *
 					sizeof(struct usb_cdc_ncm_dpe16));
@@ -1129,7 +1136,7 @@ cdc_ncm_speed_change(struct cdc_ncm_ctx *ctx,
 static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
 {
 	struct cdc_ncm_ctx *ctx;
-	struct usb_cdc_notification *event;
+	struct cdc_ncm_request *event;
 
 	ctx = (struct cdc_ncm_ctx *)dev->data[0];
 
@@ -1145,7 +1152,7 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
 
 	event = urb->transfer_buffer;
 
-	switch (event->bNotificationType) {
+	switch (event->bRequest) {
 	case USB_CDC_NOTIFY_NETWORK_CONNECTION:
 		/*
 		 * According to the CDC NCM specification ch.7.1
@@ -1177,7 +1184,7 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
 
 	default:
 		dev_err(&dev->udev->dev, "NCM: unexpected "
-			"notification 0x%02x!\n", event->bNotificationType);
+			"notification 0x%02x!\n", event->bRequest);
 		break;
 	}
 }
-- 
1.7.5.4


^ permalink raw reply related

* Re: [PATCH] net: Fix security_socket_sendmsg() bypass problem.
From: Tetsuo Handa @ 2011-08-03 12:20 UTC (permalink / raw)
  To: anton, davem; +Cc: eparis, casey, mjt, netdev, linux-security-module
In-Reply-To: <20110803134752.31347b64@kryten>

David Miller wrote:
> From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Date: Tue, 2 Aug 2011 20:52:05 +0900
> 
> > David Miller wrote:
> >> Actually, I change my mind. :-)
> >> 
> >> I think sendmmsg() needs to unconditionally not report an error if any
> >> datagrams were sent successfully.
> > 
> > What about adding
> 
> I much prefer to make the error handling more correct, rather than
> making sendmmsg() have fundamentally different semantics depending
> upon the underlying LSM.
> 

Well, the way how sendmmsg() returns error code is tricky. But recvmmsg() has
been doing in this way for a while. So, for symmetry reason, maybe sendmmsg()
should do as with recvmmsg() since it is too late to change recvmmsg()'s way.

So, programmers should be warned (in the man pages) that they should always
call getsockopt(SO_ERROR) (in order to clear the error code) if sendmmsg() or
recvmmsg() returned less than requested.

It is inevitable that sendmmsg() behaves differently depending upon the
underlying LSM. If the underlying LSM is SMACK (or TOMOYO), sendmmsg() might
return before all datagrams are sent due to security_socket_sendmsg() returning
an error at the middle of the datagram array. In that case, calling senddmsg()
again (after clearing error code using getsockopt(SO_ERROR)) from (previous'
sendmmsg()'s return value)th element of the datagram array will likely fail
because security_socket_sendmsg() will return the same error again. Thus,
programmers should be warned that they must not expect that resuming sendmmsg()
 from (previous' sendmmsg()'s return value)th element will eventually succeed.

By the way, don't we want integer overflow check and/or cond_resched() here?
I don't know whether there is an arch where userspace can allocate
(1 << BITS_PER_INT) * sizeof(struct msghdr) bytes using malloc() and kernel can
allocate huge memory for the socket buffer.

#include <stdio.h>
int main(int argc, char *argv[])
{
        int datagrams = 0;
        unsigned int vlen = 4294967290U;
        while (datagrams < vlen)
                datagrams++;
        printf("%u\n", datagrams);
        return 0;
}

I think this program (on x86_32) will print an IS_ERR() value upon success.

^ permalink raw reply

* Re: [PATCH net-next] be2net: fix cmd-rx-filter not notifying MCC
From: David Miller @ 2011-08-03 12:19 UTC (permalink / raw)
  To: sathya.perla; +Cc: netdev
In-Reply-To: <1312371993-3015-1-git-send-email-sathya.perla@emulex.com>

From: Sathya Perla <sathya.perla@emulex.com>
Date: Wed, 3 Aug 2011 17:16:33 +0530

> Dave, I missed out on this line while composing the 4/6 patch from my
> yesterday's patchset ("[PATCH net-next 4/6] be2net: use RX_FILTER cmd to program multicast addresses"). As you've already queued up the patchset for net-next,
>  I'm sending the fix in a separate patch. Pls apply.
> 
> Signed-off-by: Sathya Perla <sathya.perla@emulex.com>

Ok, applied, thanks.

^ permalink raw reply

* [PATCH net-next] be2net: fix cmd-rx-filter not notifying MCC
From: Sathya Perla @ 2011-08-03 11:46 UTC (permalink / raw)
  To: netdev

Dave, I missed out on this line while composing the 4/6 patch from my
yesterday's patchset ("[PATCH net-next 4/6] be2net: use RX_FILTER cmd to program multicast addresses"). As you've already queued up the patchset for net-next,
 I'm sending the fix in a separate patch. Pls apply.

Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
---
 drivers/net/benet/be_cmds.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c
index 7292be6..4278595 100644
--- a/drivers/net/benet/be_cmds.c
+++ b/drivers/net/benet/be_cmds.c
@@ -1593,6 +1593,7 @@ int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
 			memcpy(req->mcast_mac[i++].byte, ha->addr, ETH_ALEN);
 	}
 
+	status = be_mcc_notify_wait(adapter);
 err:
 	spin_unlock_bh(&adapter->mcc_lock);
 	return status;
-- 
1.7.4


^ permalink raw reply related

* RE: [PATCH ] cdc_ncm: fixes for big-endian architecture / MIPS
From: Alexey ORISHKO @ 2011-08-03 11:13 UTC (permalink / raw)
  To: David Miller
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org,
	linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	gregkh-l3A5Bk7waGM@public.gmane.org,
	alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
In-Reply-To: <20110803.034253.417905916118311130.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>

> -----Original Message-----
> From: David Miller [mailto:davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org]
> Sent: Wednesday, August 03, 2011 12:43 PM
> To: alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org; linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org;
> gregkh-l3A5Bk7waGM@public.gmane.org; Alexey ORISHKO
> Subject: Re: [PATCH ] cdc_ncm: fixes for big-endian architecture / MIPS
> 
> From: Alexey Orishko <alexey.orishko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Date: Tue,  2 Aug 2011 18:20:26 +0200
> 
> > @@ -203,8 +203,8 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
> >  	req.bmRequestType = USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE;
> >  	req.bNotificationType = USB_CDC_GET_NTB_PARAMETERS;
> >  	req.wValue = 0;
> > -	req.wIndex = cpu_to_le16(iface_no);
> > -	req.wLength = cpu_to_le16(sizeof(ctx->ncm_parm));
> > +	req.wIndex = iface_no;
> > +	req.wLength = sizeof(ctx->ncm_parm);
> >
> >  	err = cdc_ncm_do_request(ctx, &req, &ctx->ncm_parm, 0, NULL, 1000);
> >  	if (err) {
> 
> This can't be correct.
> 
> "iface_no" is a u8 we read out of desc->bInterfaceNumber
> 
> we still have to extend it to a u16 and convert it to a little endian
> 16-bit value for the req.wIndex field.
> 
> If the types for the cdc notification struct are wrong, that's another
> story entirely.  But currently they are marked as __le16 so you must
> resolve this first.

Ok. I see where confusion started...
cdc_ncm is incorrectly using struct usb_cdc_notification (__le16) as input
to usb_control_msg() function, which is expecting u16 data type arguments.

I will post an updated patch shortly.

alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" 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] slip: cleanup statistics generation
From: Matvejchikov Ilya @ 2011-08-03 11:02 UTC (permalink / raw)
  To: David Miller; +Cc: netdev
In-Reply-To: <20110803.032632.1644745928704394302.davem@redhat.com>

2011/8/3 David Miller <davem@redhat.com>:
> Test compile your changes much?
>
> drivers/net/slip.c: In function 'sl_get_stats64':
> drivers/net/slip.c:582:50: error: request for member ‘stats’ in something not a structure or union

OMG, sorry for the typo. Here is the correct patch.

Subject: [PATCH] slip: cleanup statistics generation

Remove unused tx_compressed, tx_compressed and tx_misses fields from
the slip structure. Also, make some device stats generation cleanups.

Signed-off-by: Matvejchikov Ilya <matvejchikov@gmail.com>
---
 drivers/net/slip.c |   29 ++++++++++++++---------------
 drivers/net/slip.h |    9 ---------
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index f11b3f3..cbe8865 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -562,34 +562,33 @@ static struct rtnl_link_stats64 *
 sl_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
 	struct net_device_stats *devstats = &dev->stats;
-	unsigned long c_rx_dropped = 0;
 #ifdef SL_INCLUDE_CSLIP
-	unsigned long c_rx_fifo_errors = 0;
-	unsigned long c_tx_fifo_errors = 0;
-	unsigned long c_collisions = 0;
 	struct slip *sl = netdev_priv(dev);
 	struct slcompress *comp = sl->slcomp;
-
-	if (comp) {
-		c_rx_fifo_errors = comp->sls_i_compressed;
-		c_rx_dropped     = comp->sls_i_tossed;
-		c_tx_fifo_errors = comp->sls_o_compressed;
-		c_collisions     = comp->sls_o_misses;
-	}
-	stats->rx_fifo_errors = sl->rx_compressed + c_rx_fifo_errors;
-	stats->tx_fifo_errors = sl->tx_compressed + c_tx_fifo_errors;
-	stats->collisions     = sl->tx_misses + c_collisions;
 #endif
 	stats->rx_packets     = devstats->rx_packets;
 	stats->tx_packets     = devstats->tx_packets;
 	stats->rx_bytes       = devstats->rx_bytes;
 	stats->tx_bytes       = devstats->tx_bytes;
-	stats->rx_dropped     = devstats->rx_dropped + c_rx_dropped;
+	stats->rx_dropped     = devstats->rx_dropped;
 	stats->tx_dropped     = devstats->tx_dropped;
 	stats->tx_errors      = devstats->tx_errors;
 	stats->rx_errors      = devstats->rx_errors;
 	stats->rx_over_errors = devstats->rx_over_errors;

+#ifdef SL_INCLUDE_CSLIP
+	if (comp) {
+		/* Generic compressed statistics */
+		stats->rx_compressed   = comp->sls_i_compressed;
+		stats->tx_compressed   = comp->sls_o_compressed;
+
+		/* Are we really still needs this? */
+		stats->rx_fifo_errors += comp->sls_i_compressed;
+		stats->rx_dropped     += comp->sls_i_tossed;
+		stats->tx_fifo_errors += comp->sls_o_compressed;
+		stats->collisions     += comp->sls_o_misses;
+	}
+#endif
 	return stats;
 }

diff --git a/drivers/net/slip.h b/drivers/net/slip.h
index aa0764c..67673cf 100644
--- a/drivers/net/slip.h
+++ b/drivers/net/slip.h
@@ -65,15 +65,6 @@ struct slip {
   unsigned char		*xbuff;		/* transmitter buffer		*/
   unsigned char         *xhead;         /* pointer to next byte to XMIT */
   int                   xleft;          /* bytes left in XMIT queue     */
-
-  /* SLIP interface statistics. */
-#ifdef SL_INCLUDE_CSLIP
-  unsigned long		tx_compressed;
-  unsigned long		rx_compressed;
-  unsigned long		tx_misses;
-#endif
-  /* Detailed SLIP statistics. */
-
   int			mtu;		/* Our mtu (to spot changes!)   */
   int                   buffsize;       /* Max buffers sizes            */

-- 
1.7.6

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox