svn commit: r222670 - in head/sys/cddl/compat/opensolaris: kern sys
Author: avg Date: Sat Jun 4 07:02:06 2011 New Revision: 222670 URL: http://svn.freebsd.org/changeset/base/222670 Log: opensolaris compat / zfs: avoid early overflow in ddi_get_lbolt* Reported by: David P. Discher Tested by:will Reviewed by: art Discussed with: dwhite MFC after:2 weeks Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris.c head/sys/cddl/compat/opensolaris/sys/time.h Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris.c == --- head/sys/cddl/compat/opensolaris/kern/opensolaris.c Sat Jun 4 04:35:12 2011(r222669) +++ head/sys/cddl/compat/opensolaris/kern/opensolaris.c Sat Jun 4 07:02:06 2011(r222670) @@ -40,6 +40,7 @@ cpu_core_t cpu_core[MAXCPU]; kmutex_t cpu_lock; solaris_cpu_t solaris_cpu[MAXCPU]; +intnsec_per_tick; /* * OpenSolaris subsystem initialisation. @@ -60,6 +61,8 @@ opensolaris_load(void *dummy) } mutex_init(&cpu_lock, "OpenSolaris CPU lock", MUTEX_DEFAULT, NULL); + + nsec_per_tick = NANOSEC / hz; } SYSINIT(opensolaris_register, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, opensolaris_load, NULL); Modified: head/sys/cddl/compat/opensolaris/sys/time.h == --- head/sys/cddl/compat/opensolaris/sys/time.h Sat Jun 4 04:35:12 2011 (r222669) +++ head/sys/cddl/compat/opensolaris/sys/time.h Sat Jun 4 07:02:06 2011 (r222670) @@ -62,8 +62,21 @@ gethrtime(void) { #definegethrestime(ts) getnanotime(ts) #definegethrtime_waitfree()gethrtime() -#defineddi_get_lbolt() ((gethrtime() * hz) / NANOSEC) -#defineddi_get_lbolt64() (int64_t)((gethrtime() * hz) / NANOSEC) +extern int nsec_per_tick; /* nanoseconds per clock tick */ + +static __inline int64_t +ddi_get_lbolt64(void) +{ + + return (gethrtime() / nsec_per_tick); +} + +static __inline clock_t +ddi_get_lbolt(void) +{ + + return (ddi_get_lbolt64()); +} #else ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222671 - head/sys/mips/cavium
Author: imp Date: Sat Jun 4 07:06:05 2011 New Revision: 222671 URL: http://svn.freebsd.org/changeset/base/222671 Log: Add support for True IDE mode to the Octeon CF driver. This mode is signalled when the attribute address for the CF is 0 in the octeon sysinfo structure. In this mode, the DATA port is 16-bits, but the other ports are 8-bits, but on a 16-bit bus (so you have to access it a short at a time, but only believe the lower byte). See the code for more details on this slightly odd arrangement. I'm still not 100% happy with the abstractions here on many levels (starting with the globals for these settings, on down to no bus_space use, etc), but the driver had these problems before the change. Also, clean up the code a bit to make this support easier, and the code a bit easier to read. I tried to follow existing style, but may have missed a few spots. Add some comments. Fix probe/attach routine to return a proper error for the simulator. With this change, my EBH5200 eval board now recognizes the CF well enough to boot to the login prompt. Before it would say it never became ready. My CN3010-EVB-HS5 still boots properly. My older CN3860-based board won't load the 64-bit kernel, either before or after the change, and I didn't chase that down. Modified: head/sys/mips/cavium/octeon_ebt3000_cf.c Modified: head/sys/mips/cavium/octeon_ebt3000_cf.c == --- head/sys/mips/cavium/octeon_ebt3000_cf.cSat Jun 4 07:02:06 2011 (r222670) +++ head/sys/mips/cavium/octeon_ebt3000_cf.cSat Jun 4 07:06:05 2011 (r222671) @@ -104,12 +104,40 @@ __FBSDID("$FreeBSD$"); extern cvmx_bootinfo_t *octeon_bootinfo; /* Globals */ -intbus_width; +/* + * There's three bus types supported by this driver. + * + * CF_8 -- Traditional PC Card IDE interface on an 8-bit wide bus. We assume + * the bool loader has configure attribute memory properly. We then access + * the device like old-school 8-bit IDE card (which is all a traditional PC Card + * interface really is). + * CF_16 -- Traditional PC Card IDE interface on a 16-bit wide bus. Registers on + * this bus are 16-bits wide too. When accessing registers in the task file, you + * have to do it in 16-bit chunks, and worry about masking out what you don't want + * or ORing together the traditional 8-bit values. We assume the bootloader does + * the right attribute memory initialization dance. + * CF_TRUE_IDE_8 - CF Card wired to True IDE mode. There's no Attribute memory + * space at all. Instead all the traditional 8-bit registers are there, but + * on a 16-bit bus where addr0 isn't wired. This means we need to read/write them + * 16-bit chunks, but only the lower 8 bits are valid. We do not (and can not) + * access this like CF_16 with the comingled registers. Yet we can't access + * this like CF_8 because of the register offset. Except the TF_DATA register + * appears to be full width? + */ void *base_addr; +intbus_type; +#define CF_8 1 /* 8-bit bus, no offsets - PC Card */ +#define CF_16 2 /* 16-bit bus, registers shared - PC Card */ +#define CF_TRUE_IDE_8 3 /* 16-bit bus, only lower 8-bits, TrueIDE */ +const char *const cf_type[] = { + "impossible type", + "CF 8-bit", + "CF 16-bit", + "True IDE" +}; /* Device softc */ struct cf_priv { - device_t dev; struct drive_param *drive_param; @@ -230,9 +258,65 @@ static void cf_start (struct bio *bp) static int cf_ioctl (struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td) { -return (0); + return (0); +} + + +static uint8_t cf_inb_8(int port) +{ + /* +* Traditional 8-bit PC Card/CF bus access. +*/ + if (bus_type == CF_8) { + volatile uint8_t *task_file = (volatile uint8_t *)base_addr; + return task_file[port]; + } + + /* +* True IDE access. lower 8 bits on a 16-bit bus (see above). +*/ + volatile uint16_t *task_file = (volatile uint16_t *)base_addr; + return task_file[port] & 0xff; +} + +static void cf_outb_8(int port, uint8_t val) +{ + /* +* Traditional 8-bit PC Card/CF bus access. +*/ + if (bus_type == CF_8) { + volatile uint8_t *task_file = (volatile uint8_t *)base_addr; + task_file[port] = val; + } + + /* +* True IDE access. lower 8 bits on a 16-bit bus (see above). +*/ + volatile uint16_t *task_file = (volatile uint16_t *)base_addr; + task_file[port] = val & 0xff; +} + +static uint8_t cf_inb_16(int port) +{ + volatile uint16_t *task_file = (volatile uint16_t *)base_addr; + uint16_t val = task_file[port / 2]; + if (port & 1) + return (val >> 8) & 0xff; + return val & 0xff; +} + +static uint16_t cf_inw_1
svn commit: r222672 - head/sys/dev/ath/ath_dfs/null
Author: adrian Date: Sat Jun 4 08:24:58 2011 New Revision: 222672 URL: http://svn.freebsd.org/changeset/base/222672 Log: Commit radar detection changes missed by my previous commit. Modified: head/sys/dev/ath/ath_dfs/null/dfs_null.c Modified: head/sys/dev/ath/ath_dfs/null/dfs_null.c == --- head/sys/dev/ath/ath_dfs/null/dfs_null.cSat Jun 4 07:06:05 2011 (r222671) +++ head/sys/dev/ath/ath_dfs/null/dfs_null.cSat Jun 4 08:24:58 2011 (r222672) @@ -107,7 +107,7 @@ ath_dfs_radar_enable(struct ath_softc *s * Process DFS related PHY errors */ void -ath_dfs_process_phy_err(struct ath_softc *sc, struct ath_desc *ds, +ath_dfs_process_phy_err(struct ath_softc *sc, const char *buf, uint64_t tsf, struct ath_rx_status *rxstat) { ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222673 - head/sys/dev/iicbus
Author: andreast Date: Sat Jun 4 09:19:53 2011 New Revision: 222673 URL: http://svn.freebsd.org/changeset/base/222673 Log: Replace the FCU_ZERO_C_TO_K with the ZERO_C_TO_K from powermac_thermal.h. Approved by: nwhitehorn (mentor) Modified: head/sys/dev/iicbus/ds1775.c Modified: head/sys/dev/iicbus/ds1775.c == --- head/sys/dev/iicbus/ds1775.cSat Jun 4 08:24:58 2011 (r222672) +++ head/sys/dev/iicbus/ds1775.cSat Jun 4 09:19:53 2011 (r222673) @@ -51,8 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include -#define FCU_ZERO_C_TO_K 2732 - /* Drivebay sensor: LM75/DS1775. */ #define DS1775_TEMP 0x0 @@ -211,12 +209,12 @@ ds1775_start(void *xdev) /* Make up target temperatures. These are low, for the drive bay. */ if (sc->sc_sensor.zone == 0) { - sc->sc_sensor.target_temp = 500 + FCU_ZERO_C_TO_K; - sc->sc_sensor.max_temp = 600 + FCU_ZERO_C_TO_K; + sc->sc_sensor.target_temp = 500 + ZERO_C_TO_K; + sc->sc_sensor.max_temp = 600 + ZERO_C_TO_K; } else { - sc->sc_sensor.target_temp = 300 + FCU_ZERO_C_TO_K; - sc->sc_sensor.max_temp = 600 + FCU_ZERO_C_TO_K; + sc->sc_sensor.target_temp = 300 + ZERO_C_TO_K; + sc->sc_sensor.max_temp = 600 + ZERO_C_TO_K; } sc->sc_sensor.read = @@ -248,7 +246,7 @@ ds1775_sensor_read(struct ds1775_softc * /* The default mode of the ADC is 9 bit, the resolution is 0.5 C per bit. The temperature is in tenth kelvin. */ - return (((int16_t)(read) >> 7) * 5 + FCU_ZERO_C_TO_K); + return (((int16_t)(read) >> 7) * 5 + ZERO_C_TO_K); } static int ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222674 - head/sys/dev/iicbus
Author: andreast Date: Sat Jun 4 09:23:54 2011 New Revision: 222674 URL: http://svn.freebsd.org/changeset/base/222674 Log: - Improve error handling. - Add a retry loop for the i2c sensor reading. - Check on busy status of the chip and on invalid values. - Fix a typo in a comment. - Replace the constant 2732 with the ZERO_C_TO_K macro. Approved by: nwhitehorn (mentor) Modified: head/sys/dev/iicbus/max6690.c Modified: head/sys/dev/iicbus/max6690.c == --- head/sys/dev/iicbus/max6690.c Sat Jun 4 09:19:53 2011 (r222673) +++ head/sys/dev/iicbus/max6690.c Sat Jun 4 09:23:54 2011 (r222674) @@ -51,12 +51,11 @@ __FBSDID("$FreeBSD$"); #include #include -#define FCU_ZERO_C_TO_K 2732 - /* Inlet, Backside, U3 Heatsink sensor: MAX6690. */ #define MAX6690_INT_TEMP0x0 #define MAX6690_EXT_TEMP0x1 +#define MAX6690_RSL_STATUS 0x2 #define MAX6690_EEXT_TEMP 0x10 #define MAX6690_IEXT_TEMP 0x11 #define MAX6690_TEMP_MASK 0xe0 @@ -76,8 +75,8 @@ static int max6690_attach(device_t); static int max6690_sensor_read(struct max6690_sensor *sens); static int max6690_sensor_sysctl(SYSCTL_HANDLER_ARGS); static void max6690_start(void *xdev); -static int max6690_read_1(device_t dev, uint32_t addr, uint8_t reg, - uint8_t *data); +static int max6690_read(device_t dev, uint32_t addr, uint8_t reg, +uint8_t *data); struct max6690_softc { device_tsc_dev; @@ -105,23 +104,43 @@ DRIVER_MODULE(max6690, iicbus, max6690_d MALLOC_DEFINE(M_MAX6690, "max6690", "Temp-Monitor MAX6690"); static int -max6690_read_1(device_t dev, uint32_t addr, uint8_t reg, uint8_t *data) +max6690_read(device_t dev, uint32_t addr, uint8_t reg, uint8_t *data) { uint8_t buf[4]; + uint8_t busy[1], rsl; + int err, try = 0; - struct iic_msg msg[2] = { + /* Busy register RSL. */ + rsl = MAX6690_RSL_STATUS; + /* first read the status register, 0x2. If busy, retry. */ + struct iic_msg msg[4] = { + { addr, IIC_M_WR | IIC_M_NOSTOP, 1, &rsl }, + { addr, IIC_M_RD, 1, busy }, { addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, { addr, IIC_M_RD, 1, buf }, }; - if (iicbus_transfer(dev, msg, 2) != 0) { - device_printf(dev, "iicbus read failed\n"); - return (EIO); + for (;;) + { + err = iicbus_transfer(dev, msg, 4); + if (err != 0) + goto retry; + if (busy[0] & 0x80) + goto retry; + /* Check for invalid value and retry. */ + if (buf[0] == 0xff) + goto retry; + + *data = *((uint8_t*)buf); + return (0); + + retry: + if (++try > 5) { + device_printf(dev, "iicbus read failed\n"); + return (-1); + } + pause("max6690_read", hz); } - - *data = *((uint8_t*)buf); - - return (0); } static int @@ -193,8 +212,8 @@ max6690_fill_sensor_prop(device_t dev) for (j = 0; j < i; j++) { sc->sc_sensors[j].dev = dev; - sc->sc_sensors[j].therm.target_temp = 400 + 2732; - sc->sc_sensors[j].therm.max_temp = 800 + 2732; + sc->sc_sensors[j].therm.target_temp = 400 + ZERO_C_TO_K; + sc->sc_sensors[j].therm.max_temp = 800 + ZERO_C_TO_K; sc->sc_sensors[j].therm.read = (int (*)(struct pmac_therm *))(max6690_sensor_read); @@ -302,14 +321,15 @@ static int max6690_sensor_read(struct max6690_sensor *sens) { uint8_t reg_int = 0, reg_ext = 0; - uint8_t integer; - uint8_t fraction; - int temp; + uint8_t integer = 0; + uint8_t fraction = 0; + int err, temp; + struct max6690_softc *sc; sc = device_get_softc(sens->dev); - /* The internal sensor id's are even, the external ar odd. */ + /* The internal sensor id's are even, the external are odd. */ if ((sens->id % 2) == 0) { reg_int = MAX6690_INT_TEMP; reg_ext = MAX6690_IEXT_TEMP; @@ -318,9 +338,11 @@ max6690_sensor_read(struct max6690_senso reg_ext = MAX6690_EEXT_TEMP; } - max6690_read_1(sc->sc_dev, sc->sc_addr, reg_int, &integer); + err = max6690_read(sc->sc_dev, sc->sc_addr, reg_int, &integer); + err = max6690_read(sc->sc_dev, sc->sc_addr, reg_ext, &fraction); - max6690_read_1(sc->sc_dev, sc->sc_addr, reg_ext, &fraction); + if (err < 0) + return (-1); fraction &= MAX6690_TEMP_MASK; @@ -329,7 +351,7 @@ max6690_sensor_read(struct max6690_senso */ temp = (integer * 10) + (fraction >> 5) * 10 / 8;
svn commit: r222675 - head/sys/powerpc/powermac
Author: andreast Date: Sat Jun 4 09:25:59 2011 New Revision: 222675 URL: http://svn.freebsd.org/changeset/base/222675 Log: - Improve error handling. - Add retry loops for the i2c read/write functions. Approved by: nwhitehorn (mentor) Modified: head/sys/powerpc/powermac/fcu.c Modified: head/sys/powerpc/powermac/fcu.c == --- head/sys/powerpc/powermac/fcu.c Sat Jun 4 09:23:54 2011 (r222674) +++ head/sys/powerpc/powermac/fcu.c Sat Jun 4 09:25:59 2011 (r222675) @@ -138,6 +138,8 @@ fcu_write(device_t dev, uint32_t addr, u int len) { unsigned char buf[4]; + int try = 0; + struct iic_msg msg[] = { { addr, IIC_M_WR, 0, buf } }; @@ -145,33 +147,46 @@ fcu_write(device_t dev, uint32_t addr, u msg[0].len = len + 1; buf[0] = reg; memcpy(buf + 1, buff, len); - if (iicbus_transfer(dev, msg, 1) != 0) { - device_printf(dev, "iicbus write failed\n"); - return (EIO); - } - return (0); + for (;;) + { + if (iicbus_transfer(dev, msg, 1) == 0) + return (0); + if (++try > 5) { + device_printf(dev, "iicbus write failed\n"); + return (-1); + } + pause("fcu_write", hz); + } } static int fcu_read_1(device_t dev, uint32_t addr, uint8_t reg, uint8_t *data) { uint8_t buf[4]; + int err, try = 0; struct iic_msg msg[2] = { { addr, IIC_M_WR | IIC_M_NOSTOP, 1, ® }, { addr, IIC_M_RD, 1, buf }, }; - if (iicbus_transfer(dev, msg, 2) != 0) { - device_printf(dev, "iicbus read failed\n"); - return (EIO); + for (;;) + { + err = iicbus_transfer(dev, msg, 2); + if (err != 0) + goto retry; + + *data = *((uint8_t*)buf); + return (0); + retry: + if (++try > 5) { + device_printf(dev, "iicbus read failed\n"); + return (-1); + } + pause("fcu_read_1", hz); } - - *data = *((uint8_t*)buf); - - return (0); } static int @@ -267,13 +282,14 @@ fcu_fan_set_rpm(struct fcu_fan *fan, int fan->setpoint = rpm; } else { device_printf(fan->dev, "Unknown fan type: %d\n", fan->type); - return (EIO); + return (-1); } buf[0] = rpm >> (8 - fcu_rpm_shift); buf[1] = rpm << fcu_rpm_shift; - fcu_write(sc->sc_dev, sc->sc_addr, reg, buf, 2); + if (fcu_write(sc->sc_dev, sc->sc_addr, reg, buf, 2) < 0) + return (-1); return (0); } @@ -292,7 +308,8 @@ fcu_fan_get_rpm(struct fcu_fan *fan) if (fan->type == FCU_FAN_RPM) { /* Check if the fan is available. */ reg = FCU_RPM_AVAILABLE; - fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &avail); + if (fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &avail) < 0) + return (-1); if ((avail & (1 << fan->id)) == 0) { device_printf(fan->dev, "RPM Fan not available ID: %d\n", fan->id); @@ -300,7 +317,8 @@ fcu_fan_get_rpm(struct fcu_fan *fan) } /* Check if we have a failed fan. */ reg = FCU_RPM_FAIL; - fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &fail); + if (fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &fail) < 0) + return (-1); if ((fail & (1 << fan->id)) != 0) { device_printf(fan->dev, "RPM Fan failed ID: %d\n", fan->id); @@ -308,7 +326,8 @@ fcu_fan_get_rpm(struct fcu_fan *fan) } /* Check if fan is active. */ reg = FCU_RPM_ACTIVE; - fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &active); + if (fcu_read_1(sc->sc_dev, sc->sc_addr, reg, &active) < 0) + return (-1); if ((active & (1 << fan->id)) == 0) { device_printf(fan->dev, "RPM Fan not active ID: %d\n", fan->id); @@ -322,7 +341,8 @@ fcu_fan_get_rpm(struct fcu_fan *fan) } /* It seems that we can read the fans rpm. */ - fcu_read_1(sc->sc_dev, sc->sc_addr, reg, buff); + if (fcu_read_1(sc->sc_dev, sc->sc_addr, reg, buff) < 0) + return (-1); rpm = (buff[0] << (8 - fcu_rpm_shift)) | buff[1] >> fcu_rpm_shift; @@ -356,8 +376,8 @@ fcu_fan_set_pwm(struct fcu_fan *fan, int buf[0] = (pwm * 2550) / 1000; - fcu_write(sc->sc_dev, sc->sc_addr, reg,
Re: svn commit: r222449 - in head/sys: conf dev/iicbus powerpc/conf
Hi, sorry for the delay. On 29.05.11 17:10, Henrik Brix Andersen wrote: Hi, On May 29, 2011, at 16:25, Andreas Tobler wrote: Author: andreast Date: Sun May 29 14:25:42 2011 New Revision: 222449 URL: http://svn.freebsd.org/changeset/base/222449 Log: Add a new driver, the ad7417, to read temperatures and voltages on some PowerMac's. Approved by: nwhitehorn (mentor) Added: head/sys/dev/iicbus/ad7417.c (contents, props changed) Modified: head/sys/conf/files.powerpc head/sys/powerpc/conf/GENERIC head/sys/powerpc/conf/GENERIC64 head/sys/powerpc/conf/NOTES Since this driver is powerpc-only (the chip is not powerpc-specific - but this driver depends on OFW?) shouldn't it live somewhere under sys/powerpc/ instead of the generic sys/dev/iicbus/? Or perhaps be rewritten to a more generic form? The chip itself is not PowerMac specific. It contains four times the functionality of the ad7418 which is already in there. (dev/iicbus) The ofw is only needed to detect the chip and to wire the sensor place to the right fan property. I think this could be refactored that it is PowerMac only and others could benefit from the driver too. The same would apply for the ds1775.c and the max6690.c. Those chips are not PowerMac only, they are simple i2c temp sensors. To get there, it would really be helpful if there are other people with non PowerMac hardware who would have an interest in these drivers. Then we could sit together, refactor and test. W/o the corresponding hardware it seems a bit difficult for me to test. A few months ago I asked on hackers@ how I could combine those two drivers. I got no feedback. Now we're heading towards 9.0 and we (nwhitehorn@) wanted to get this driver in. We need these drivers to run certain G5 PowerMac's in a silent mode. W/o we have a swarm of bees which makes it very hard to concentrate ;) Gruss, Andreas ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r222449 - in head/sys: conf dev/iicbus powerpc/conf
Hi, On Jun 4, 2011, at 11:45, Andreas Tobler wrote: > The chip itself is not PowerMac specific. It contains four times the > functionality of the ad7418 which is already in there. (dev/iicbus) > > The ofw is only needed to detect the chip and to wire the sensor place to the > right fan property. I think this could be refactored that it is PowerMac only > and others could benefit from the driver too. Right. Since iicbus(4) is a hinted bus, I believe the current scenario could be improved either by having a dynamic hints system (and an OFW specific layer that added hints about known devices at runtime) or perhaps an OFW iicbus subclass (didn't Nathan start on this in r186833?). > The same would apply for the ds1775.c and the max6690.c. Those chips are not > PowerMac only, they are simple i2c temp sensors. Agreed. > To get there, it would really be helpful if there are other people with non > PowerMac hardware who would have an interest in these drivers. > Then we could sit together, refactor and test. W/o the corresponding hardware > it seems a bit difficult for me to test. I'd love to help. I'll try getting my hands on the raw chips and wire them up to my glxiic(4) based lab setup. I'll get back to you then. Brix -- Henrik Brix Andersen PGP.sig Description: This is a digitally signed message part
Re: svn commit: r222670 - in head/sys/cddl/compat/opensolaris: kern sys
If we are "fixing" this, what about following pjd's rules and moving in direction vendor code (reducing diff)? Or is it too expensive? If that way: a) the nsec_per_tick is defined in vendor code "usr/src/uts/common/conf/param.c". Maybe we should define it at least in sys/cddl/compat/opensolaris/sys/param.h and not in time.h b) sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c might contain the functions as in vendor code (uts/common/os/sunddi.c): clock_t ddi_get_lbolt(void) { return ((clock_t)lbolt_hybrid()); } int64_t ddi_get_lbolt64(void) { return (lbolt_hybrid()); } c) sys/cddl/compat/opensolaris/sys/time.h: extern clock_t ddi_get_lbolt(void); extern int64_t ddi_get_lbolt64(void); d) we might want a new file called sys/cddl/compat/opensolaris/kern/opensolaris_clock.c (uts/common/os/clock.c): int64_t lbolt_hybrid(void) { return (gethrtime() / nsec_per_tick); } The d) step with lbolt_hybrid might be omitted and the function result integrated directly into opensolaris_sunddi.c. Bud regardless of that, notice the clock_t cast in ddi_get_lbolt(). mm Dňa 04.06.2011 09:02, Andriy Gapon wrote / napísal(a): > Author: avg > Date: Sat Jun 4 07:02:06 2011 > New Revision: 222670 > URL: http://svn.freebsd.org/changeset/base/222670 > > Log: > opensolaris compat / zfs: avoid early overflow in ddi_get_lbolt* > > Reported by:David P. Discher > Tested by: will > Reviewed by:art > Discussed with: dwhite > MFC after: 2 weeks > > Modified: > head/sys/cddl/compat/opensolaris/kern/opensolaris.c > head/sys/cddl/compat/opensolaris/sys/time.h > > Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris.c > == > --- head/sys/cddl/compat/opensolaris/kern/opensolaris.c Sat Jun 4 > 04:35:12 2011(r222669) > +++ head/sys/cddl/compat/opensolaris/kern/opensolaris.c Sat Jun 4 > 07:02:06 2011(r222670) > @@ -40,6 +40,7 @@ > cpu_core_t cpu_core[MAXCPU]; > kmutex_t cpu_lock; > solaris_cpu_tsolaris_cpu[MAXCPU]; > +int nsec_per_tick; > > /* > * OpenSolaris subsystem initialisation. > @@ -60,6 +61,8 @@ opensolaris_load(void *dummy) > } > > mutex_init(&cpu_lock, "OpenSolaris CPU lock", MUTEX_DEFAULT, NULL); > + > + nsec_per_tick = NANOSEC / hz; > } > > SYSINIT(opensolaris_register, SI_SUB_OPENSOLARIS, SI_ORDER_FIRST, > opensolaris_load, NULL); > > Modified: head/sys/cddl/compat/opensolaris/sys/time.h > == > --- head/sys/cddl/compat/opensolaris/sys/time.h Sat Jun 4 04:35:12 > 2011(r222669) > +++ head/sys/cddl/compat/opensolaris/sys/time.h Sat Jun 4 07:02:06 > 2011(r222670) > @@ -62,8 +62,21 @@ gethrtime(void) { > #define gethrestime(ts) getnanotime(ts) > #define gethrtime_waitfree()gethrtime() > > -#define ddi_get_lbolt() ((gethrtime() * hz) / NANOSEC) > -#define ddi_get_lbolt64() (int64_t)((gethrtime() * hz) / NANOSEC) > +extern int nsec_per_tick;/* nanoseconds per clock tick */ > + > +static __inline int64_t > +ddi_get_lbolt64(void) > +{ > + > + return (gethrtime() / nsec_per_tick); > +} > + > +static __inline clock_t > +ddi_get_lbolt(void) > +{ > + > + return (ddi_get_lbolt64()); > +} > > #else > ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222676 - in head: bin/sh tools/regression/bin/sh/execution
Author: jilles Date: Sat Jun 4 11:28:42 2011 New Revision: 222676 URL: http://svn.freebsd.org/changeset/base/222676 Log: sh: Honour -n while processing -c string. Added: head/tools/regression/bin/sh/execution/set-n4.0 (contents, props changed) Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Sat Jun 4 09:25:59 2011(r222675) +++ head/bin/sh/eval.c Sat Jun 4 11:28:42 2011(r222676) @@ -165,7 +165,7 @@ evalstring(char *s, int flags) setstackmark(&smark); setinputstring(s, 1); while ((n = parsecmd(0)) != NEOF) { - if (n != NULL) { + if (n != NULL && !nflag) { if (flags_exit && preadateof()) evaltree(n, flags | EV_EXIT); else Added: head/tools/regression/bin/sh/execution/set-n4.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/execution/set-n4.0 Sat Jun 4 11:28:42 2011(r222676) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +$SH -nc 'echo bad' ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222679 - head/sys/dev/iwn
Author: bschmidt Date: Sat Jun 4 11:43:09 2011 New Revision: 222679 URL: http://svn.freebsd.org/changeset/base/222679 Log: The firmware of 4965 series adapters seems to die while trying to send probe requests at 1Mbps while being associated on a 5GHz channel. Sending those at 6Mbps does work, so use that instead during a background scan. This workaround allows us to re-enable background scan support for the 4965 adapters. Also, just enabling one antenna on 5GHz results in better reception of beacons: test00:26:5a:c6:14:1a 40 54M -71:-95 200 EWME HTCAP ATH vs test00:26:5a:c6:14:1a 40 54M -92:-95 200 EWME HTCAP ATH Due to roam:rssi thresholds set to 7 by default it might have been impossible to associate to that network. While here use IEEE80211_IS_CHAN_5GHZ() to determine the band. Modified: head/sys/dev/iwn/if_iwn.c Modified: head/sys/dev/iwn/if_iwn.c == --- head/sys/dev/iwn/if_iwn.c Sat Jun 4 11:30:12 2011(r222678) +++ head/sys/dev/iwn/if_iwn.c Sat Jun 4 11:43:09 2011(r222679) @@ -567,6 +567,7 @@ iwn_attach(device_t dev) ic->ic_caps = IEEE80211_C_STA /* station mode supported */ | IEEE80211_C_MONITOR /* monitor mode supported */ + | IEEE80211_C_BGSCAN/* background scanning */ | IEEE80211_C_TXPMGT/* tx power management */ | IEEE80211_C_SHSLOT/* short slot time supported */ | IEEE80211_C_WPA @@ -576,8 +577,6 @@ iwn_attach(device_t dev) #endif | IEEE80211_C_WME /* WME */ ; - if (sc->hw_type != IWN_HW_REV_TYPE_4965) - ic->ic_caps |= IEEE80211_C_BGSCAN; /* background scanning */ /* Read MAC address, channels, etc from EEPROM. */ if ((error = iwn_read_eeprom(sc, macaddr)) != 0) { @@ -5161,7 +5160,7 @@ iwn_scan(struct iwn_softc *sc) if (IEEE80211_IS_CHAN_A(ic->ic_curchan) && sc->hw_type == IWN_HW_REV_TYPE_4965) { /* Ant A must be avoided in 5GHz because of an HW bug. */ - rxchain |= IWN_RXCHAIN_FORCE_SEL(IWN_ANT_BC); + rxchain |= IWN_RXCHAIN_FORCE_SEL(IWN_ANT_B); } else /* Use all available RX antennas. */ rxchain |= IWN_RXCHAIN_FORCE_SEL(sc->rxchainmask); hdr->rxchain = htole16(rxchain); @@ -5172,14 +5171,19 @@ iwn_scan(struct iwn_softc *sc) tx->id = sc->broadcast_id; tx->lifetime = htole32(IWN_LIFETIME_INFINITE); - if (IEEE80211_IS_CHAN_A(ic->ic_curchan)) { + if (IEEE80211_IS_CHAN_5GHZ(ic->ic_curchan)) { /* Send probe requests at 6Mbps. */ tx->rate = htole32(0xd); rs = &ic->ic_sup_rates[IEEE80211_MODE_11A]; } else { hdr->flags = htole32(IWN_RXON_24GHZ | IWN_RXON_AUTO); - /* Send probe requests at 1Mbps. */ - tx->rate = htole32(10 | IWN_RFLAG_CCK); + if (sc->hw_type == IWN_HW_REV_TYPE_4965 && + sc->rxon.associd && sc->rxon.chan > 14) + tx->rate = htole32(0xd); + else { + /* Send probe requests at 1Mbps. */ + tx->rate = htole32(10 | IWN_RFLAG_CCK); + } rs = &ic->ic_sup_rates[IEEE80211_MODE_11G]; } /* Use the first valid TX antenna. */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222680 - head/sys/dev/iwn
Author: bschmidt Date: Sat Jun 4 11:56:20 2011 New Revision: 222680 URL: http://svn.freebsd.org/changeset/base/222680 Log: Only consider QoS frames for TX packet aggregation. Modified: head/sys/dev/iwn/if_iwn.c Modified: head/sys/dev/iwn/if_iwn.c == --- head/sys/dev/iwn/if_iwn.c Sat Jun 4 11:43:09 2011(r222679) +++ head/sys/dev/iwn/if_iwn.c Sat Jun 4 11:56:20 2011(r222680) @@ -3314,7 +3314,8 @@ iwn_tx_data(struct iwn_softc *sc, struct } ac = M_WME_GETAC(m); - if (IEEE80211_AMPDU_RUNNING(&ni->ni_tx_ampdu[ac])) { + if (IEEE80211_QOS_HAS_SEQ(wh) && + IEEE80211_AMPDU_RUNNING(&ni->ni_tx_ampdu[ac])) { struct ieee80211_tx_ampdu *tap = &ni->ni_tx_ampdu[ac]; ring = &sc->txq[*(int *)tap->txa_private]; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222681 - head/usr.sbin/bsdinstall/scripts
Author: bz Date: Sat Jun 4 12:51:22 2011 New Revision: 222681 URL: http://svn.freebsd.org/changeset/base/222681 Log: Fix resolv.conf search list creation: 1) do not print out an empty "search ", things do not like it. 2) the search list is not comma separated. Sponsored by: The FreeBSD Foundation Sponsored by: iXsystems Modified: head/usr.sbin/bsdinstall/scripts/netconfig Modified: head/usr.sbin/bsdinstall/scripts/netconfig == --- head/usr.sbin/bsdinstall/scripts/netconfig Sat Jun 4 11:56:20 2011 (r222680) +++ head/usr.sbin/bsdinstall/scripts/netconfig Sat Jun 4 12:51:22 2011 (r222681) @@ -173,8 +173,7 @@ exec 3>&- echo ${RESOLV} | tr ' ' '\n' | \ awk ' BEGIN { - search=1 - printf "search "; + search=-1; } { if (/^[[:space:]]+$/) { @@ -185,8 +184,13 @@ BEGIN { search=0; next; } + if (search == -1) { + printf "search "; + search=1; + } if (search > 0) { - printf "%s%s", (search > 1) ? "," : "", $1; + printf "%s%s", (search > 1) ? " " : "", $1; + search++; next; } printf "nameserver %s\n", $1; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222682 - head/sys/net80211
Author: bschmidt Date: Sat Jun 4 14:28:09 2011 New Revision: 222682 URL: http://svn.freebsd.org/changeset/base/222682 Log: Data frames sent over the mgmt path might be part of a TX aggr session too. In that case don't fiddle with the seqno as drivers are supposed to handle that. Currently only the powersave feature does sent QoS-null-data frames before and after a background scan which must be handled correctly. Due to this being quite rare we don't fiddle around with starting of aggr sessions. Modified: head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_output.c == --- head/sys/net80211/ieee80211_output.cSat Jun 4 12:51:22 2011 (r222681) +++ head/sys/net80211/ieee80211_output.cSat Jun 4 14:28:09 2011 (r222682) @@ -516,6 +516,7 @@ ieee80211_send_setup( { #defineWH4(wh) ((struct ieee80211_frame_addr4 *)wh) struct ieee80211vap *vap = ni->ni_vap; + struct ieee80211_tx_ampdu *tap; struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *); ieee80211_seq seqno; @@ -583,9 +584,15 @@ ieee80211_send_setup( } *(uint16_t *)&wh->i_dur[0] = 0; - seqno = ni->ni_txseqs[tid]++; - *(uint16_t *)&wh->i_seq[0] = htole16(seqno << IEEE80211_SEQ_SEQ_SHIFT); - M_SEQNO_SET(m, seqno); + tap = &ni->ni_tx_ampdu[TID_TO_WME_AC(tid)]; + if (tid != IEEE80211_NONQOS_TID && IEEE80211_AMPDU_RUNNING(tap)) + m->m_flags |= M_AMPDU_MPDU; + else { + seqno = ni->ni_txseqs[tid]++; + *(uint16_t *)&wh->i_seq[0] = + htole16(seqno << IEEE80211_SEQ_SEQ_SHIFT); + M_SEQNO_SET(m, seqno); + } if (IEEE80211_IS_MULTICAST(wh->i_addr1)) m->m_flags |= M_MCAST; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r222488 - in head/sys: contrib/pf/net netinet netinet/ipfw netinet6
Hi, I'm seeing a panic when I start natd, which I suspect is related to this commit: panic: Lock pcbinfohash not exclusively locked @ /usr/src/sys/netinet/in_pcb.c:323 Backtrace: panic() ... _rw_assert() at _rw_assert+0x18d in_pcbbind() at in_pcbbind+0xf5 div_bind() at div_bind+0xb9 sobind() at sobind()+0x79 kern_bind() at kern_bind+0xde bind() at bind()+0x41 syscallenter() at syscallenter+0x1cb syscall() at syscall+0x4c Xfast_syscall() at Xfast_syscall+0xdd div_bind probably also needs to surround the call to in_pcbbind with INP_HASHW(UN)LOCK(...) I'm currently running 222680. I've only now seen the issue, but I've also just now activated INVARIANTS. Regards, Kristof On 2011-05-30 09:43:55 (+), Robert Watson wrote: > Author: rwatson > Date: Mon May 30 09:43:55 2011 > New Revision: 222488 > URL: http://svn.freebsd.org/changeset/base/222488 > > Log: > Decompose the current single inpcbinfo lock into two locks: > > - The existing ipi_lock continues to protect the global inpcb list and > inpcb counter. This lock is now relegated to a small number of > allocation and free operations, and occasional operations that walk > all connections (including, awkwardly, certain UDP multicast receive > operations -- something to revisit). > > - A new ipi_hash_lock protects the two inpcbinfo hash tables for > looking up connections and bound sockets, manipulated using new > INP_HASH_*() macros. This lock, combined with inpcb locks, protects > the 4-tuple address space. > > Unlike the current ipi_lock, ipi_hash_lock follows the individual inpcb > connection locks, so may be acquired while manipulating a connection on > which a lock is already held, avoiding the need to acquire the inpcbinfo > lock preemptively when a binding change might later be required. As a > result, however, lookup operations necessarily go through a reference > acquire while holding the lookup lock, later acquiring an inpcb lock -- > if required. > > A new function in_pcblookup() looks up connections, and accepts flags > indicating how to return the inpcb. Due to lock order changes, callers > no longer need acquire locks before performing a lookup: the lookup > routine will acquire the ipi_hash_lock as needed. In the future, it will > also be able to use alternative lookup and locking strategies > transparently to callers, such as pcbgroup lookup. New lookup flags are, > supplementing the existing INPLOOKUP_WILDCARD flag: > > INPLOOKUP_RLOCKPCB - Acquire a read lock on the returned inpcb > INPLOOKUP_WLOCKPCB - Acquire a write lock on the returned inpcb > > Callers must pass exactly one of these flags (for the time being). > > Some notes: > > - All protocols are updated to work within the new regime; especially, > TCP, UDPv4, and UDPv6. pcbinfo ipi_lock acquisitions are largely > eliminated, and global hash lock hold times are dramatically reduced > compared to previous locking. > - The TCP syncache still relies on the pcbinfo lock, something that we > may want to revisit. > - Support for reverting to the FreeBSD 7.x locking strategy in TCP input > is no longer available -- hash lookup locks are now held only very > briefly during inpcb lookup, rather than for potentially extended > periods. However, the pcbinfo ipi_lock will still be acquired if a > connection state might change such that a connection is added or > removed. > - Raw IP sockets continue to use the pcbinfo ipi_lock for protection, > due to maintaining their own hash tables. > - The interface in6_pcblookup_hash_locked() is maintained, which allows > callers to acquire hash locks and perform one or more lookups atomically > with 4-tuple allocation: this is required only for TCPv6, as there is no > in6_pcbconnect_setup(), which there should be. > - UDPv6 locking remains significantly more conservative than UDPv4 > locking, which relates to source address selection. This needs > attention, as it likely significantly reduces parallelism in this code > for multithreaded socket use (such as in BIND). > - In the UDPv4 and UDPv6 multicast cases, we need to revisit locking > somewhat, as they relied on ipi_lock to stablise 4-tuple matches, which > is no longer sufficient. A second check once the inpcb lock is held > should do the trick, keeping the general case from requiring the inpcb > lock for every inpcb visited. > - This work reminds us that we need to revisit locking of the v4/v6 flags, > which may be accessed lock-free both before and after this change. > - Right now, a single lock name is used for the pcbhash lock -- this is > undesirable, and probably another argument is required to take care of > this (or a char array name field in the pcbinfo?). > > This is not an MFC candidate for 8.x due to its impact on lookup and > locking semantics. It's possible
svn commit: r222683 - head/sys/net80211
Author: bschmidt Date: Sat Jun 4 15:05:32 2011 New Revision: 222683 URL: http://svn.freebsd.org/changeset/base/222683 Log: Certain adapters have HT40 support on some but not all channels. The Intel 4965 devices for example have HT40 on 2GHz completely disabled but it is still supported for 5GHz. To handle that in sta mode we need to check if we can "upgrade" to a HT40 channel after the association, if that is not possible but we are still announcing support to the remote side we are left with a very flabby connection. Reviewed by: adrian Modified: head/sys/net80211/ieee80211_ht.c Modified: head/sys/net80211/ieee80211_ht.c == --- head/sys/net80211/ieee80211_ht.cSat Jun 4 14:28:09 2011 (r222682) +++ head/sys/net80211/ieee80211_ht.cSat Jun 4 15:05:32 2011 (r222683) @@ -2520,6 +2520,7 @@ ieee80211_add_htcap_body(uint8_t *frm, s frm[1] = (v) >> 8; \ frm += 2; \ } while (0) + struct ieee80211com *ic = ni->ni_ic; struct ieee80211vap *vap = ni->ni_vap; uint16_t caps, extcaps; int rxmax, density; @@ -2543,6 +2544,17 @@ ieee80211_add_htcap_body(uint8_t *frm, s /* use advertised setting (XXX locally constraint) */ rxmax = MS(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU); density = MS(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY); + + /* +* NB: Hardware might support HT40 on some but not all +* channels. We can't determine this earlier because only +* after association the channel is upgraded to HT based +* on the negotiated capabilities. +*/ + if (ni->ni_chan != IEEE80211_CHAN_ANYC && + findhtchan(ic, ni->ni_chan, IEEE80211_CHAN_HT40U) == NULL && + findhtchan(ic, ni->ni_chan, IEEE80211_CHAN_HT40D) == NULL) + caps &= ~IEEE80211_HTCAP_CHWIDTH40; } else { /* override 20/40 use based on current channel */ if (IEEE80211_IS_CHAN_HT40(ni->ni_chan)) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222684 - in head: bin/sh tools/regression/bin/sh/builtins
Author: jilles Date: Sat Jun 4 15:05:52 2011 New Revision: 222684 URL: http://svn.freebsd.org/changeset/base/222684 Log: sh: Reduce more needless differences between error messages. Modified: head/bin/sh/alias.c head/bin/sh/input.c head/bin/sh/jobs.c head/bin/sh/main.c head/tools/regression/bin/sh/builtins/alias.1.stderr Modified: head/bin/sh/alias.c == --- head/bin/sh/alias.c Sat Jun 4 15:05:32 2011(r222683) +++ head/bin/sh/alias.c Sat Jun 4 15:05:52 2011(r222684) @@ -238,7 +238,7 @@ aliascmd(int argc, char **argv) while ((n = *++argv) != NULL) { if ((v = strchr(n+1, '=')) == NULL) /* n+1: funny ksh stuff */ if ((ap = lookupalias(n, 0)) == NULL) { - warning("%s not found", n); + warning("%s: not found", n); ret = 1; } else printalias(ap); Modified: head/bin/sh/input.c == --- head/bin/sh/input.c Sat Jun 4 15:05:32 2011(r222683) +++ head/bin/sh/input.c Sat Jun 4 15:05:52 2011(r222684) @@ -403,7 +403,7 @@ setinputfile(const char *fname, int push INTOFF; if ((fd = open(fname, O_RDONLY)) < 0) - error("Can't open %s: %s", fname, strerror(errno)); + error("cannot open %s: %s", fname, strerror(errno)); if (fd < 10) { fd2 = fcntl(fd, F_DUPFD, 10); close(fd); Modified: head/bin/sh/jobs.c == --- head/bin/sh/jobs.c Sat Jun 4 15:05:32 2011(r222683) +++ head/bin/sh/jobs.c Sat Jun 4 15:05:52 2011(r222684) @@ -820,7 +820,7 @@ forkshell(struct job *jp, union node *n, ! fd0_redirected_p ()) { close(0); if (open(_PATH_DEVNULL, O_RDONLY) != 0) - error("Can't open %s: %s", + error("cannot open %s: %s", _PATH_DEVNULL, strerror(errno)); } } @@ -832,7 +832,7 @@ forkshell(struct job *jp, union node *n, ! fd0_redirected_p ()) { close(0); if (open(_PATH_DEVNULL, O_RDONLY) != 0) - error("Can't open %s: %s", + error("cannot open %s: %s", _PATH_DEVNULL, strerror(errno)); } } Modified: head/bin/sh/main.c == --- head/bin/sh/main.c Sat Jun 4 15:05:32 2011(r222683) +++ head/bin/sh/main.c Sat Jun 4 15:05:52 2011(r222684) @@ -264,7 +264,7 @@ readcmdfile(const char *name) if ((fd = open(name, O_RDONLY)) >= 0) setinputfd(fd, 1); else - error("Can't open %s: %s", name, strerror(errno)); + error("cannot open %s: %s", name, strerror(errno)); INTON; cmdloop(0); popfile(); Modified: head/tools/regression/bin/sh/builtins/alias.1.stderr == --- head/tools/regression/bin/sh/builtins/alias.1.stderrSat Jun 4 15:05:32 2011(r222683) +++ head/tools/regression/bin/sh/builtins/alias.1.stderrSat Jun 4 15:05:52 2011(r222684) @@ -1 +1 @@ -alias: foo not found +alias: foo: not found ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Divert socket problem (was: Re: svn commit: r222488 - in head/sys: contrib/pf/net netinet netinet/ipfw netinet6)
On 4 Jun 2011, at 15:30, Kristof Provost wrote: > div_bind probably also needs to surround the call to in_pcbbind with > INP_HASHW(UN)LOCK(...) > > I'm currently running 222680. I've only now seen the issue, but I've also > just now activated INVARIANTS. Hi Kristof: Thanks for the detailed report, and yes, it looks like that is exactly what is required. Could you try the attached patch? Robert 20110604-divert-fix.diff Description: Binary data ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222686 - in head/sys: conf powerpc/conf powerpc/powermac
Author: andreast Date: Sat Jun 4 15:17:35 2011 New Revision: 222686 URL: http://svn.freebsd.org/changeset/base/222686 Log: Add new fan controller driver for the G4 MDD PowerMac. Submitted and tested by Justin Hibbits. Approved by: nwhitehorn (mentor) Added: head/sys/powerpc/powermac/windtunnel.c (contents, props changed) Modified: head/sys/conf/files.powerpc head/sys/powerpc/conf/GENERIC head/sys/powerpc/conf/NOTES Modified: head/sys/conf/files.powerpc == --- head/sys/conf/files.powerpc Sat Jun 4 15:15:42 2011(r222685) +++ head/sys/conf/files.powerpc Sat Jun 4 15:17:35 2011(r222686) @@ -162,6 +162,7 @@ powerpc/powermac/smusat.c optionalpower powerpc/powermac/uninorth.coptionalpowermac powerpc/powermac/uninorthpci.c optionalpowermac pci powerpc/powermac/vcoregpio.c optionalpowermac +powerpc/powermac/windtunnel.c optionalpowermac windtunnel powerpc/powerpc/altivec.c optionalaim powerpc/powerpc/atomic.S standard powerpc/powerpc/autoconf.c standard Modified: head/sys/powerpc/conf/GENERIC == --- head/sys/powerpc/conf/GENERIC Sat Jun 4 15:15:42 2011 (r222685) +++ head/sys/powerpc/conf/GENERIC Sat Jun 4 15:17:35 2011 (r222686) @@ -180,6 +180,7 @@ device fcu # Apple Fan Control Unit device max6690 # PowerMac7,2 temperature sensor device powermac_nvram # Open Firmware configuration NVRAM device smu # Apple System Management Unit +device windtunnel # Apple G4 MDD fan controller # ADB support device adb Modified: head/sys/powerpc/conf/NOTES == --- head/sys/powerpc/conf/NOTES Sat Jun 4 15:15:42 2011(r222685) +++ head/sys/powerpc/conf/NOTES Sat Jun 4 15:17:35 2011(r222686) @@ -47,6 +47,7 @@ devicepmu # Apple Power Management Un device smu # Apple System Management Unit device snd_ai2s# Apple I2S Audio device snd_davbus # Apple Davbus Audio +device windtunnel # Apple G4 MDD fan controller # Added: head/sys/powerpc/powermac/windtunnel.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/powerpc/powermac/windtunnel.c Sat Jun 4 15:17:35 2011 (r222686) @@ -0,0 +1,216 @@ +/*- + * Copyright (c) 2011 Justin Hibbits + * Copyright (c) 2010 Andreas Tobler + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +struct adm1030_softc { + struct pmac_fan fan; + device_tsc_dev; + struct intr_config_hook enum_hook; + uint32_tsc_addr; + phandle_t sc_thermostat_phandle; + device_tsc_thermostat_dev; +}; + +/* Regular bus attachment functions */ +static int adm1030_probe(device_t); +static int adm1030_attach(device_t); + +/* Utility functions */ +static voidadm1030_start(void *xdev); +static int adm1030_write_byte(device_t dev, uint32_t addr, uint8_t reg, uint8_t buf); +stati
svn commit: r222687 - head/sys/dev/iwn
Author: bschmidt Date: Sat Jun 4 15:22:01 2011 New Revision: 222687 URL: http://svn.freebsd.org/changeset/base/222687 Log: Enable HT40 (40MHz channel width) support. Modified: head/sys/dev/iwn/if_iwn.c Modified: head/sys/dev/iwn/if_iwn.c == --- head/sys/dev/iwn/if_iwn.c Sat Jun 4 15:17:35 2011(r222686) +++ head/sys/dev/iwn/if_iwn.c Sat Jun 4 15:22:01 2011(r222687) @@ -606,9 +606,9 @@ iwn_attach(device_t dev) ic->ic_htcaps = IEEE80211_HTCAP_SMPS_OFF /* SMPS mode disabled */ | IEEE80211_HTCAP_SHORTGI20 /* short GI in 20MHz */ -#ifdef notyet | IEEE80211_HTCAP_CHWIDTH40 /* 40MHz channel width*/ | IEEE80211_HTCAP_SHORTGI40 /* short GI in 40MHz */ +#ifdef notyet | IEEE80211_HTCAP_GREENFIELD #if IWN_RBUF_SIZE == 8192 | IEEE80211_HTCAP_MAXAMSDU_7935 /* max A-MSDU length */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222688 - head/sbin/hastd
Author: sobomax Date: Sat Jun 4 16:01:30 2011 New Revision: 222688 URL: http://svn.freebsd.org/changeset/base/222688 Log: Read from the socket using the same max buffer size as we use while sending. What happens otherwise is that the sender splits all the traffic into 32k chunks, while the receiver is waiting for the whole packet. Then for a certain packet sizes, particularly 66607 bytes in my case, the communication stucks to secondary is expecting to read one chunk of 66607 bytes, while primary is sending two chunks of 32768 bytes and third chunk of 1071. Probably due to TCP windowing and buffering the final chunk gets stuck somewhere, so neither server not client can make any progress. This patch also protect from short reads, as according to the manual page there are some cases when MSG_WAITALL can give less data than expected. MFC after:3 days Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Sat Jun 4 15:22:01 2011 (r222687) +++ head/sbin/hastd/proto_common.c Sat Jun 4 16:01:30 2011 (r222688) @@ -194,6 +194,8 @@ int proto_common_recv(int sock, unsigned char *data, size_t size, int *fdp) { ssize_t done; + size_t total_done, recvsize; + unsigned char *dp; PJDLOG_ASSERT(sock >= 0); @@ -210,9 +212,19 @@ proto_common_recv(int sock, unsigned cha PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); + total_done = 0; + dp = data; do { - done = recv(sock, data, size, MSG_WAITALL); - } while (done == -1 && errno == EINTR); + recvsize = size - total_done; + recvsize = recvsize < MAX_SEND_SIZE ? recvsize : MAX_SEND_SIZE; + done = recv(sock, dp, recvsize, MSG_WAITALL); + if (done == -1 && errno == EINTR) + continue; + if (done <= 0) + break; + total_done += done; + dp += done; + } while (total_done < size); if (done == 0) { return (ENOTCONN); } else if (done < 0) { ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222689 - head/tools/regression/netinet/ipdivert
Author: rwatson Date: Sat Jun 4 16:25:12 2011 New Revision: 222689 URL: http://svn.freebsd.org/changeset/base/222689 Log: Add a very simple IPDIVERT test, which creates IP divert sockets and checks for collision/non-collision properties in binding them. This test would have identified a bug recently reported on current@ involding my disaggregation of the pcbinfo lock. It would be nice if this test also exercised packet diversion and injection, but that is for another day. MFC after:3 days Sponsored by: Juniper Networks, Inc. Added: head/tools/regression/netinet/ipdivert/ head/tools/regression/netinet/ipdivert/Makefile (contents, props changed) head/tools/regression/netinet/ipdivert/ipdivert.c (contents, props changed) Added: head/tools/regression/netinet/ipdivert/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/netinet/ipdivert/Makefile Sat Jun 4 16:25:12 2011(r222689) @@ -0,0 +1,11 @@ +# +# $FreeBSD$ +# + +PROG= ipdivert +SRCS= ipdivert.c +NO_MAN= + +WARNS?=2 + +.include Added: head/tools/regression/netinet/ipdivert/ipdivert.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/netinet/ipdivert/ipdivert.c Sat Jun 4 16:25:12 2011(r222689) @@ -0,0 +1,166 @@ +/*- + * Copyright (c) 2010-2011 Juniper Networks, Inc. + * All rights reserved. + * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * This is a test tool for IP divert sockets. For the time being, it just + * exercise creation and binding of sockets, rather than their divert + * behaviour. It would be highly desirable to broaden this test tool to + * include packet injection and diversion. + */ + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +static void +ok(const char *test) +{ + + fprintf(stderr, "%s: OK\n", test); +} + +static void +fail(const char *test, const char *note) +{ + + fprintf(stderr, "%s - %s: FAIL (%s)\n", test, note, strerror(errno)); + exit(1); +} + +static void +failx(const char *test, const char *note) +{ + + fprintf(stderr, "%s - %s: FAIL\n", test, note); + exit(1); +} + +static int +ipdivert_create(const char *test) +{ + int s; + + s = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT); + if (s < 0) + fail(test, "socket"); + return (s); +} + +static void +ipdivert_close(const char *test, int s) +{ + + if (close(s) < 0) + fail(test, "close"); +} + +static void +ipdivert_bind(const char *test, int s, u_short port, int expect) +{ + struct sockaddr_in sin; + int err; + + bzero(&sin, sizeof(sin)); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_ANY); + sin.sin_port = htons(port); + + err = bind(s, (struct sockaddr *)&sin, sizeof(sin)); + if (err < 0) { + if (expect == 0) + fail(test, "bind"); + if (errno != expect) + fail(test, "bind"); + } else { + if (expect != 0) + failx(test, "bind"); + } +} + +int +main(int argc, char *argv[]) +{ + const char *test; + int s1, s2; + + /* +* First test: create and close an IP divert socket. +*/ + test = "create_close"; + s1 = ipdivert_create(te
svn commit: r222690 - head/sys/netinet
Author: rwatson Date: Sat Jun 4 16:26:02 2011 New Revision: 222690 URL: http://svn.freebsd.org/changeset/base/222690 Log: IP divert sockets use their inpcbinfo for port reservation, although not for lookup. I missed its call to in_pcbbind() when preparing previous patches, which would lead to a lock assertion failure (although problem not an actual race condition due to global pcbinfo locks providing required synchronisation -- in this particular case only). This change adds the missing locking of the pcbhash lock. (Existing comments in the ipdivert code question the need for using the global hash to manage the namespace, as really it's a simple port namespace and not an address/port namespace. Also, although in_pcbbind is used to manage reservations, the hash tables aren't used for lookup. It might be a good idea to make them use hashed lookup, or to use a different reservation scheme.) Reviewed by:bz Reported by:Kristof Provost Sponsored by: Juniper Networks Modified: head/sys/netinet/ip_divert.c Modified: head/sys/netinet/ip_divert.c == --- head/sys/netinet/ip_divert.cSat Jun 4 16:25:12 2011 (r222689) +++ head/sys/netinet/ip_divert.cSat Jun 4 16:26:02 2011 (r222690) @@ -530,7 +530,9 @@ div_bind(struct socket *so, struct socka ((struct sockaddr_in *)nam)->sin_addr.s_addr = INADDR_ANY; INP_INFO_WLOCK(&V_divcbinfo); INP_WLOCK(inp); + INP_HASH_WLOCK(&V_divcbinfo); error = in_pcbbind(inp, nam, td->td_ucred); + INP_HASH_WUNLOCK(&V_divcbinfo); INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_divcbinfo); return error; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r222488 - in head/sys: contrib/pf/net netinet netinet/ipfw netinet6
On Sat, 4 Jun 2011, Kristof Provost wrote: I'm seeing a panic when I start natd, which I suspect is related to this commit: And, I believe now fixed in the just-committed r222690. My suggestion is that people running -CURRENT should generally keep INVARIANTS and WITNESS on -- they introduce some overhead, but are invaluable in tracking down problems. Thanks! Robert panic: Lock pcbinfohash not exclusively locked @ /usr/src/sys/netinet/in_pcb.c:323 Backtrace: panic() ... _rw_assert() at _rw_assert+0x18d in_pcbbind() at in_pcbbind+0xf5 div_bind() at div_bind+0xb9 sobind() at sobind()+0x79 kern_bind() at kern_bind+0xde bind() at bind()+0x41 syscallenter() at syscallenter+0x1cb syscall() at syscall+0x4c Xfast_syscall() at Xfast_syscall+0xdd div_bind probably also needs to surround the call to in_pcbbind with INP_HASHW(UN)LOCK(...) I'm currently running 222680. I've only now seen the issue, but I've also just now activated INVARIANTS. Regards, Kristof On 2011-05-30 09:43:55 (+), Robert Watson wrote: Author: rwatson Date: Mon May 30 09:43:55 2011 New Revision: 222488 URL: http://svn.freebsd.org/changeset/base/222488 Log: Decompose the current single inpcbinfo lock into two locks: - The existing ipi_lock continues to protect the global inpcb list and inpcb counter. This lock is now relegated to a small number of allocation and free operations, and occasional operations that walk all connections (including, awkwardly, certain UDP multicast receive operations -- something to revisit). - A new ipi_hash_lock protects the two inpcbinfo hash tables for looking up connections and bound sockets, manipulated using new INP_HASH_*() macros. This lock, combined with inpcb locks, protects the 4-tuple address space. Unlike the current ipi_lock, ipi_hash_lock follows the individual inpcb connection locks, so may be acquired while manipulating a connection on which a lock is already held, avoiding the need to acquire the inpcbinfo lock preemptively when a binding change might later be required. As a result, however, lookup operations necessarily go through a reference acquire while holding the lookup lock, later acquiring an inpcb lock -- if required. A new function in_pcblookup() looks up connections, and accepts flags indicating how to return the inpcb. Due to lock order changes, callers no longer need acquire locks before performing a lookup: the lookup routine will acquire the ipi_hash_lock as needed. In the future, it will also be able to use alternative lookup and locking strategies transparently to callers, such as pcbgroup lookup. New lookup flags are, supplementing the existing INPLOOKUP_WILDCARD flag: INPLOOKUP_RLOCKPCB - Acquire a read lock on the returned inpcb INPLOOKUP_WLOCKPCB - Acquire a write lock on the returned inpcb Callers must pass exactly one of these flags (for the time being). Some notes: - All protocols are updated to work within the new regime; especially, TCP, UDPv4, and UDPv6. pcbinfo ipi_lock acquisitions are largely eliminated, and global hash lock hold times are dramatically reduced compared to previous locking. - The TCP syncache still relies on the pcbinfo lock, something that we may want to revisit. - Support for reverting to the FreeBSD 7.x locking strategy in TCP input is no longer available -- hash lookup locks are now held only very briefly during inpcb lookup, rather than for potentially extended periods. However, the pcbinfo ipi_lock will still be acquired if a connection state might change such that a connection is added or removed. - Raw IP sockets continue to use the pcbinfo ipi_lock for protection, due to maintaining their own hash tables. - The interface in6_pcblookup_hash_locked() is maintained, which allows callers to acquire hash locks and perform one or more lookups atomically with 4-tuple allocation: this is required only for TCPv6, as there is no in6_pcbconnect_setup(), which there should be. - UDPv6 locking remains significantly more conservative than UDPv4 locking, which relates to source address selection. This needs attention, as it likely significantly reduces parallelism in this code for multithreaded socket use (such as in BIND). - In the UDPv4 and UDPv6 multicast cases, we need to revisit locking somewhat, as they relied on ipi_lock to stablise 4-tuple matches, which is no longer sufficient. A second check once the inpcb lock is held should do the trick, keeping the general case from requiring the inpcb lock for every inpcb visited. - This work reminds us that we need to revisit locking of the v4/v6 flags, which may be accessed lock-free both before and after this change. - Right now, a single lock name is used for the pcbhash lock -- this is undesirable, and probably another argument is required to take care of this (or a char array name field i
svn commit: r222691 - in head/sys: contrib/pf/net netinet netinet6
Author: rwatson Date: Sat Jun 4 16:33:06 2011 New Revision: 222691 URL: http://svn.freebsd.org/changeset/base/222691 Log: Add _mbuf() variants of various inpcb-related interfaces, including lookup, hash install, etc. For now, these are arguments are unused, but as we add RSS support, we will want to use hashes extracted from mbufs, rather than manually calculated hashes of header fields, due to the expensive of the software version of Toeplitz (and similar hashes). Add notes that it would be nice to be able to pass mbufs into lookup routines in pf(4), optimising firewall lookup in the same way, but the code structure there doesn't facilitate that currently. (In principle there is no reason this couldn't be MFCed -- the change extends rather than modifies the KBI. However, it won't be useful without other previous possibly less MFCable changes.) Reviewed by:bz Sponsored by: Juniper Networks, Inc. Modified: head/sys/contrib/pf/net/pf.c head/sys/netinet/in_pcb.c head/sys/netinet/in_pcb.h head/sys/netinet/tcp_input.c head/sys/netinet/tcp_syncache.c head/sys/netinet/udp_usrreq.c head/sys/netinet6/in6_pcb.c head/sys/netinet6/in6_pcb.h head/sys/netinet6/udp6_usrreq.c Modified: head/sys/contrib/pf/net/pf.c == --- head/sys/contrib/pf/net/pf.cSat Jun 4 16:26:02 2011 (r222690) +++ head/sys/contrib/pf/net/pf.cSat Jun 4 16:33:06 2011 (r222691) @@ -3034,6 +3034,10 @@ pf_socket_lookup(int direction, struct p #ifdef INET case AF_INET: #ifdef __FreeBSD__ + /* +* XXXRW: would be nice if we had an mbuf here so that we +* could use in_pcblookup_mbuf(). +*/ inp = in_pcblookup(pi, saddr->v4, sport, daddr->v4, dport, INPLOOKUP_RLOCKPCB, NULL); if (inp == NULL) { @@ -3056,6 +3060,10 @@ pf_socket_lookup(int direction, struct p #ifdef INET6 case AF_INET6: #ifdef __FreeBSD__ + /* +* XXXRW: would be nice if we had an mbuf here so that we +* could use in6_pcblookup_mbuf(). +*/ inp = in6_pcblookup(pi, &saddr->v6, sport, &daddr->v6, dport, INPLOOKUP_RLOCKPCB, NULL); if (inp == NULL) { Modified: head/sys/netinet/in_pcb.c == --- head/sys/netinet/in_pcb.c Sat Jun 4 16:26:02 2011(r222690) +++ head/sys/netinet/in_pcb.c Sat Jun 4 16:33:06 2011(r222691) @@ -621,7 +621,8 @@ in_pcbbind_setup(struct inpcb *inp, stru * then pick one. */ int -in_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) +in_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr *nam, +struct ucred *cred, struct mbuf *m) { u_short lport, fport; in_addr_t laddr, faddr; @@ -654,13 +655,20 @@ in_pcbconnect(struct inpcb *inp, struct inp->inp_laddr.s_addr = laddr; inp->inp_faddr.s_addr = faddr; inp->inp_fport = fport; - in_pcbrehash(inp); + in_pcbrehash_mbuf(inp, m); if (anonport) inp->inp_flags |= INP_ANONPORT; return (0); } +int +in_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) +{ + + return (in_pcbconnect_mbuf(inp, nam, cred, NULL)); +} + /* * Do proper source address selection on an unbound socket in case * of connect. Take jails into account as well. @@ -1626,7 +1634,8 @@ in_pcblookup_hash(struct inpcbinfo *pcbi } /* - * Public inpcb lookup routines, accepting a 4-tuple. + * Public inpcb lookup routines, accepting a 4-tuple, and optionally, an mbuf + * from which a pre-calculated hash value may be extracted. */ struct inpcb * in_pcblookup(struct inpcbinfo *pcbinfo, struct in_addr faddr, u_int fport, @@ -1641,6 +1650,21 @@ in_pcblookup(struct inpcbinfo *pcbinfo, return (in_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, lookupflags, ifp)); } + +struct inpcb * +in_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in_addr faddr, +u_int fport, struct in_addr laddr, u_int lport, int lookupflags, +struct ifnet *ifp, struct mbuf *m) +{ + + KASSERT((lookupflags & ~INPLOOKUP_MASK) == 0, + ("%s: invalid lookup flags %d", __func__, lookupflags)); + KASSERT((lookupflags & (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)) != 0, + ("%s: LOCKPCB not set", __func__)); + + return (in_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, + lookupflags, ifp)); +} #endif /* INET */ /* @@ -1707,7 +1731,7 @@ in_pcbinshash(struct inpcb *inp) * not change after in_pcbinshash() has been called. */ void -in_pcbrehash(struct inpcb *inp) +in_pcbrehash_mbuf(struct inpcb *inp, struct mbuf *m) { struct inpcbinfo *pcbinfo = inp->inp_pcbin
Re: svn commit: r222688 - head/sbin/hastd
On Jun 4, 2011, at 4:01 PM, Maxim Sobolev wrote: > Author: sobomax > Date: Sat Jun 4 16:01:30 2011 > New Revision: 222688 > URL: http://svn.freebsd.org/changeset/base/222688 > > Log: > Read from the socket using the same max buffer size as we use while > sending. What happens otherwise is that the sender splits all the > traffic into 32k chunks, while the receiver is waiting for the whole > packet. Then for a certain packet sizes, particularly 66607 bytes in > my case, the communication stucks to secondary is expecting to > read one chunk of 66607 bytes, while primary is sending two chunks > of 32768 bytes and third chunk of 1071. Probably due to TCP windowing > and buffering the final chunk gets stuck somewhere, so neither server > not client can make any progress. I don't know about the hast internal protocol but the above reads kind of wrong to me. -- Bjoern A. Zeeb You have to have visions! Stop bit received. Insert coin for new address family. ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r222688 - head/sbin/hastd
On 6/4/2011 9:33 AM, Bjoern A. Zeeb wrote: I don't know about the hast internal protocol but the above reads kind of wrong to me. Hmm, not sure what exactly is wrong? Sender does 3 writes to the TCP socket - 32k, 32k and 1071 bytes, while receiver does one recv(MSG_WAITALL) with the size of 66607. So I suspect sender's kernel does deliver two 32k packets and fills up receiver's buffer or something. And the remaining 1071 bytes stay somewhere in sender's kernel indefinitely, while recv() cannot complete in receiver's. Using the same size when doing recv() solves the issue for me. -Maxim ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222696 - in head: share/man/man4 sys/conf sys/dev/usb/serial sys/modules/usb sys/modules/usb/umcs sys/modules/usb/umcs7840
Author: hselasky Date: Sat Jun 4 20:40:24 2011 New Revision: 222696 URL: http://svn.freebsd.org/changeset/base/222696 Log: Rename recently added USB serial driver. Suggested by: YongHyeon PYUN MFC after:7 days Added: head/share/man/man4/umcs.4 - copied, changed from r222578, head/share/man/man4/umcs7840.4 head/sys/dev/usb/serial/umcs.c - copied, changed from r222578, head/sys/dev/usb/serial/umcs7840.c head/sys/dev/usb/serial/umcs.h - copied unchanged from r222578, head/sys/dev/usb/serial/umcs7840.h head/sys/modules/usb/umcs/ - copied from r222578, head/sys/modules/usb/umcs7840/ Deleted: head/share/man/man4/umcs7840.4 head/sys/dev/usb/serial/umcs7840.c head/sys/dev/usb/serial/umcs7840.h head/sys/modules/usb/umcs7840/ Modified: head/share/man/man4/Makefile head/share/man/man4/ucom.4 head/sys/conf/files head/sys/modules/usb/Makefile head/sys/modules/usb/umcs/Makefile Modified: head/share/man/man4/Makefile == --- head/share/man/man4/MakefileSat Jun 4 19:16:46 2011 (r222695) +++ head/share/man/man4/MakefileSat Jun 4 20:40:24 2011 (r222696) @@ -475,7 +475,7 @@ MAN=aac.4 \ ukbd.4 \ ulpt.4 \ umass.4 \ - umcs7840.4 \ + umcs.4 \ umct.4 \ umodem.4 \ ums.4 \ Modified: head/share/man/man4/ucom.4 == --- head/share/man/man4/ucom.4 Sat Jun 4 19:16:46 2011(r222695) +++ head/share/man/man4/ucom.4 Sat Jun 4 20:40:24 2011(r222696) @@ -78,7 +78,7 @@ multiple external ports. .Xr uark 4 , .Xr uchcom 4 , .Xr uftdi 4 , -.Xr umcs7840 4 , +.Xr umcs 4 , .Xr umct 4 , .Xr umodem 4 , .Xr uplcom 4 , Copied and modified: head/share/man/man4/umcs.4 (from r222578, head/share/man/man4/umcs7840.4) == --- head/share/man/man4/umcs7840.4 Wed Jun 1 17:58:27 2011 (r222578, copy source) +++ head/share/man/man4/umcs.4 Sat Jun 4 20:40:24 2011(r222696) @@ -29,24 +29,24 @@ .\" $FreeBSD$ .\" .Dd December 10, 2010 -.Dt UMCS7840 4 +.Dt UMCS 4 .Os .Sh NAME -.Nm umcs7840 +.Nm umcs .Nd USB support for serial adapters based on the MCS7820 and MCS7840 chips .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your kernel configuration file: .Bd -ragged -offset indent -.Cd "device umcs7840" +.Cd "device umcs" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in .Xr loader.conf 5 : .Bd -literal -offset indent -umcs7840_load="YES" +umcs_load="YES" .Ed .Sh DESCRIPTION The Modified: head/sys/conf/files == --- head/sys/conf/files Sat Jun 4 19:16:46 2011(r222695) +++ head/sys/conf/files Sat Jun 4 20:40:24 2011(r222696) @@ -1958,7 +1958,7 @@ dev/usb/serial/uftdi.coptional uftdi dev/usb/serial/ugensa.coptional ugensa dev/usb/serial/uipaq.c optional uipaq dev/usb/serial/ulpt.c optional ulpt -dev/usb/serial/umcs7840.c optional umcs7840 +dev/usb/serial/umcs.c optional umcs dev/usb/serial/umct.c optional umct dev/usb/serial/umodem.coptional umodem dev/usb/serial/umoscom.c optional umoscom @@ -1968,7 +1968,7 @@ dev/usb/serial/uvisor.c optional uvisor dev/usb/serial/uvscom.coptional uvscom dev/usb/serial/usb_serial.coptional ucom | u3g | uark | ubsa | ubser | \ uchcom | ucycom | ufoma | uftdi | \ -ugensa | uipaq | umcs7840 | umct | \ +ugensa | uipaq | umcs | umct | \ umodem | umoscom | uplcom | uslcom | \ uvisor | uvscom # Copied and modified: head/sys/dev/usb/serial/umcs.c (from r222578, head/sys/dev/usb/serial/umcs7840.c) == --- head/sys/dev/usb/serial/umcs7840.c Wed Jun 1 17:58:27 2011 (r222578, copy source) +++ head/sys/dev/usb/serial/umcs.c Sat Jun 4 20:40:24 2011 (r222696) @@ -66,21 +66,21 @@ __FBSDID("$FreeBSD$"); #include #include "usbdevs.h" -#defineUSB_DEBUG_VAR umcs7840_debug +#defineUSB_DEBUG_VAR umcs_debug #include #include #include -#include +#include #defineUMCS7840_MODVER 1 #ifdef USB_DEBUG -static int umcs7840_debug = 0; +static int umcs_debug = 0; -SYSCTL_NODE(_hw_usb, OID_AUTO, umcs7840, CTLFLAG_RW, 0, "USB umcs7840 quadport serial adapter"); -SYSCTL_INT(_hw_usb_umcs7840, OID_AUTO, debug, CTLFLAG_RW, &umcs7840_debug, 0, "Debug level"); +SYSCTL_NODE(_hw_usb, OI
svn commit: r222697 - head/usr.bin/find
Author: jilles Date: Sat Jun 4 21:59:55 2011 New Revision: 222697 URL: http://svn.freebsd.org/changeset/base/222697 Log: find: Exit if there is an unknown option. Ignoring the parameter with the unknown options is unlikely to be what was intended. Example: find -n . Note that things like find -n already caused an exit, equivalent to "find" by itself. Modified: head/usr.bin/find/main.c Modified: head/usr.bin/find/main.c == --- head/usr.bin/find/main.cSat Jun 4 20:40:24 2011(r222696) +++ head/usr.bin/find/main.cSat Jun 4 21:59:55 2011(r222697) @@ -120,7 +120,7 @@ main(int argc, char *argv[]) break; case '?': default: - break; + usage(); } argc -= optind; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222699 - head/bin/sh
Author: jilles Date: Sat Jun 4 22:19:00 2011 New Revision: 222699 URL: http://svn.freebsd.org/changeset/base/222699 Log: sh: Improve error message if the script cannot be opened. Avoid ": cannot open : ...". Modified: head/bin/sh/options.c Modified: head/bin/sh/options.c == --- head/bin/sh/options.c Sat Jun 4 22:05:20 2011(r222698) +++ head/bin/sh/options.c Sat Jun 4 22:19:00 2011(r222699) @@ -83,6 +83,7 @@ void procargs(int argc, char **argv) { int i; + char *scriptname; argptr = argv; if (argc > 0) @@ -105,8 +106,9 @@ procargs(int argc, char **argv) optlist[i].val = 0; arg0 = argv[0]; if (sflag == 0 && minusc == NULL) { - commandname = arg0 = *argptr++; - setinputfile(commandname, 0); + scriptname = *argptr++; + setinputfile(scriptname, 0); + commandname = arg0 = scriptname; } /* POSIX 1003.2: first arg after -c cmd is $0, remainder $1... */ if (argptr && minusc && *argptr) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r222488 - in head/sys: contrib/pf/net netinet netinet/ipfw netinet6
On 2011-06-04 17:27:56 (+0100), Robert Watson wrote: > > On Sat, 4 Jun 2011, Kristof Provost wrote: > > >I'm seeing a panic when I start natd, which I suspect is related > >to this commit: > > And, I believe now fixed in the just-committed r222690. My > suggestion is that people running -CURRENT should generally keep > INVARIANTS and WITNESS on -- they introduce some overhead, but are > invaluable in tracking down problems. > I've just been able to test your patch. The panic is now gone. I'll also test 222690, but that'll be a job for tomorrow. > Thanks! Thanks for the quick response. Kristof ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222701 - head/sys/dev/cxgbe
Author: np Date: Sat Jun 4 23:31:33 2011 New Revision: 222701 URL: http://svn.freebsd.org/changeset/base/222701 Log: Allow lazy fill up of freelists. MFC after:3 days Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/t4_sge.c Modified: head/sys/dev/cxgbe/adapter.h == --- head/sys/dev/cxgbe/adapter.hSat Jun 4 22:51:06 2011 (r222700) +++ head/sys/dev/cxgbe/adapter.hSat Jun 4 23:31:33 2011 (r222701) @@ -396,6 +396,7 @@ struct sge_ctrlq { struct sge { uint16_t timer_val[SGE_NTIMERS]; uint8_t counter_val[SGE_NCOUNTERS]; + int fl_starve_threshold; int nrxq; /* total rx queues (all ports and the rest) */ int ntxq; /* total tx queues (all ports and the rest) */ Modified: head/sys/dev/cxgbe/t4_sge.c == --- head/sys/dev/cxgbe/t4_sge.c Sat Jun 4 22:51:06 2011(r222700) +++ head/sys/dev/cxgbe/t4_sge.c Sat Jun 4 23:31:33 2011(r222701) @@ -203,6 +203,9 @@ t4_sge_init(struct adapter *sc) FL_BUF_SIZE(i)); } + i = t4_read_reg(sc, A_SGE_CONM_CTRL); + s->fl_starve_threshold = G_EGRTHRESHOLD(i) * 2 + 1; + t4_write_reg(sc, A_SGE_INGRESS_RX_THRESHOLD, V_THRESHOLD_0(s->counter_val[0]) | V_THRESHOLD_1(s->counter_val[1]) | @@ -1233,7 +1236,8 @@ alloc_iq_fl(struct port_info *pi, struct sc->sge.eqmap[cntxt_id] = (void *)fl; FL_LOCK(fl); - refill_fl(sc, fl, -1, 8); + /* Just enough to make sure it doesn't starve right away. */ + refill_fl(sc, fl, roundup(sc->sge.fl_starve_threshold, 8), 8); FL_UNLOCK(fl); } @@ -1389,6 +1393,10 @@ alloc_rxq(struct port_info *pi, struct s if (rc != 0) return (rc); + FL_LOCK(&rxq->fl); + refill_fl(pi->adapter, &rxq->fl, rxq->fl.needed / 8, 8); + FL_UNLOCK(&rxq->fl); + #ifdef INET rc = tcp_lro_init(&rxq->lro); if (rc != 0) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222702 - head/sys/sys
Author: rwatson Date: Sat Jun 4 23:31:41 2011 New Revision: 222702 URL: http://svn.freebsd.org/changeset/base/222702 Log: Allocate four bits from the mbuf flags field to represent the hash type of a software- or hardware-generated hash held in the mbuf.m_pkthdr.flowid field, and provide accessor macros to easily clear, set, receive, and test for hash values. Some of these constants correspond to RSS hash types, but we don't want to limit ourselves to that, as a number of other hashing techniques are in use on hardware supported by FreeBSD. Mark the M_FLOWID flag as deprecated; I hope to remove this before 9.0, changing drivers and the stack over to using the new M_HASHTYPEBITS, most likely to use M_HASHTYPE_OPAQUE as we don't yet want to nail down the KPI for RSS key/bucket management for device drivers. MFC after: 3 days Reviewed by:bz Sponsored by: Juniper Networks, Inc. Modified: head/sys/sys/mbuf.h Modified: head/sys/sys/mbuf.h == --- head/sys/sys/mbuf.h Sat Jun 4 23:31:33 2011(r222701) +++ head/sys/sys/mbuf.h Sat Jun 4 23:31:41 2011(r222702) @@ -199,7 +199,9 @@ struct mbuf { #defineM_PROTO60x0008 /* protocol-specific */ #defineM_PROTO70x0010 /* protocol-specific */ #defineM_PROTO80x0020 /* protocol-specific */ -#defineM_FLOWID0x0040 /* flowid is valid */ +#defineM_FLOWID0x0040 /* deprecated: flowid is valid */ +#defineM_HASHTYPEBITS 0x0F00 /* mask of bits holding flowid hash type */ + /* * For RELENG_{6,7} steal these flags for limited multiple routing table * support. In RELENG_8 and beyond, use just one flag and a tag. @@ -215,11 +217,45 @@ struct mbuf { (M_PROTO1|M_PROTO2|M_PROTO3|M_PROTO4|M_PROTO5|M_PROTO6|M_PROTO7|M_PROTO8) /* + * Network interface cards are able to hash protocol fields (such as IPv4 + * addresses and TCP port numbers) classify packets into flows. These flows + * can then be used to maintain ordering while delivering packets to the OS + * via parallel input queues, as well as to provide a stateless affinity + * model. NIC drivers can pass up the hash via m->m_pkthdr.flowid, and set + * m_flag fields to indicate how the hash should be interpreted by the + * network stack. + * + * Most NICs support RSS, which provides ordering and explicit affinity, and + * use the hash m_flag bits to indicate what header fields were covered by + * the hash. M_HASHTYPE_OPAQUE can be set by non-RSS cards or configurations + * that provide an opaque flow identifier, allowing for ordering and + * distribution without explicit affinity. + */ +#defineM_HASHTYPE_SHIFT24 +#defineM_HASHTYPE_NONE 0x0 +#defineM_HASHTYPE_RSS_IPV4 0x1 /* IPv4 2-tuple */ +#defineM_HASHTYPE_RSS_TCP_IPV4 0x2 /* TCPv4 4-tuple */ +#defineM_HASHTYPE_RSS_IPV6 0x3 /* IPv6 2-tuple */ +#defineM_HASHTYPE_RSS_TCP_IPV6 0x4 /* TCPv6 4-tuple */ +#defineM_HASHTYPE_RSS_IPV6_EX 0x5 /* IPv6 2-tuple + ext hdrs */ +#defineM_HASHTYPE_RSS_TCP_IPV6_EX 0x6 /* TCPv6 4-tiple + ext hdrs */ +#defineM_HASHTYPE_OPAQUE 0xf /* ordering, not affinity */ + +#defineM_HASHTYPE_CLEAR(m) (m)->m_flags &= ~(M_HASHTYPEBITS) +#defineM_HASHTYPE_GET(m) (((m)->m_flags & M_HASHTYPEBITS) >> \ + M_HASHTYPE_SHIFT) +#defineM_HASHTYPE_SET(m, v)do { \ + (m)->m_flags &= ~M_HASHTYPEBITS;\ + (m)->m_flags |= ((v) << M_HASHTYPE_SHIFT); \ +while (0) +#defineM_HASHTYPE_TEST(m, v) (M_HASHTYPE_GET(m) == (v)) + +/* * Flags preserved when copying m_pkthdr. */ #defineM_COPYFLAGS \ (M_PKTHDR|M_EOR|M_RDONLY|M_PROTOFLAGS|M_SKIP_FIREWALL|M_BCAST|M_MCAST|\ - M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_FIB) + M_FRAG|M_FIRSTFRAG|M_LASTFRAG|M_VLANTAG|M_PROMISC|M_FIB|M_HASHTYPEBITS) /* * External buffer types: identify ext_buf type. ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222703 - head/sys/dev/cxgbe
Author: np Date: Sat Jun 4 23:36:19 2011 New Revision: 222703 URL: http://svn.freebsd.org/changeset/base/222703 Log: Cause backpressure (instead of dropping frames) on congestion. MFC after:3 days Modified: head/sys/dev/cxgbe/t4_main.c Modified: head/sys/dev/cxgbe/t4_main.c == --- head/sys/dev/cxgbe/t4_main.cSat Jun 4 23:31:41 2011 (r222702) +++ head/sys/dev/cxgbe/t4_main.cSat Jun 4 23:36:19 2011 (r222703) @@ -492,6 +492,8 @@ t4_attach(device_t dev) V_RXTSHIFTMAXR2(15) | V_PERSHIFTBACKOFFMAX(8) | V_PERSHIFTMAX(8) | V_KEEPALIVEMAXR1(4) | V_KEEPALIVEMAXR2(9)); t4_write_reg(sc, A_ULP_RX_TDDP_PSZ, V_HPZ0(PAGE_SHIFT - 12)); + t4_set_reg_field(sc, A_TP_PARA_REG3, F_TUNNELCNGDROP0 | + F_TUNNELCNGDROP1 | F_TUNNELCNGDROP2 | F_TUNNELCNGDROP3, 0); setup_memwin(sc); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r222707 - head/sys/dev/ath
Author: adrian Date: Sun Jun 5 03:33:46 2011 New Revision: 222707 URL: http://svn.freebsd.org/changeset/base/222707 Log: Add a missing call to sync the DMAed buffer before the radar event data is extracted. Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c == --- head/sys/dev/ath/if_ath.c Sun Jun 5 02:44:04 2011(r222706) +++ head/sys/dev/ath/if_ath.c Sun Jun 5 03:33:46 2011(r222707) @@ -3473,7 +3473,15 @@ ath_rx_proc(void *arg, int npending) if (rs->rs_status & HAL_RXERR_PHY) { sc->sc_stats.ast_rx_phyerr++; /* Process DFS radar events */ - ath_dfs_process_phy_err(sc, mtod(m, char *), tsf, rs); + if ((rs->rs_phyerr == HAL_PHYERR_RADAR) || + (rs->rs_phyerr == HAL_PHYERR_FALSE_RADAR_EXT)) { + /* Since we're touching the frame data, sync it */ + bus_dmamap_sync(sc->sc_dmat, + bf->bf_dmamap, + BUS_DMASYNC_POSTREAD); + /* Now pass it to the radar processing code */ + ath_dfs_process_phy_err(sc, mtod(m, char *), tsf, rs); + } /* Be suitably paranoid about receiving phy errors out of the stats array bounds */ if (rs->rs_phyerr < 64) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"