Re: ifconfig.8: removing arp as a valid load balancing mode
On Thu, Nov 30, 2017 at 01:42:22AM +0100, Martin Rettberg wrote: > Hi, > > mpi@ removed ARP as a load balancing mode from carp(4) on November 2, > 2015. The manual page of ifconfig(8) never reflected this change. > > Regards, > Martin > fixed, thanks. jmc > > Index: ifconfig.8 > === > RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v > retrieving revision 1.289 > diff -u -p -r1.289 ifconfig.8 > --- ifconfig.817 Nov 2017 18:04:51 - 1.289 > +++ ifconfig.829 Nov 2017 23:42:05 - > @@ -768,7 +768,6 @@ Acceptable values are 0 to 254; the defa > Set the load balancing mode to > .Ar mode . > Valid modes are > -.Ar arp , > .Ar ip , > .Ar ip-stealth , > and >
Re: dc(1): floor(log_10(x)) should not cost more than O(log(log(x)))
On Sun, Nov 26, 2017 at 07:40:03PM +, kshe wrote: > Hi, > > The `Z' command can be a handy shortcut for computing logarithms; as > such, for example, it is the basis of the implementation of bc(1)'s `l' > function. However, the algorithm currently used in count_digits() is > too naive to be really useful, becoming rapidly much slower than what > would be expected from a native command. > > To see how this computation could easily be made exponentially faster, > one may start by noticing that, if next() is the function defined for > any real r as > > next(r) := floor(r) + 1, > > then clearly, for any strictly positive integer x, > > floor(log_2(x)) <= log_2(x) < next(log_2(x)) > > and therefore > > log_10(2) * floor(log_2(x)) <= log_10(x) < k, > > where > > k := log_10(2) * next(log_2(x)). > > Since log_10(2) < 1, it follows that > > floor(k) <= next(k - log_10(2)) <= next(log_10(x)) <= next(k), > > which proves that next(log_10(x)) is either floor(k) or next(k). > > If next(log_10(x)) = floor(k), then > > 10^floor(k) = 10^next(log_10(x)) > 10^log_10(x) = x. > > If next(log_10(x)) = next(k), then > > 10^floor(k) = 10^floor(log_10(x)) <= 10^log_10(x) = x. > > Therefore, if x >= 10^floor(k), then next(log_10(x)) cannot be floor(k), > hence it must be next(k); likewise, if x < 10^floor(k), then > next(log_10(x)) cannot be next(k), hence it must be floor(k). Using the > conventional integer value of a boolean expression, this result can be > summarised as > > next(log_10(x)) = floor(k) + (x >= 10^floor(k)). > > As an additional refinement, one may further notice that if > > floor(k) = floor(log_10(2) * floor(log_2(x))) > > then > > 10^floor(k) = 10^floor(log_10(2) * floor(log_2(x))) > <= 10^(log_10(2) * floor(log_2(x))) > <= 2^floor(log_2(x)) > <= x > > so that it can readily be concluded that > > next(log_10(x)) = next(k) > > without having to compute 10^floor(k). > > The BN library permits computation of k in O(1) and 10^floor(k) in > O(log(k)) which is O(log(log(x))). Therefore, one can compute > next(log_10(x)) in O(1) most of the time (at least on average, and with > a certain definition of such average, the full analysis of which is, I > presume, outside the scope of this message), with a worst case of > O(log(log(x))). In contrast, the current code is exponentially worse > than what its worst case should be, computing this value in O(log(x)). > > $ jot -b 9 -s '' 65536 >script > $ echo Z >>script > > $ time dc script > 0m03.57s real 0m03.56s user 0m00.01s system > $ time ./dc script > 0m00.12s real 0m00.12s user 0m00.00s system > > The diff below implements this optimisation. It also fixes a small > logic error in split_number(), which is used by count_digits(). General comment: it would be a good thing to add (part of) the proof or a reference to some published work to the code in a comment. Especially the derivation of c and the computation of d seem a bit like dropping out of thin air. >From a style point of view I do not like the assignment in conditionals very much. There's also the problem of bits * c overflowing, though that's likely theoretical. -Otto > > Index: bcode.c > === > RCS file: /cvs/src/usr.bin/dc/bcode.c,v > retrieving revision 1.51 > diff -u -p -r1.51 bcode.c > --- bcode.c 26 Feb 2017 11:29:55 - 1.51 > +++ bcode.c 17 Nov 2017 02:38:12 - > @@ -385,9 +381,10 @@ split_number(const struct number *n, BIG > > bn_checkp(BN_copy(i, n->number)); > > - if (n->scale == 0 && f != NULL) > - bn_check(BN_set_word(f, 0)); > - else if (n->scale < sizeof(factors)/sizeof(factors[0])) { > + if (n->scale == 0) { > + if (f != NULL) > + bn_check(BN_set_word(f, 0)); > + } else if (n->scale < sizeof(factors)/sizeof(factors[0])) { > rem = BN_div_word(i, factors[n->scale]); > if (f != NULL) > bn_check(BN_set_word(f, rem)); > @@ -692,25 +689,40 @@ push_scale(void) > static u_int > count_digits(const struct number *n) > { > - struct number *int_part, *fract_part; > - u_int i; > + BIGNUM *int_part, *a, *p; > + BN_CTX *ctx; > + uint64_td, c = 0x4D104D42; > + int bits; > > if (BN_is_zero(n->number)) > return n->scale ? n->scale : 1; > > - int_part = new_number(); > - fract_part = new_number(); > - fract_part->scale = n->scale; > - split_number(n, int_part->number, fract_part->number); > - > - i = 0; > - while (!BN_is_zero(int_part->number)) { > - (void)BN_div_word(int_part->number, 10); > - i++; > - } > - free_number(int_part); > -
Re: Driver for Bosch motion sensors
On Thu, Nov 30, 2017 at 02:29:58AM +0100, Mark Kettenis wrote: > Driver name is bgw(4). Found on a Lenovo 2-in-1 laptop. > > ok? > Man page? Otherwise ok mlarkin. -ml > Index: dev/i2c/bmc150.c > === > RCS file: dev/i2c/bmc150.c > diff -N dev/i2c/bmc150.c > --- /dev/null 1 Jan 1970 00:00:00 - > +++ dev/i2c/bmc150.c 30 Nov 2017 01:21:36 - > @@ -0,0 +1,193 @@ > +/* $OpenBSD$ */ > + > +/* > + * Copyright (c) 2017 Mark Kettenis > + * > + * Permission to use, copy, modify, and distribute this software for any > + * purpose with or without fee is hereby granted, provided that the above > + * copyright notice and this permission notice appear in all copies. > + * > + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES > + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF > + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR > + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES > + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN > + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF > + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. > + */ > + > +#include > +#include > +#include > +#include > + > +#include > + > +#define BGW_CHIPID 0x00 > +#define BGW_CHIPID_BMA222E 0xf8 > +#define BGW_CHIPID_BMA250E 0xf9 > +#define BGW_CHIPID_BMC150 0xfa > +#define BGW_CHIPID_BMI055 0xfa > +#define BGW_CHIPID_BMA255 0xfa > +#define BGW_CHIPID_BMA280 0xfb > +#define ACCD_X_LSB 0x02 > +#define ACCD_X_MSB 0x03 > +#define ACCD_Y_LSB 0x04 > +#define ACCD_Y_MSB 0x05 > +#define ACCD_Z_LSB 0x06 > +#define ACCD_Z_MSB 0x07 > +#define ACCD_TEMP0x08 > + > +#define BGW_NUM_SENSORS 4 > + > +#define BGW_SENSOR_XACCEL0 > +#define BGW_SENSOR_YACCEL1 > +#define BGW_SENSOR_ZACCEL2 > +#define BGW_SENSOR_TEMP 3 > + > +struct bgw_softc { > + struct device sc_dev; > + i2c_tag_t sc_tag; > + i2c_addr_t sc_addr; > + > + uint8_t sc_temp0; > + > + struct ksensor sc_sensor[BGW_NUM_SENSORS]; > + struct ksensordev sc_sensordev; > +}; > + > +int bgw_match(struct device *, void *, void *); > +void bgw_attach(struct device *, struct device *, void *); > + > +struct cfattach bgw_ca = { > + sizeof(struct bgw_softc), bgw_match, bgw_attach > +}; > + > +struct cfdriver bgw_cd = { > + NULL, "bgw", DV_DULL > +}; > + > +void bgw_refresh(void *); > + > +int > +bgw_match(struct device *parent, void *match, void *aux) > +{ > + struct i2c_attach_args *ia = aux; > + > + if (strcmp(ia->ia_name, "BSBA0150") == 0 || > + strcmp(ia->ia_name, "BMC150A") == 0 || > + strcmp(ia->ia_name, "BMI055A") == 0 || > + strcmp(ia->ia_name, "BMA0255") == 0 || > + strcmp(ia->ia_name, "BMA250E") == 0 || > + strcmp(ia->ia_name, "BMA222E") == 0 || > + strcmp(ia->ia_name, "BMA0280") == 0 || > + strcmp(ia->ia_name, "BOSC0200") == 0) > + return 1; > + return 0; > +} > + > +void > +bgw_attach(struct device *parent, struct device *self, void *aux) > +{ > + struct bgw_softc *sc = (struct bgw_softc *)self; > + struct i2c_attach_args *ia = aux; > + uint8_t cmd, data; > + int i; > + > + sc->sc_tag = ia->ia_tag; > + sc->sc_addr = ia->ia_addr; > + > + iic_acquire_bus(sc->sc_tag, 0); > + cmd = BGW_CHIPID; > + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, > + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) { > + iic_release_bus(sc->sc_tag, 0); > + printf(": can't read chip ID\n"); > + return; > + } > + iic_release_bus(sc->sc_tag, 0); > + > + switch (data) { > + case BGW_CHIPID_BMA222E: > + sc->sc_temp0 = 23; > + printf(": BMA222E"); > + break; > + case BGW_CHIPID_BMA250E: > + sc->sc_temp0 = 23; > + printf(": BMA250E"); > + break; > + case BGW_CHIPID_BMC150: > + sc->sc_temp0 = 24; > + printf(": BMC150"); > + break; > + case BGW_CHIPID_BMA280: > + sc->sc_temp0 = 23; > + printf(": BMA280"); > + break; > + } > + > + sc->sc_sensor[BGW_SENSOR_XACCEL].type = SENSOR_INTEGER; > + strlcpy(sc->sc_sensor[BGW_SENSOR_XACCEL].desc, "X_ACCEL", > + sizeof(sc->sc_sensor[BGW_SENSOR_XACCEL].desc)); > + sc->sc_sensor[BGW_SENSOR_YACCEL].type = SENSOR_INTEGER; > + strlcpy(sc->sc_sensor[BGW_SENSOR_YACCEL].desc, "Y_ACCEL", > + sizeof(sc->sc_sensor[BGW_SENSOR_YACCEL].desc)); > + sc->sc_sensor[BGW_SENSOR_ZACCEL].type = SENSOR_INTEGER; > + strlcpy(sc->sc_sensor[BGW_SENSOR_ZACCEL].desc, "Z_ACCEL", > + sizeof(sc->sc_sensor[BGW_SENSOR_ZACCEL].desc)); >
Fix a typo in INSTALL.octeon
Hi, The patch below replace one "$loadaddr" to "${loadaddr}" in U-Boot instructions of INSTALL.octeon. Regards, Rafael Neves Index: install === RCS file: /cvs/src/distrib/notes/octeon/install,v retrieving revision 1.14 diff -u -p -r1.14 install --- install 2 Mar 2017 15:31:15 - 1.14 +++ install 30 Nov 2017 01:56:04 - @@ -82,7 +82,7 @@ On dual-core systems, the coremask param On the EdgeRouter Lite, bootcmd may also reset the USB controller for more reliable USB device detection: - usb reset; fatload usb 0 $loadaddr bsd; bootoctlinux rootdev=sd0 coremask=0x3 + usb reset; fatload usb 0 ${loadaddr} bsd; bootoctlinux rootdev=sd0 coremask=0x3 OpenBSDCongratulations
ifconfig.8: removing arp as a valid load balancing mode
Hi, mpi@ removed ARP as a load balancing mode from carp(4) on November 2, 2015. The manual page of ifconfig(8) never reflected this change. Regards, Martin Index: ifconfig.8 === RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v retrieving revision 1.289 diff -u -p -r1.289 ifconfig.8 --- ifconfig.8 17 Nov 2017 18:04:51 - 1.289 +++ ifconfig.8 29 Nov 2017 23:42:05 - @@ -768,7 +768,6 @@ Acceptable values are 0 to 254; the defa Set the load balancing mode to .Ar mode . Valid modes are -.Ar arp , .Ar ip , .Ar ip-stealth , and
lex: simplify PRINT_SPACES() macro
Hello, Upstream flex converted macro PRINT_SPACES() into a single fprintf() call. https://github.com/westes/flex/commit/37a6184dabcd82fa1d17c24c000f3da469296195#diff-25d902c24283ab8cfbac54dfa101ad31 Applying this to OpenBSD lex reduces the differences in scanopt.c between the two. - Michael Index: scanopt.c === RCS file: /cvs/src/usr.bin/lex/scanopt.c,v retrieving revision 1.6 diff -u -p -u -r1.6 scanopt.c --- scanopt.c 31 May 2017 07:20:26 - 1.6 +++ scanopt.c 30 Nov 2017 01:50:43 - @@ -409,14 +409,8 @@ int scanopt_usage (scanner, fp, usag } desccol = maxlen[0] + indent * 2; -#define PRINT_SPACES(fp,n)\ -do{\ -int _n;\ -_n=(n);\ -while(_n-- > 0)\ -fputc(' ',(fp));\ -}while(0) - +#define PRINT_SPACES(fp,n) \ + fprintf((fp), "%*s", (n), "") /* Second pass (same as above loop), this time we print. */ /* Sloppy hack: We iterate twice. The first time we print short and long options.
Driver for Bosch motion sensors
Driver name is bgw(4). Found on a Lenovo 2-in-1 laptop. ok? Index: dev/i2c/bmc150.c === RCS file: dev/i2c/bmc150.c diff -N dev/i2c/bmc150.c --- /dev/null 1 Jan 1970 00:00:00 - +++ dev/i2c/bmc150.c30 Nov 2017 01:21:36 - @@ -0,0 +1,193 @@ +/* $OpenBSD$ */ + +/* + * Copyright (c) 2017 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +#include + +#define BGW_CHIPID 0x00 +#define BGW_CHIPID_BMA222E0xf8 +#define BGW_CHIPID_BMA250E0xf9 +#define BGW_CHIPID_BMC150 0xfa +#define BGW_CHIPID_BMI055 0xfa +#define BGW_CHIPID_BMA255 0xfa +#define BGW_CHIPID_BMA280 0xfb +#define ACCD_X_LSB 0x02 +#define ACCD_X_MSB 0x03 +#define ACCD_Y_LSB 0x04 +#define ACCD_Y_MSB 0x05 +#define ACCD_Z_LSB 0x06 +#define ACCD_Z_MSB 0x07 +#define ACCD_TEMP 0x08 + +#define BGW_NUM_SENSORS4 + +#define BGW_SENSOR_XACCEL 0 +#define BGW_SENSOR_YACCEL 1 +#define BGW_SENSOR_ZACCEL 2 +#define BGW_SENSOR_TEMP3 + +struct bgw_softc { + struct device sc_dev; + i2c_tag_t sc_tag; + i2c_addr_t sc_addr; + + uint8_t sc_temp0; + + struct ksensor sc_sensor[BGW_NUM_SENSORS]; + struct ksensordev sc_sensordev; +}; + +intbgw_match(struct device *, void *, void *); +void bgw_attach(struct device *, struct device *, void *); + +struct cfattach bgw_ca = { + sizeof(struct bgw_softc), bgw_match, bgw_attach +}; + +struct cfdriver bgw_cd = { + NULL, "bgw", DV_DULL +}; + +void bgw_refresh(void *); + +int +bgw_match(struct device *parent, void *match, void *aux) +{ + struct i2c_attach_args *ia = aux; + + if (strcmp(ia->ia_name, "BSBA0150") == 0 || + strcmp(ia->ia_name, "BMC150A") == 0 || + strcmp(ia->ia_name, "BMI055A") == 0 || + strcmp(ia->ia_name, "BMA0255") == 0 || + strcmp(ia->ia_name, "BMA250E") == 0 || + strcmp(ia->ia_name, "BMA222E") == 0 || + strcmp(ia->ia_name, "BMA0280") == 0 || + strcmp(ia->ia_name, "BOSC0200") == 0) + return 1; + return 0; +} + +void +bgw_attach(struct device *parent, struct device *self, void *aux) +{ + struct bgw_softc *sc = (struct bgw_softc *)self; + struct i2c_attach_args *ia = aux; + uint8_t cmd, data; + int i; + + sc->sc_tag = ia->ia_tag; + sc->sc_addr = ia->ia_addr; + + iic_acquire_bus(sc->sc_tag, 0); + cmd = BGW_CHIPID; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) { + iic_release_bus(sc->sc_tag, 0); + printf(": can't read chip ID\n"); + return; + } + iic_release_bus(sc->sc_tag, 0); + + switch (data) { + case BGW_CHIPID_BMA222E: + sc->sc_temp0 = 23; + printf(": BMA222E"); + break; + case BGW_CHIPID_BMA250E: + sc->sc_temp0 = 23; + printf(": BMA250E"); + break; + case BGW_CHIPID_BMC150: + sc->sc_temp0 = 24; + printf(": BMC150"); + break; + case BGW_CHIPID_BMA280: + sc->sc_temp0 = 23; + printf(": BMA280"); + break; + } + + sc->sc_sensor[BGW_SENSOR_XACCEL].type = SENSOR_INTEGER; + strlcpy(sc->sc_sensor[BGW_SENSOR_XACCEL].desc, "X_ACCEL", + sizeof(sc->sc_sensor[BGW_SENSOR_XACCEL].desc)); + sc->sc_sensor[BGW_SENSOR_YACCEL].type = SENSOR_INTEGER; + strlcpy(sc->sc_sensor[BGW_SENSOR_YACCEL].desc, "Y_ACCEL", + sizeof(sc->sc_sensor[BGW_SENSOR_YACCEL].desc)); + sc->sc_sensor[BGW_SENSOR_ZACCEL].type = SENSOR_INTEGER; + strlcpy(sc->sc_sensor[BGW_SENSOR_ZACCEL].desc, "Z_ACCEL", + sizeof(sc->sc_sensor[BGW_SENSOR_ZACCEL].desc)); + sc->sc_sensor[BGW_SENSOR_TEMP].type = SENSOR_TEMP; + + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + for (i = 0; i < BGW_NUM_SENSORS; i++) +
Re: perlreftut.1.patch
Upstream has fixed this by switching to using Ada Lovelace instead of the name of the president. We'll pick it up eventually. https://perl5.git.perl.org/perl.git/commitdiff/b9d0a43747db03517f1acf3b092bb5276058747c l8rZ, -- andrew - http://afresh1.com Computer Science: solving today's problems tomorrow.
Re: perlreftut.1.patch
perl is from upstream, which means someone works hard to update it when neccessary, and you've been around long enough to know better (i'm suggesting you know you are being an ass) > --- perlreftut.1.orig Wed Nov 29 18:45:45 2017 > +++ perlreftut.1Wed Nov 29 18:51:52 2017 > @@ -140,11 +140,11 @@ > reference that you're already familiar with. Think of the President > of the United States: a messy, inconvenient bag of blood and bones. > But to talk about him, or to represent him in a computer program, all > -you need is the easy, convenient scalar string \*(L"Barack Obama\*(R". > +you need is the easy, convenient scalar string \*(L"Donald Trump\*(R". > .PP > References in Perl are like names for arrays and hashes. They're > Perl's private, internal names, so you can be sure they're > -unambiguous. Unlike \*(L"Barack Obama\*(R", a reference only refers to one > +unambiguous. Unlike \*(L"Donald Trump\*(R", a reference only refers to one > thing, and you always know what it refers to. If you have a reference > to an array, you can recover the entire array from it. If you have a > reference to a hash, you can recover the entire hash. But the >
perlreftut.1.patch
--- perlreftut.1.orig Wed Nov 29 18:45:45 2017 +++ perlreftut.1Wed Nov 29 18:51:52 2017 @@ -140,11 +140,11 @@ reference that you're already familiar with. Think of the President of the United States: a messy, inconvenient bag of blood and bones. But to talk about him, or to represent him in a computer program, all -you need is the easy, convenient scalar string \*(L"Barack Obama\*(R". +you need is the easy, convenient scalar string \*(L"Donald Trump\*(R". .PP References in Perl are like names for arrays and hashes. They're Perl's private, internal names, so you can be sure they're -unambiguous. Unlike \*(L"Barack Obama\*(R", a reference only refers to one +unambiguous. Unlike \*(L"Donald Trump\*(R", a reference only refers to one thing, and you always know what it refers to. If you have a reference to an array, you can recover the entire array from it. If you have a reference to a hash, you can recover the entire hash. But the
Re: ACPI GPIO-signaled events
On Wed, Nov 29, 2017 at 11:31:18PM +0100, Mark Kettenis wrote: > Diff below adds support for ACPI GPIO-signaled events to the > chvgpio(4) driver. This makes the laptop I have here realize the lid > is closed or opened. > > ok? > ok mlarkin -ml > > Index: dev/acpi/acpi.c > === > RCS file: /cvs/src/sys/dev/acpi/acpi.c,v > retrieving revision 1.334 > diff -u -p -r1.334 acpi.c > --- dev/acpi/acpi.c 16 Nov 2017 18:12:27 - 1.334 > +++ dev/acpi/acpi.c 29 Nov 2017 22:16:52 - > @@ -834,6 +834,87 @@ acpi_pciroots_attach(struct device *dev, > } > } > > +/* GPIO support */ > + > +struct acpi_gpio_event { > + struct aml_node *node; > + int pin; > +}; > + > +void > +acpi_gpio_event_task(void *arg0, int arg1) > +{ > + struct aml_node *node = arg0; > + int pin = arg1; > + char name[5]; > + > + snprintf(name, sizeof(name), "_E%.2X", pin); > + aml_evalname(acpi_softc, node, name, 0, NULL, NULL); > +} > + > +int > +acpi_gpio_event(void *arg) > +{ > + struct acpi_gpio_event *ev = arg; > + > + acpi_addtask(acpi_softc, acpi_gpio_event_task, ev->node, ev->pin); > + return 1; > +} > + > +int > +acpi_gpio_parse_events(int crsidx, union acpi_resource *crs, void *arg) > +{ > + struct aml_node *devnode = arg; > + struct aml_node *node; > + uint16_t pin; > + > + switch (AML_CRSTYPE(crs)) { > + case LR_GPIO: > + node = aml_searchname(devnode, > + (char *)&crs->pad[crs->lr_gpio.res_off]); > + pin = *(uint16_t *)&crs->pad[crs->lr_gpio.pin_off]; > + if (crs->lr_gpio.type == LR_GPIO_INT && node && node->gpio) { > + struct acpi_gpio *gpio = node->gpio; > + struct acpi_gpio_event *ev; > + > + ev = malloc(sizeof(*ev), M_DEVBUF, M_WAITOK); > + ev->node = devnode; > + ev->pin = pin; > + gpio->intr_establish(gpio->cookie, pin, > + crs->lr_gpio.tflags, acpi_gpio_event, ev); > + } > + break; > + default: > + printf("%s: unknown resource type %d\n", __func__, > + AML_CRSTYPE(crs)); > + } > + > + return 0; > +} > + > +void > +acpi_register_gpio(struct acpi_softc *sc, struct aml_node *devnode) > +{ > + struct aml_value arg[2]; > + struct aml_node *node; > + struct aml_value res; > + > + /* Register GeneralPurposeIO address space. */ > + memset(&arg, 0, sizeof(arg)); > + arg[0].type = AML_OBJTYPE_INTEGER; > + arg[0].v_integer = ACPI_OPREG_GPIO; > + arg[1].type = AML_OBJTYPE_INTEGER; > + arg[1].v_integer = 1; > + node = aml_searchname(devnode, "_REG"); > + if (node && aml_evalnode(sc, node, 2, arg, NULL)) > + printf("%s: _REG failed\n", node->name); > + > + /* Register GPIO signaled ACPI events. */ > + if (aml_evalname(sc, devnode, "_AEI", 0, NULL, &res)) > + return; > + aml_parse_resource(&res, acpi_gpio_parse_events, devnode); > +} > + > void > acpi_attach(struct device *parent, struct device *self, void *aux) > { > Index: dev/acpi/acpivar.h > === > RCS file: /cvs/src/sys/dev/acpi/acpivar.h,v > retrieving revision 1.88 > diff -u -p -r1.88 acpivar.h > --- dev/acpi/acpivar.h17 Aug 2017 05:16:27 - 1.88 > +++ dev/acpi/acpivar.h29 Nov 2017 22:15:32 - > @@ -332,6 +332,8 @@ void acpi_wakeup(void *); > > int acpi_gasio(struct acpi_softc *, int, int, uint64_t, int, int, void *); > > +void acpi_register_gpio(struct acpi_softc *, struct aml_node *); > + > int acpi_set_gpehandler(struct acpi_softc *, int, > int (*)(struct acpi_softc *, int, void *), void *, int); > void acpi_enable_gpe(struct acpi_softc *, u_int32_t); > Index: dev/acpi/chvgpio.c > === > RCS file: /cvs/src/sys/dev/acpi/chvgpio.c,v > retrieving revision 1.7 > diff -u -p -r1.7 chvgpio.c > --- dev/acpi/chvgpio.c29 Nov 2017 15:22:22 - 1.7 > +++ dev/acpi/chvgpio.c29 Nov 2017 22:15:13 - > @@ -169,8 +169,6 @@ chvgpio_attach(struct device *parent, st > struct acpi_attach_args *aaa = aux; > struct chvgpio_softc *sc = (struct chvgpio_softc *)self; > struct aml_value res; > - struct aml_value arg[2]; > - struct aml_node *node; > int64_t uid; > int i; > > @@ -251,19 +249,11 @@ chvgpio_attach(struct device *parent, st > > printf(", %d pins\n", sc->sc_npins); > > - /* Register GeneralPurposeIO address space. */ > - memset(&arg, 0, sizeof(arg)); > - arg[0].type = AML_OBJTYPE_INTEGER; > - arg[0].v_integer = ACPI_OPREG_GPIO; > - arg[1].type = AML_OBJTYPE_INTEGER; > - arg[1].v_integer = 1; > - node = aml_searchname(sc->sc_node, "_REG"); > - if
ACPI GPIO-signaled events
Diff below adds support for ACPI GPIO-signaled events to the chvgpio(4) driver. This makes the laptop I have here realize the lid is closed or opened. ok? Index: dev/acpi/acpi.c === RCS file: /cvs/src/sys/dev/acpi/acpi.c,v retrieving revision 1.334 diff -u -p -r1.334 acpi.c --- dev/acpi/acpi.c 16 Nov 2017 18:12:27 - 1.334 +++ dev/acpi/acpi.c 29 Nov 2017 22:16:52 - @@ -834,6 +834,87 @@ acpi_pciroots_attach(struct device *dev, } } +/* GPIO support */ + +struct acpi_gpio_event { + struct aml_node *node; + int pin; +}; + +void +acpi_gpio_event_task(void *arg0, int arg1) +{ + struct aml_node *node = arg0; + int pin = arg1; + char name[5]; + + snprintf(name, sizeof(name), "_E%.2X", pin); + aml_evalname(acpi_softc, node, name, 0, NULL, NULL); +} + +int +acpi_gpio_event(void *arg) +{ + struct acpi_gpio_event *ev = arg; + + acpi_addtask(acpi_softc, acpi_gpio_event_task, ev->node, ev->pin); + return 1; +} + +int +acpi_gpio_parse_events(int crsidx, union acpi_resource *crs, void *arg) +{ + struct aml_node *devnode = arg; + struct aml_node *node; + uint16_t pin; + + switch (AML_CRSTYPE(crs)) { + case LR_GPIO: + node = aml_searchname(devnode, + (char *)&crs->pad[crs->lr_gpio.res_off]); + pin = *(uint16_t *)&crs->pad[crs->lr_gpio.pin_off]; + if (crs->lr_gpio.type == LR_GPIO_INT && node && node->gpio) { + struct acpi_gpio *gpio = node->gpio; + struct acpi_gpio_event *ev; + + ev = malloc(sizeof(*ev), M_DEVBUF, M_WAITOK); + ev->node = devnode; + ev->pin = pin; + gpio->intr_establish(gpio->cookie, pin, + crs->lr_gpio.tflags, acpi_gpio_event, ev); + } + break; + default: + printf("%s: unknown resource type %d\n", __func__, + AML_CRSTYPE(crs)); + } + + return 0; +} + +void +acpi_register_gpio(struct acpi_softc *sc, struct aml_node *devnode) +{ + struct aml_value arg[2]; + struct aml_node *node; + struct aml_value res; + + /* Register GeneralPurposeIO address space. */ + memset(&arg, 0, sizeof(arg)); + arg[0].type = AML_OBJTYPE_INTEGER; + arg[0].v_integer = ACPI_OPREG_GPIO; + arg[1].type = AML_OBJTYPE_INTEGER; + arg[1].v_integer = 1; + node = aml_searchname(devnode, "_REG"); + if (node && aml_evalnode(sc, node, 2, arg, NULL)) + printf("%s: _REG failed\n", node->name); + + /* Register GPIO signaled ACPI events. */ + if (aml_evalname(sc, devnode, "_AEI", 0, NULL, &res)) + return; + aml_parse_resource(&res, acpi_gpio_parse_events, devnode); +} + void acpi_attach(struct device *parent, struct device *self, void *aux) { Index: dev/acpi/acpivar.h === RCS file: /cvs/src/sys/dev/acpi/acpivar.h,v retrieving revision 1.88 diff -u -p -r1.88 acpivar.h --- dev/acpi/acpivar.h 17 Aug 2017 05:16:27 - 1.88 +++ dev/acpi/acpivar.h 29 Nov 2017 22:15:32 - @@ -332,6 +332,8 @@ void acpi_wakeup(void *); int acpi_gasio(struct acpi_softc *, int, int, uint64_t, int, int, void *); +void acpi_register_gpio(struct acpi_softc *, struct aml_node *); + intacpi_set_gpehandler(struct acpi_softc *, int, int (*)(struct acpi_softc *, int, void *), void *, int); void acpi_enable_gpe(struct acpi_softc *, u_int32_t); Index: dev/acpi/chvgpio.c === RCS file: /cvs/src/sys/dev/acpi/chvgpio.c,v retrieving revision 1.7 diff -u -p -r1.7 chvgpio.c --- dev/acpi/chvgpio.c 29 Nov 2017 15:22:22 - 1.7 +++ dev/acpi/chvgpio.c 29 Nov 2017 22:15:13 - @@ -169,8 +169,6 @@ chvgpio_attach(struct device *parent, st struct acpi_attach_args *aaa = aux; struct chvgpio_softc *sc = (struct chvgpio_softc *)self; struct aml_value res; - struct aml_value arg[2]; - struct aml_node *node; int64_t uid; int i; @@ -251,19 +249,11 @@ chvgpio_attach(struct device *parent, st printf(", %d pins\n", sc->sc_npins); - /* Register GeneralPurposeIO address space. */ - memset(&arg, 0, sizeof(arg)); - arg[0].type = AML_OBJTYPE_INTEGER; - arg[0].v_integer = ACPI_OPREG_GPIO; - arg[1].type = AML_OBJTYPE_INTEGER; - arg[1].v_integer = 1; - node = aml_searchname(sc->sc_node, "_REG"); - if (node && aml_evalnode(sc->sc_acpi, node, 2, arg, NULL)) - printf("%s: _REG failed\n", sc->sc_dev.dv_xname); - /* Register OEM defined address space. */ aml_register_regionspace(sc->sc_node, CHVGPIO_REGIONSPACE_BASE + uid,
slaacd(8): Move privileged initialization from frontend to main process.
Move privileged initialization from frontend to main process. Needed for future work where we will spin up children via fork - privdrop - exec. OK? diff --git control.c control.c index 76b0f3b15ea..96a6206c874 100644 --- control.c +++ control.c @@ -85,9 +85,7 @@ control_init(char *path) return (-1); } - control_state.fd = fd; - - return (0); + return (fd); } int diff --git frontend.c frontend.c index 8998e3d2785..8c9823b39c6 100644 --- frontend.c +++ frontend.c @@ -84,7 +84,7 @@ struct nd_router_solicit rs; struct nd_opt_hdr nd_opt_hdr; struct ether_addr nd_opt_source_link_addr; struct sockaddr_in6 dst; -int icmp6sock, routesock, ioctlsock; +int icmp6sock = -1, ioctlsock; struct icmp6_ev { struct event ev; @@ -112,24 +112,21 @@ frontend_sig_handler(int sig, short event, void *bula) } void -frontend(int debug, int verbose, char *sockname) +frontend(int debug, int verbose) { struct event ev_sigint, ev_sigterm; struct passwd *pw; - struct icmp6_filter filt; struct in6_pktinfo *pi; struct cmsghdr *cm; size_t rcvcmsglen, sndcmsglen; - int hoplimit = 255, on = 1, rtfilter; + int hoplimit = 255; uint8_t *rcvcmsgbuf, *sndcmsgbuf; log_init(debug, LOG_DAEMON); log_setverbose(verbose); #ifndefSMALL - /* Create slaacd control socket outside chroot. */ - if (control_init(sockname) == -1) - fatalx("control socket setup failed"); + control_state.fd = -1; #endif /* SMALL */ if ((pw = getpwnam(SLAACD_USER)) == NULL) @@ -144,12 +141,6 @@ frontend(int debug, int verbose, char *sockname) setproctitle("%s", log_procnames[slaacd_process]); log_procinit(log_procnames[slaacd_process]); - if ((icmp6sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) - fatal("ICMPv6 socket"); - - if ((routesock = socket(PF_ROUTE, SOCK_RAW, 0)) < 0) - fatal("route socket"); - if ((ioctlsock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) fatal("socket"); @@ -158,27 +149,6 @@ frontend(int debug, int verbose, char *sockname) setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) fatal("can't drop privileges"); - if (setsockopt(icmp6sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, - sizeof(on)) < 0) - fatal("IPV6_RECVPKTINFO"); - - if (setsockopt(icmp6sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on, - sizeof(on)) < 0) - fatal("IPV6_RECVHOPLIMIT"); - - /* only router advertisements */ - ICMP6_FILTER_SETBLOCKALL(&filt); - ICMP6_FILTER_SETPASS(ND_ROUTER_ADVERT, &filt); - if (setsockopt(icmp6sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt, - sizeof(filt)) == -1) - fatal("ICMP6_FILTER"); - - rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_NEWADDR) | - ROUTE_FILTER(RTM_DELADDR) | ROUTE_FILTER(RTM_PROPOSAL); - if (setsockopt(routesock, PF_ROUTE, ROUTE_MSGFILTER, - &rtfilter, sizeof(rtfilter)) < 0) - fatal("setsockopt(ROUTE_MSGFILTER)"); - if (pledge("stdio inet recvfd route", NULL) == -1) fatal("pledge"); @@ -202,18 +172,6 @@ frontend(int debug, int verbose, char *sockname) iev_main->handler, iev_main); event_add(&iev_main->ev, NULL); -#ifndefSMALL - /* Listen on control socket. */ - TAILQ_INIT(&ctl_conns); - control_listen(); -#endif /* SMALL */ - - event_set(&ev_route, routesock, EV_READ | EV_PERSIST, route_receive, - NULL); - - event_set(&icmp6ev.ev, icmp6sock, EV_READ | EV_PERSIST, icmp6_receive, - NULL); - rcvcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int)); if((rcvcmsgbuf = malloc(rcvcmsglen)) == NULL) @@ -369,12 +327,38 @@ frontend_dispatch_main(int fd, short event, void *bula) event_set(&iev_engine->ev, iev_engine->ibuf.fd, iev_engine->events, iev_engine->handler, iev_engine); event_add(&iev_engine->ev, NULL); - - if (pledge("stdio inet route", NULL) == -1) - fatal("pledge"); - + break; + case IMSG_ICMP6SOCK: + if ((icmp6sock = imsg.fd) == -1) + fatalx("%s: expected to receive imsg " + "ICMPv6 fd but didn't receive any", + __func__); + event_set(&icmp6ev.ev, icmp6sock, EV_READ | EV_PERSIST, + icmp6_rec
glamor_egl build error
The attached diff fixes an error when building xenocara with XENOCARA_BUILD_GALLIUM=llvm set. Attaching instead of inline, as I've read on here the gmail mangles whitespace ... or something. Thanks, Tracey Index: Makefile.am === RCS file: /cvs/xenocara/xserver/hw/xfree86/glamor_egl/Makefile.am,v retrieving revision 1.2 diff -u -p -r1.2 Makefile.am --- Makefile.am 16 Sep 2015 19:10:22 - 1.2 +++ Makefile.am 29 Nov 2017 19:28:51 - @@ -39,6 +39,7 @@ libglamoregl_la_LIBADD = \ AM_CPPFLAGS = $(XORG_INCS) \ -I$(top_srcdir)/dri3 \ -I$(top_srcdir)/glamor \ + @GL_CFLAGS@ \ $() AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(GLAMOR_CFLAGS) $(GBM_CFLAGS) Index: Makefile.in === RCS file: /cvs/xenocara/xserver/hw/xfree86/glamor_egl/Makefile.in,v retrieving revision 1.5 diff -u -p -r1.5 Makefile.in --- Makefile.in 11 Oct 2016 22:15:55 - 1.5 +++ Makefile.in 29 Nov 2017 19:28:51 - @@ -543,6 +543,7 @@ libglamoregl_la_LIBADD = \ AM_CPPFLAGS = $(XORG_INCS) \ -I$(top_srcdir)/dri3 \ -I$(top_srcdir)/glamor \ + @GL_CFLAGS@ \ $() AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(GLAMOR_CFLAGS) $(GBM_CFLAGS)
unlock more of rtsock
This diff changes the the PCB list into an SRP list. Therefor concurrent access is no longer an issue and route_input() could be more unlocked. There is not much point of releasing the KERNEL_LOCK for now but I added commented lock / unlock to the code. Next on the list are now the socekt functions sorwakeup, sbspace and sbappendaddr. If those are save then route_input should be save. If this is the way to go then doing the same for pfkey should be straight forward. Looking forward to test reports and comments -- :wq Claudio Index: net/rtsock.c === RCS file: /cvs/src/sys/net/rtsock.c,v retrieving revision 1.255 diff -u -p -r1.255 rtsock.c --- net/rtsock.c3 Nov 2017 16:23:20 - 1.255 +++ net/rtsock.c29 Nov 2017 18:54:26 - @@ -70,6 +70,7 @@ #include #include #include +#include #include #include @@ -94,7 +95,6 @@ #include #include -struct sockaddrroute_dst = { 2, PF_ROUTE, }; struct sockaddrroute_src = { 2, PF_ROUTE, }; struct walkarg { @@ -103,6 +103,8 @@ struct walkarg { }; void route_prinit(void); +void route_ref(void *, void *); +void route_unref(void *, void *); introute_output(struct mbuf *, struct socket *, struct sockaddr *, struct mbuf *); introute_ctloutput(int, struct socket *, int, int, struct mbuf *); @@ -133,7 +135,8 @@ int sysctl_rtable_rtstat(void *, size_ struct routecb { struct rawcbrcb; - LIST_ENTRY(routecb) rcb_list; + SRPL_ENTRY(routecb) rcb_list; + struct refcnt refcnt; struct timeout timeout; unsigned intmsgfilter; unsigned intflags; @@ -142,11 +145,10 @@ struct routecb { #definesotoroutecb(so) ((struct routecb *)(so)->so_pcb) struct route_cb { - LIST_HEAD(, routecb)rcb; - int ip_count; - int ip6_count; - int mpls_count; - int any_count; + SRPL_HEAD(, routecb)rcb; + struct srpl_rc rcb_rc; + struct rwlock rcb_lk; + unsigned intany_count; }; struct route_cb route_cb; @@ -165,9 +167,26 @@ struct route_cb route_cb; void route_prinit(void) { - LIST_INIT(&route_cb.rcb); + srpl_rc_init(&route_cb.rcb_rc, route_ref, route_unref, NULL); + rw_init(&route_cb.rcb_lk, "rtsock"); + SRPL_INIT(&route_cb.rcb); } +void +route_ref(void *null, void *v) +{ + struct routecb *rop = v; + + refcnt_take(&rop->refcnt); +} + +void +route_unref(void *null, void *v) +{ + struct routecb *rop = v; + + refcnt_rele_wake(&rop->refcnt); +} int route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, @@ -218,9 +237,10 @@ route_attach(struct socket *so, int prot */ rop = malloc(sizeof(struct routecb), M_PCB, M_WAITOK|M_ZERO); rp = &rop->rcb; - so->so_pcb = rp; + so->so_pcb = rop; /* Init the timeout structure */ - timeout_set(&rop->timeout, route_senddesync, rp); + timeout_set(&rop->timeout, route_senddesync, rop); + refcnt_init(&rop->refcnt); if (curproc == NULL) error = EACCES; @@ -230,31 +250,33 @@ route_attach(struct socket *so, int prot free(rop, M_PCB, sizeof(struct routecb)); return (error); } + rp->rcb_socket = so; rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family; rp->rcb_proto.sp_protocol = proto; rop->rtableid = curproc->p_p->ps_rtableid; - switch (rp->rcb_proto.sp_protocol) { - case AF_INET: - route_cb.ip_count++; - break; - case AF_INET6: - route_cb.ip6_count++; - break; -#ifdef MPLS - case AF_MPLS: - route_cb.mpls_count++; - break; -#endif - } soisconnected(so); so->so_options |= SO_USELOOPBACK; + /* KERNEL_UNLOCK(); */ + rp->rcb_faddr = &route_src; + + error = rw_enter(&route_cb.rcb_lk, RW_WRITE); + if (error != 0) { + free(rop, M_PCB, sizeof(struct routecb)); + /* KERNEL_LOCK(); */ + return (error); + } + + SRPL_INSERT_HEAD_LOCKED(&route_cb.rcb_rc, &route_cb.rcb, rop, rcb_list); route_cb.any_count++; - LIST_INSERT_HEAD(&route_cb.rcb, rop, rcb_list); + + rw_exit(&route_cb.rcb_lk); + + /* KERNEL_LOCK(); */ return (0); } @@ -263,7 +285,7 @@ int route_detach(struct socket *so) { struct routecb *rop; - int af; + int error; soassertlocked(so); @@ -271,18 +293,24 @@ route_detach(struct socket *so) if (rop == NULL) return (EINVAL)
iwm(4): newstate error recovery
If iwm_newstate() fails, queue the init task to reset the device. This should prevent hangs some people have been reporting. Tests? OK? Index: if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.217 diff -u -p -r1.217 if_iwm.c --- if_iwm.c26 Oct 2017 15:00:28 - 1.217 +++ if_iwm.c29 Nov 2017 19:12:16 - @@ -6056,8 +6056,12 @@ iwm_newstate_task(void *psc) } out: - if (err == 0 && (sc->sc_flags & IWM_FLAG_SHUTDOWN) == 0) - sc->sc_newstate(ic, nstate, arg); + if ((sc->sc_flags & IWM_FLAG_SHUTDOWN) == 0) { + if (err) + task_add(systq, &sc->init_task); + else + sc->sc_newstate(ic, nstate, arg); + } refcnt_rele_wake(&sc->task_refs); splx(s); }
iwm(4) background scan
This is an initial implementation of background scanning for iwm(4). The intention is to transparently roam between access points with the same SSID. This implementation is functionally complete, but it may still need some tuning. Background scans are triggered if the received signal strength indicator for our current AP falls below a fixed threshold. This is a simple heuristic. We could tweak this heuristic, and add, or replace it with, other heuristics in the future. If a better AP is found, we deauth from our current AP and then try to associate with our new AP of choice. If we can successfully associate, we roam with virtually no interruption of link. If association fails, we drop into the usual scan loop as a fallback. If no better AP is found, background scans will occur less and less frequently over time. When a better AP is found, this backoff resets. The longest interval is hard-coded to 3 minutes (if I got my math right). Most changes are in the net80211 stack. Once this feature has proven itself with iwm(4) we could add support for other drivers. Slightly tested in the hack hut. OK? Index: dev/pci/if_iwm.c === RCS file: /cvs/src/sys/dev/pci/if_iwm.c,v retrieving revision 1.217 diff -u -p -r1.217 if_iwm.c --- dev/pci/if_iwm.c26 Oct 2017 15:00:28 - 1.217 +++ dev/pci/if_iwm.c29 Nov 2017 18:53:27 - @@ -420,9 +420,9 @@ uint32_t iwm_scan_rate_n_flags(struct iw uint8_tiwm_lmac_scan_fill_channels(struct iwm_softc *, struct iwm_scan_channel_cfg_lmac *, int); intiwm_fill_probe_req(struct iwm_softc *, struct iwm_scan_probe_req *); -intiwm_lmac_scan(struct iwm_softc *); +intiwm_lmac_scan(struct iwm_softc *, int); intiwm_config_umac_scan(struct iwm_softc *); -intiwm_umac_scan(struct iwm_softc *); +intiwm_umac_scan(struct iwm_softc *, int); uint8_tiwm_ridx2rate(struct ieee80211_rateset *, int); intiwm_rval2ridx(int); void iwm_ack_rates(struct iwm_softc *, struct iwm_node *, int *, int *); @@ -435,6 +435,7 @@ int iwm_update_quotas(struct iwm_softc * void iwm_add_task(struct iwm_softc *, struct taskq *, struct task *); void iwm_del_task(struct iwm_softc *, struct taskq *, struct task *); intiwm_scan(struct iwm_softc *); +intiwm_bgscan(struct ieee80211com *); intiwm_auth(struct iwm_softc *); intiwm_deauth(struct iwm_softc *); intiwm_assoc(struct iwm_softc *); @@ -4868,7 +4869,7 @@ iwm_fill_probe_req(struct iwm_softc *sc, } int -iwm_lmac_scan(struct iwm_softc *sc) +iwm_lmac_scan(struct iwm_softc *sc, int bgscan) { struct ieee80211com *ic = &sc->sc_ic; struct iwm_host_cmd hcmd = { @@ -4879,28 +4880,34 @@ iwm_lmac_scan(struct iwm_softc *sc) }; struct iwm_scan_req_lmac *req; size_t req_len; - int err; + int err, async = bgscan; req_len = sizeof(struct iwm_scan_req_lmac) + (sizeof(struct iwm_scan_channel_cfg_lmac) * sc->sc_capa_n_scan_channels) + sizeof(struct iwm_scan_probe_req); if (req_len > IWM_MAX_CMD_PAYLOAD_SIZE) return ENOMEM; - req = malloc(req_len, M_DEVBUF, M_WAIT | M_CANFAIL | M_ZERO); + req = malloc(req_len, M_DEVBUF, + (async ? M_NOWAIT : M_WAIT) | M_CANFAIL | M_ZERO); if (req == NULL) return ENOMEM; hcmd.len[0] = (uint16_t)req_len; hcmd.data[0] = (void *)req; + hcmd.flags |= async ? IWM_CMD_ASYNC : 0; /* These timings correspond to iwlwifi's UNASSOC scan. */ req->active_dwell = 10; req->passive_dwell = 110; req->fragmented_dwell = 44; req->extended_dwell = 90; - req->max_out_time = 0; - req->suspend_time = 0; - + if (bgscan) { + req->max_out_time = htole32(120); + req->suspend_time = htole32(120); + } else { + req->max_out_time = htole32(0); + req->suspend_time = htole32(0); + } req->scan_prio = htole32(IWM_SCAN_PRIORITY_HIGH); req->rx_chain_select = iwm_scan_rx_chain(sc); req->iter_num = htole32(1); @@ -5048,7 +5055,7 @@ iwm_config_umac_scan(struct iwm_softc *s } int -iwm_umac_scan(struct iwm_softc *sc) +iwm_umac_scan(struct iwm_softc *sc, int bgscan) { struct ieee80211com *ic = &sc->sc_ic; struct iwm_host_cmd hcmd = { @@ -5060,7 +5067,7 @@ iwm_umac_scan(struct iwm_softc *sc) struct iwm_scan_req_umac *req; struct iwm_scan_req_umac_tail *tail; size_t req_len; - int err; + int err, async = bgscan; req_len = sizeof(struct iwm_scan_req_umac) + (sizeof(struct iwm_scan_channel_cfg_umac) * @@ -5068,20 +5075,27 @@ iwm_umac_scan(struct iwm_softc *sc) sizeof(struct iwm_scan_req_umac_tail); if (req_len > IWM_MAX_CMD_PAYLOAD_SIZE) return ENOMEM; - req = malloc(req_len, M_DEVBUF, M
Re: iked, don't return NULL in print_host
On Wed, Nov 29, 2017 at 05:32:11PM +0100, Patrick Wildt wrote: > On Wed, Nov 29, 2017 at 04:32:24PM +0100, Claudio Jeker wrote: > > On Wed, Nov 29, 2017 at 02:43:45AM +0100, Jeremie Courreges-Anglas wrote: > > > On Wed, Nov 29 2017, Claudio Jeker wrote: > > > > On Wed, Nov 29, 2017 at 01:59:06AM +0100, Claudio Jeker wrote: > > > >> Seen in my log file: > > > >> Nov 28 17:47:22 dramaqueen iked: vfprintf %s NULL in "%s: %s %s from > > > >> %s to > > > >> %s ms gid %u, %ld bytes%s" > > > >> > > > >> and > > > >> > > > >> Nov 29 01:02:39 dramaqueen iked[49967]: ikev2_msg_send: IKE_SA_INIT > > > >> request from (null) to 62.48.30.5:500 msgid 0, 438 bytes > > > >> > > > >> The problem seems to be in print_host so try to not return NULL in > > > >> there. > > > >> Maybe we could return something else but this is a start IMO. > > > > > > > > beck@ prefers to just print unknown instead of the gai_strerror -- > > > > guess > > > > that is more sensible. > > > > > > Why would getnameinfo(NI_NUMERICHOST) fail here? The code in > > > ikev2_msg.c is: > > > > > > --8<-- > > > log_info("%s: %s %s from %s to %s msgid %u, %ld bytes%s", __func__, > > > print_map(exchange, ikev2_exchange_map), > > > (flags & IKEV2_FLAG_RESPONSE) ? "response" : "request", > > > print_host((struct sockaddr *)&msg->msg_local, NULL, 0), > > > print_host((struct sockaddr *)&msg->msg_peer, NULL, 0), > > > betoh32(hdr->ike_msgid), > > > ibuf_length(buf), isnatt ? ", NAT-T" : ""); > > > -->8-- > > > > > > Maybe msg->msg_local is corrupt? > > > > > > > I assume so much. gai_strerror returns "system error" not very helpful. > > I would like to find out where that comes from. What's your setup? I > guess you can reproduce it easily? More or less. It seems that msg_local is garbage: $3 = {msg_data = 0x1b4e541fa4c0, msg_offset = 0, msg_local = { ss_len = 128 '\200', ss_family = 192 'À', __ss_pad1 = 0x7f7da8c2 "Ì]\001", __ss_pad2 = 30024042514159, __ss_pad3 = 0x7f7da8d0 "Ьýÿ\177\177"}, msg_locallen = 128, msg_peer = {ss_len = 16 '\020', ss_family = 2 '\002', __ss_pad1 = 0x7f7da9ca "\001ô>0\036\005", __ss_pad2 = 0, __ss_pad3 = 0x7f7da9d8 ""}, msg_peerlen = 16, Why so I don't know. Config is: ikev2 "tunnel" active esp proto ipencap from 10.83.66.133/32 to 10.83.66.6/32 \ peer 62.48.30.5 \ ikesa group modp2048 \ srcid dramaqueen.zyd.ch rsa ikev2 "tunnel" active esp proto ipv6 from 10.83.66.133/32 to 10.83.66.6/32 \ peer 62.48.30.5 \ ikesa group modp2048 \ srcid dramaqueen6.zyd.ch The other end does not listen to iked so the connections never succeed. Maybe this helps. -- :wq Claudio
Re: iked, don't return NULL in print_host
On Wed, Nov 29 2017, Patrick Wildt wrote: > On Wed, Nov 29, 2017 at 04:32:24PM +0100, Claudio Jeker wrote: >> On Wed, Nov 29, 2017 at 02:43:45AM +0100, Jeremie Courreges-Anglas wrote: >> > On Wed, Nov 29 2017, Claudio Jeker wrote: >> > > On Wed, Nov 29, 2017 at 01:59:06AM +0100, Claudio Jeker wrote: >> > >> Seen in my log file: >> > >> Nov 28 17:47:22 dramaqueen iked: vfprintf %s NULL in "%s: %s %s from %s >> > >> to >> > >> %s ms gid %u, %ld bytes%s" >> > >> >> > >> and >> > >> >> > >> Nov 29 01:02:39 dramaqueen iked[49967]: ikev2_msg_send: IKE_SA_INIT >> > >> request from (null) to 62.48.30.5:500 msgid 0, 438 bytes >> > >> >> > >> The problem seems to be in print_host so try to not return NULL in >> > >> there. >> > >> Maybe we could return something else but this is a start IMO. >> > > >> > > beck@ prefers to just print unknown instead of the gai_strerror -- guess >> > > that is more sensible. >> > >> > Why would getnameinfo(NI_NUMERICHOST) fail here? The code in >> > ikev2_msg.c is: >> > >> > --8<-- >> >log_info("%s: %s %s from %s to %s msgid %u, %ld bytes%s", __func__, >> >print_map(exchange, ikev2_exchange_map), >> >(flags & IKEV2_FLAG_RESPONSE) ? "response" : "request", >> >print_host((struct sockaddr *)&msg->msg_local, NULL, 0), >> >print_host((struct sockaddr *)&msg->msg_peer, NULL, 0), >> >betoh32(hdr->ike_msgid), >> >ibuf_length(buf), isnatt ? ", NAT-T" : ""); >> > -->8-- >> > >> > Maybe msg->msg_local is corrupt? >> > >> >> I assume so much. gai_strerror returns "system error" not very helpful. > > I would like to find out where that comes from. What's your setup? I > guess you can reproduce it easily? btw, "system error" may not be helpful, but afaik if you get EAI_SYSTEM you're supposed to look at errno. (asr has a mechanism to save and restore the proper errno). -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: iked, don't return NULL in print_host
On Wed, Nov 29, 2017 at 04:32:24PM +0100, Claudio Jeker wrote: > On Wed, Nov 29, 2017 at 02:43:45AM +0100, Jeremie Courreges-Anglas wrote: > > On Wed, Nov 29 2017, Claudio Jeker wrote: > > > On Wed, Nov 29, 2017 at 01:59:06AM +0100, Claudio Jeker wrote: > > >> Seen in my log file: > > >> Nov 28 17:47:22 dramaqueen iked: vfprintf %s NULL in "%s: %s %s from %s > > >> to > > >> %s ms gid %u, %ld bytes%s" > > >> > > >> and > > >> > > >> Nov 29 01:02:39 dramaqueen iked[49967]: ikev2_msg_send: IKE_SA_INIT > > >> request from (null) to 62.48.30.5:500 msgid 0, 438 bytes > > >> > > >> The problem seems to be in print_host so try to not return NULL in there. > > >> Maybe we could return something else but this is a start IMO. > > > > > > beck@ prefers to just print unknown instead of the gai_strerror -- guess > > > that is more sensible. > > > > Why would getnameinfo(NI_NUMERICHOST) fail here? The code in > > ikev2_msg.c is: > > > > --8<-- > > log_info("%s: %s %s from %s to %s msgid %u, %ld bytes%s", __func__, > > print_map(exchange, ikev2_exchange_map), > > (flags & IKEV2_FLAG_RESPONSE) ? "response" : "request", > > print_host((struct sockaddr *)&msg->msg_local, NULL, 0), > > print_host((struct sockaddr *)&msg->msg_peer, NULL, 0), > > betoh32(hdr->ike_msgid), > > ibuf_length(buf), isnatt ? ", NAT-T" : ""); > > -->8-- > > > > Maybe msg->msg_local is corrupt? > > > > I assume so much. gai_strerror returns "system error" not very helpful. I would like to find out where that comes from. What's your setup? I guess you can reproduce it easily?
Re: iked, don't return NULL in print_host
On Wed, Nov 29, 2017 at 02:43:45AM +0100, Jeremie Courreges-Anglas wrote: > On Wed, Nov 29 2017, Claudio Jeker wrote: > > On Wed, Nov 29, 2017 at 01:59:06AM +0100, Claudio Jeker wrote: > >> Seen in my log file: > >> Nov 28 17:47:22 dramaqueen iked: vfprintf %s NULL in "%s: %s %s from %s to > >> %s ms gid %u, %ld bytes%s" > >> > >> and > >> > >> Nov 29 01:02:39 dramaqueen iked[49967]: ikev2_msg_send: IKE_SA_INIT > >> request from (null) to 62.48.30.5:500 msgid 0, 438 bytes > >> > >> The problem seems to be in print_host so try to not return NULL in there. > >> Maybe we could return something else but this is a start IMO. > > > > beck@ prefers to just print unknown instead of the gai_strerror -- guess > > that is more sensible. > > Why would getnameinfo(NI_NUMERICHOST) fail here? The code in > ikev2_msg.c is: > > --8<-- > log_info("%s: %s %s from %s to %s msgid %u, %ld bytes%s", __func__, > print_map(exchange, ikev2_exchange_map), > (flags & IKEV2_FLAG_RESPONSE) ? "response" : "request", > print_host((struct sockaddr *)&msg->msg_local, NULL, 0), > print_host((struct sockaddr *)&msg->msg_peer, NULL, 0), > betoh32(hdr->ike_msgid), > ibuf_length(buf), isnatt ? ", NAT-T" : ""); > -->8-- > > Maybe msg->msg_local is corrupt? > I assume so much. gai_strerror returns "system error" not very helpful. -- :wq Claudio
Re: relayd/ctl alternative control socket
Kapetanakis Giannis(bil...@edu.physics.uoc.gr) on 2017.11.29 11:40:41 +0200: > On 28/11/17 17:06, Sebastian benoit wrote: > > Hi, > > > > your diff looks good, but i would rather do it the way bgpd/bgpctl do it: > > > > there the default is? /var/run/bgpd.sock. where is the > > routing domain bgpctl is running in.? To administer bgpd(8) in a different > > routing domain, run bgpctl in said routing domain. > > > > i.e. it detects the rdomain at startup, bgpctl does the same. > > > > Can you do that in relayd? It was commited there in sometime in summer. > > > > /Benno > > I followed snmpd way. > > My first diff was with -s command line option (ospfd, ldpd, iscsid, slaccd, > ripd way). > Then I changed it to relayd.conf socket option cause I saw a comment from > Reyk on an older thread that this is the way to go. > https://marc.info/?l=openbsd-tech&m=148840138521470&w=2 > > I don't think locking on rdomain is good in relayd since someone might want > to run multiple daemons on same rdomain. With bgpd this is not a requirement. well, i was thinking of having both the option and the automatic .. anyway, i commited your diff. Thanks. > Anyway if the patch is ok I believe it should go in because this feature is > really needed by many people. > Then later on if a universal way is decided on handling control sockets it > should be changed on all daemons > not following that decision. > > G >
Re: isakmpd: use monotonic clock for event timeouts
On Mon, Nov 27, 2017 at 08:36:33PM -0600, Scott Cheloha wrote: > > > On Nov 27, 2017, at 9:54 AM, Jeremie Courreges-Anglas > > wrote: > > > > On Fri, Nov 24 2017, Scott Cheloha wrote: > >> Hi, > >> > >> [...] > >> > >> Thoughts and feedback? > > > > This seems to mix refactoring, eg changing the signature of > > timer_add_event(), with semantic changes. Could you please > > split your diff in seperate steps easier to review? > > Sure thing. Here's part 1: use monotime for everything event-related. -- Scott Cheloha Index: sbin/isakmpd/connection.c === RCS file: /cvs/src/sbin/isakmpd/connection.c,v retrieving revision 1.38 diff -u -p -r1.38 connection.c --- sbin/isakmpd/connection.c 6 Aug 2017 13:54:04 - 1.38 +++ sbin/isakmpd/connection.c 29 Nov 2017 13:50:13 - @@ -31,7 +31,6 @@ */ #include -#include #include #include #include @@ -71,7 +70,7 @@ struct connection_passive { /* XXX Potential additions to 'connection_passive'. */ char *isakmp_peer; struct sa *sa; /* XXX "Soft" ref to active sa? */ - struct timeval sa_expiration; /* XXX *sa may expire. */ + struct timespec sa_expiration; /* XXX *sa may expire. */ #endif }; @@ -144,11 +143,11 @@ connection_init(void) static void connection_checker(void *vconn) { - struct timeval now; + struct timespec now; struct connection *conn = vconn; char *name; - gettimeofday(&now, 0); + clock_gettime(CLOCK_MONOTONIC, &now); now.tv_sec += conf_get_num("General", "check-interval", CHECK_INTERVAL); conn->ev = timer_add_event("connection_checker", @@ -272,7 +271,7 @@ int connection_setup(char *name) { struct connection *conn = 0; - struct timeval now; + struct timespec now; /* Check for trials to add duplicate connections. */ if (connection_lookup(name)) { @@ -291,7 +290,7 @@ connection_setup(char *name) log_error("connection_setup: strdup (\"%s\") failed", name); goto fail; } - gettimeofday(&now, 0); + clock_gettime(CLOCK_MONOTONIC, &now); conn->ev = timer_add_event("connection_checker", connection_checker, conn, &now); if (!conn->ev) { @@ -405,11 +404,11 @@ void connection_report(void) { struct connection *conn; - struct timeval now; + struct timespec now; struct connection_passive *pconn; struct doi *doi = doi_lookup(ISAKMP_DOI_ISAKMP); - gettimeofday(&now, 0); + clock_gettime(CLOCK_MONOTONIC, &now); for (conn = TAILQ_FIRST(&connections); conn; conn = TAILQ_NEXT(conn, link)) LOG_DBG((LOG_REPORT, 0, Index: sbin/isakmpd/dpd.c === RCS file: /cvs/src/sbin/isakmpd/dpd.c,v retrieving revision 1.19 diff -u -p -r1.19 dpd.c --- sbin/isakmpd/dpd.c 10 Dec 2015 17:27:00 - 1.19 +++ sbin/isakmpd/dpd.c 29 Nov 2017 13:50:13 - @@ -216,23 +216,23 @@ dpd_timer_interval(u_int32_t offset) static void dpd_timer_reset(struct sa *sa, u_int32_t time_passed, enum dpd_tstate mode) { - struct timeval tv; + struct timespec ts; if (sa->dpd_event) timer_remove_event(sa->dpd_event); - gettimeofday(&tv, 0); + clock_gettime(CLOCK_MONOTONIC, &ts); switch (mode) { case DPD_TIMER_NORMAL: sa->dpd_failcount = 0; - tv.tv_sec += dpd_timer_interval(time_passed); + ts.tv_sec += dpd_timer_interval(time_passed); sa->dpd_event = timer_add_event("dpd_event", dpd_event, sa, - &tv); + &ts); break; case DPD_TIMER_CHECK: - tv.tv_sec += DPD_RETRANS_WAIT; + ts.tv_sec += DPD_RETRANS_WAIT; sa->dpd_event = timer_add_event("dpd_check_event", - dpd_check_event, sa, &tv); + dpd_check_event, sa, &ts); break; default: break; @@ -267,7 +267,7 @@ dpd_check_time(struct sa *sa, void *v_ar struct sockaddr *dst; struct proto *proto; struct sa_kinfo *ksa; - struct timeval tv; + struct timespec ts; if (sa->phase == 1 || (args->isakmp_sa->flags & SA_FLAG_DPD) == 0 || dpd_find_sa(sa, args->isakmp_sa) == 0) @@ -278,7 +278,7 @@ dpd_check_time(struct sa *sa, void *v_ar return 0; sa->transport->vtbl->get_src(sa->transport, &dst); - gettimeofday(&tv, 0); + clock_gettime(CLOCK_MONOTONIC, &ts); ksa = pf_key_v2_get_kernel_sa(proto->spi[1], proto->spi_sz[1], proto->proto, dst); @@ -287,10 +287,10 @@ dpd_check_time(struct sa *sa, void *v_ar LOG_DBG((LOG_MESSAGE, 80, "dpd_check_time: "
armv7/sxie/if_dwge: get&set "local-mac-address"
Hi, now as u-boot env is more likely to be found in the FAT by default[0], i presume there will be more use for this, so that things work consistently across all ethernet drivers(except if_dwxe) on armv7. just reading what might be set in the registers already doesn't really work out consistently, as it might not get set out of the box without messing with u-boot distro_defaults, since efi payload does get run before dhcp/pxeboot or whatever; ie. the usual case to get things set w/o touching individual environment variables is to run the dhcp command on u-boot prompt. diff w/intention to be minimal. -Artturi [0] https://patchwork.ozlabs.org/cover/842057/ diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c index 116fda5f8d7..f4c6f8b1ca0 100644 --- a/sys/arch/armv7/sunxi/sxie.c +++ b/sys/arch/armv7/sunxi/sxie.c @@ -173,7 +173,7 @@ struct sxie_softc *sxie_sc; intsxie_match(struct device *, void *, void *); void sxie_attach(struct device *, struct device *, void *); void sxie_setup_interface(struct sxie_softc *, struct device *); -void sxie_socware_init(struct sxie_softc *); +void sxie_socware_init(struct sxie_softc *, int); intsxie_ioctl(struct ifnet *, u_long, caddr_t); void sxie_start(struct ifnet *); void sxie_watchdog(struct ifnet *); @@ -230,7 +230,7 @@ sxie_attach(struct device *parent, struct device *self, void *aux) clock_enable_all(faa->fa_node); - sxie_socware_init(sc); + sxie_socware_init(sc, faa->fa_node); sc->txf_inuse = 0; sc->sc_ih = arm_intr_establish_fdt(faa->fa_node, IPL_NET, @@ -276,8 +276,9 @@ sxie_attach(struct device *parent, struct device *self, void *aux) } void -sxie_socware_init(struct sxie_softc *sc) +sxie_socware_init(struct sxie_softc *sc, int node) { + uint8_t *enaddr = &sc->sc_ac.ac_enaddr[0]; int have_mac = 0; uint32_t reg; @@ -287,12 +288,17 @@ sxie_socware_init(struct sxie_softc *sc) SXIWRITE4(sc, SXIE_INTCR, SXIE_INTR_DISABLE); SXISET4(sc, SXIE_INTSR, SXIE_INTR_CLEAR); + if (OF_getproplen(node, "local-mac-address") == ETHER_ADDR_LEN) { + OF_getprop(node, "local-mac-address", enaddr, ETHER_ADDR_LEN); + have_mac = 1; + } + /* * If u-boot doesn't set emac, use the Security ID area * to generate a consistent MAC address of. */ reg = SXIREAD4(sc, SXIE_MACA0); - if (reg != 0) { + if (!have_mac && reg != 0) { sc->sc_ac.ac_enaddr[3] = reg >> 16 & 0xff; sc->sc_ac.ac_enaddr[4] = reg >> 8 & 0xff; sc->sc_ac.ac_enaddr[5] = reg & 0xff; diff --git a/sys/dev/fdt/if_dwge_fdt.c b/sys/dev/fdt/if_dwge_fdt.c index edfe5acb992..bca2cee2f72 100644 --- a/sys/dev/fdt/if_dwge_fdt.c +++ b/sys/dev/fdt/if_dwge_fdt.c @@ -87,6 +87,7 @@ dwge_fdt_attach(struct device *parent, struct device *self, void *aux) struct dwge_fdt_softc *fsc = (struct dwge_fdt_softc *)self; struct dwc_gmac_softc *sc = &fsc->sc_core; struct fdt_attach_args *faa = aux; + uint8_t *enaddr = &sc->sc_ac.ac_enaddr[0]; int phyloc = MII_PHY_ANY; uint32_t phy_supply; uint32_t phy; @@ -145,6 +146,12 @@ dwge_fdt_attach(struct device *parent, struct device *self, void *aux) goto clrpwr; } + /* Setup lladdr here, if we have one, to keep fdt out of dwc_gmac */ + if (OF_getproplen(node, "local-mac-address") == ETHER_ADDR_LEN) { + OF_getprop(node, "local-mac-address", enaddr, ETHER_ADDR_LEN); + dwc_gmac_write_hwaddr(sc, enaddr); + } + dwc_gmac_attach(sc, GMAC_MII_CLK_150_250M_DIV102, phyloc); return; diff --git a/sys/dev/ic/dwc_gmac_var.h b/sys/dev/ic/dwc_gmac_var.h index c2b3ce97e92..517bae968f7 100644 --- a/sys/dev/ic/dwc_gmac_var.h +++ b/sys/dev/ic/dwc_gmac_var.h @@ -94,3 +94,4 @@ struct dwc_gmac_softc { void dwc_gmac_attach(struct dwc_gmac_softc*, uint32_t, int); int dwc_gmac_intr(struct dwc_gmac_softc*); +void dwc_gmac_write_hwaddr(struct dwc_gmac_softc *, uint8_t *);
Re: fuse: vfs create does not map 1:1 to fuse create
On 28/11/17(Tue) 17:40, Otto Moerbeek wrote: > On Tue, Nov 28, 2017 at 10:59:07PM +0800, Helg wrote: > > One small comment from me: > > > /* already open i think all is ok */ > > if (ip->fufh[fufh_type].fh_type != FUFH_INVALID) > > return (0); > > > > + /* > > +* The file has already been created and/or truncated so FUSE dictates > > +* that no creation and truncation flags are passed to open. > > +*/ > > + flags = OFLAGS(ap->a_mode) & ~(O_CREAT|O_EXCL|O_TRUNC); > > + > > error = fusefs_file_open(fmp, ip, fufh_type, flags, isdir, ap->a_p); > > if (error) > > return (error); > > > > - return (error); > > + return (0); > > Just return (error) after the fusefs_file_open() call. ok mpi@ with that.
armv7/imx: freezing fec
Hi, there's more work to be done for fec, but this will allow changing changing address/ifconfig up&down etc. without the freeze/kernel hangup preventing ie. autoinstall i've reported to bugs@. i didn't see these while loops being done in nbsd if_enet, where i think fec originates from. -Artturi diff --git a/sys/arch/armv7/imx/if_fec.c b/sys/arch/armv7/imx/if_fec.c index 899c1904144..5b494a6c92c 100644 --- a/sys/arch/armv7/imx/if_fec.c +++ b/sys/arch/armv7/imx/if_fec.c @@ -181,6 +181,8 @@ #define ENET_TXD_INT (1 << 30) #endif +#defineENET_MII_TIMEOUT10 /* --loop_cnt { delay(5); } */ + /* * Bus dma allocation structure used by * fec_dma_malloc and fec_dma_free. @@ -339,7 +341,6 @@ fec_attach(struct device *parent, struct device *self, void *aux) /* reset the controller */ HSET4(sc, ENET_ECR, ENET_ECR_RESET); - while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET); HWRITE4(sc, ENET_EIMR, 0); HWRITE4(sc, ENET_EIR, 0x); @@ -604,7 +605,6 @@ fec_init(struct fec_softc *sc) /* reset the controller */ HSET4(sc, ENET_ECR, ENET_ECR_RESET); - while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET); /* set hw address */ HWRITE4(sc, ENET_PALR, @@ -616,7 +616,8 @@ fec_init(struct fec_softc *sc) (sc->sc_ac.ac_enaddr[4] << 24) | (sc->sc_ac.ac_enaddr[5] << 16)); - /* clear outstanding interrupts */ + /* mask and clear all interrupts */ + HWRITE4(sc, ENET_EIMR, 0); HWRITE4(sc, ENET_EIR, 0x); /* set max receive buffer size, 3-0 bits always zero for alignment */ @@ -692,6 +693,8 @@ fec_stop(struct fec_softc *sc) { struct ifnet *ifp = &sc->sc_ac.ac_if; + HCLR4(sc, ENET_ECR, ENET_ECR_ETHEREN); + /* * Mark the interface down and cancel the watchdog timer. */ @@ -701,9 +704,7 @@ fec_stop(struct fec_softc *sc) timeout_del(&sc->sc_tick); - /* reset the controller */ - HSET4(sc, ENET_ECR, ENET_ECR_RESET); - while(HREAD4(sc, ENET_ECR) & ENET_ECR_RESET); + mii_down(&sc->sc_mii); } void @@ -996,6 +997,7 @@ fec_miibus_readreg(struct device *dev, int phy, int reg) { int r = 0; struct fec_softc *sc = (struct fec_softc *)dev; + u_int timo = ENET_MII_TIMEOUT; HSET4(sc, ENET_EIR, ENET_EIR_MII); @@ -1003,10 +1005,16 @@ fec_miibus_readreg(struct device *dev, int phy, int reg) ENET_MMFR_ST | ENET_MMFR_OP_RD | ENET_MMFR_TA | phy << ENET_MMFR_PA_SHIFT | reg << ENET_MMFR_RA_SHIFT); - while(!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII)); + while (!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII) && --timo) + delay(5); r = bus_space_read_4(sc->sc_iot, sc->sc_ioh, ENET_MMFR); +#ifdef DIAGNOSTIC + if (!timo) + printf("%s: %s timeout\n", sc->sc_dev.dv_xname, __func__); +#endif + return (r & 0x); } @@ -1014,6 +1022,7 @@ void fec_miibus_writereg(struct device *dev, int phy, int reg, int val) { struct fec_softc *sc = (struct fec_softc *)dev; + u_int timo = ENET_MII_TIMEOUT; HSET4(sc, ENET_EIR, ENET_EIR_MII); @@ -1022,7 +1031,12 @@ fec_miibus_writereg(struct device *dev, int phy, int reg, int val) phy << ENET_MMFR_PA_SHIFT | reg << ENET_MMFR_RA_SHIFT | (val & 0x)); - while(!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII)); + while (!(HREAD4(sc, ENET_EIR) & ENET_EIR_MII) && --timo) + delay(5); +#ifdef DIAGNOSTIC + if (!timo) + printf("%s: %s timeout\n", sc->sc_dev.dv_xname, __func__); +#endif return; }
Re: relayd/ctl alternative control socket
On 28/11/17 17:06, Sebastian benoit wrote: > Hi, > > your diff looks good, but i would rather do it the way bgpd/bgpctl do it: > > there the default is /var/run/bgpd.sock. where is the > routing domain bgpctl is running in. To administer bgpd(8) in a different > routing domain, run bgpctl in said routing domain. > > i.e. it detects the rdomain at startup, bgpctl does the same. > > Can you do that in relayd? It was commited there in sometime in summer. > > /Benno I followed snmpd way. My first diff was with -s command line option (ospfd, ldpd, iscsid, slaccd, ripd way). Then I changed it to relayd.conf socket option cause I saw a comment from Reyk on an older thread that this is the way to go. https://marc.info/?l=openbsd-tech&m=148840138521470&w=2 I don't think locking on rdomain is good in relayd since someone might want to run multiple daemons on same rdomain. With bgpd this is not a requirement. Anyway if the patch is ok I believe it should go in because this feature is really needed by many people. Then later on if a universal way is decided on handling control sockets it should be changed on all daemons not following that decision. G
Re: armv7/sxie: enable phy-supply
On Wed, Nov 29, 2017 at 12:37:23AM +1100, Jonathan Gray wrote: > On Sun, Nov 26, 2017 at 06:52:42PM +0200, Artturi Alm wrote: > > Hi, > > > > unless i failed w/grep, only 4 boards with dts in u-boot/linux need this, > > but i've got one of those, so this would be much appreciated:) > > > > -Artturi > > This seems reasonable and there is no non-panic error path > there currently to add a regulator_disable() call to. > > Changing the variable name to phy_supply would match the existing > code in sys/dev/fdt. > Like this? -Artturi diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c index 116fda5f8d7..41c378a7ef7 100644 --- a/sys/arch/armv7/sunxi/sxie.c +++ b/sys/arch/armv7/sunxi/sxie.c @@ -51,6 +51,7 @@ #include #include #include +#include #include /* configuration registers */ @@ -212,6 +213,7 @@ sxie_attach(struct device *parent, struct device *self, void *aux) struct fdt_attach_args *faa = aux; struct mii_data *mii; struct ifnet *ifp; + int phy_supply; int s; if (faa->fa_nreg < 1) @@ -230,6 +232,11 @@ sxie_attach(struct device *parent, struct device *self, void *aux) clock_enable_all(faa->fa_node); + /* Power up PHY. */ + phy_supply = OF_getpropint(faa->fa_node, "phy-supply", 0); + if (phy_supply) + regulator_enable(phy_supply); + sxie_socware_init(sc); sc->txf_inuse = 0;
Re: relayd/ctl alternative control socket
bgpd uses that way *because* it can use an alternate socket. Being able to specify a different socket for daemon/client is pretty helpful. On 2017 Nov 28 (Tue) at 16:06:51 +0100 (+0100), Sebastian benoit wrote: :Hi, : :your diff looks good, but i would rather do it the way bgpd/bgpctl do it: : :there the default is /var/run/bgpd.sock. where is the :routing domain bgpctl is running in. To administer bgpd(8) in a different :routing domain, run bgpctl in said routing domain. : :i.e. it detects the rdomain at startup, bgpctl does the same. : :Can you do that in relayd? It was commited there in sometime in summer. : :/Benno : : :On 11/28/17 11:54, Kapetanakis Giannis wrote: :> Hi, :> :> On June I've posted a patch about using alternative control socket for relayd and relayctl. :> There was a comment from David Gwynne which was evaluated. :> :> Is it OK to get this is in order to be able to control multiple relayd daemons on different rdomains? :> :> thanks :> :> Giannis :> -- "All my friends and I are crazy. That's the only thing that keeps us sane."