diff options
158 files changed, 3576 insertions, 3235 deletions
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index b7f233242315..6026c2e0d5cc 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c | |||
@@ -757,6 +757,42 @@ void __init at91_add_device_ac97(struct atmel_ac97_data *data) | |||
757 | void __init at91_add_device_ac97(struct atmel_ac97_data *data) {} | 757 | void __init at91_add_device_ac97(struct atmel_ac97_data *data) {} |
758 | #endif | 758 | #endif |
759 | 759 | ||
760 | /* -------------------------------------------------------------------- | ||
761 | * CAN Controller | ||
762 | * -------------------------------------------------------------------- */ | ||
763 | |||
764 | #if defined(CONFIG_CAN_AT91) || defined(CONFIG_CAN_AT91_MODULE) | ||
765 | static struct resource can_resources[] = { | ||
766 | [0] = { | ||
767 | .start = AT91SAM9263_BASE_CAN, | ||
768 | .end = AT91SAM9263_BASE_CAN + SZ_16K - 1, | ||
769 | .flags = IORESOURCE_MEM, | ||
770 | }, | ||
771 | [1] = { | ||
772 | .start = AT91SAM9263_ID_CAN, | ||
773 | .end = AT91SAM9263_ID_CAN, | ||
774 | .flags = IORESOURCE_IRQ, | ||
775 | }, | ||
776 | }; | ||
777 | |||
778 | static struct platform_device at91sam9263_can_device = { | ||
779 | .name = "at91_can", | ||
780 | .id = -1, | ||
781 | .resource = can_resources, | ||
782 | .num_resources = ARRAY_SIZE(can_resources), | ||
783 | }; | ||
784 | |||
785 | void __init at91_add_device_can(struct at91_can_data *data) | ||
786 | { | ||
787 | at91_set_A_periph(AT91_PIN_PA13, 0); /* CANTX */ | ||
788 | at91_set_A_periph(AT91_PIN_PA14, 0); /* CANRX */ | ||
789 | at91sam9263_can_device.dev.platform_data = data; | ||
790 | |||
791 | platform_device_register(&at91sam9263_can_device); | ||
792 | } | ||
793 | #else | ||
794 | void __init at91_add_device_can(struct at91_can_data *data) {} | ||
795 | #endif | ||
760 | 796 | ||
761 | /* -------------------------------------------------------------------- | 797 | /* -------------------------------------------------------------------- |
762 | * LCD Controller | 798 | * LCD Controller |
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c index 57d52528f224..e6268b3cbe8d 100644 --- a/arch/arm/mach-at91/board-sam9263ek.c +++ b/arch/arm/mach-at91/board-sam9263ek.c | |||
@@ -400,6 +400,23 @@ static struct gpio_led ek_pwm_led[] = { | |||
400 | } | 400 | } |
401 | }; | 401 | }; |
402 | 402 | ||
403 | /* | ||
404 | * CAN | ||
405 | */ | ||
406 | static void sam9263ek_transceiver_switch(int on) | ||
407 | { | ||
408 | if (on) { | ||
409 | at91_set_gpio_output(AT91_PIN_PA18, 1); /* CANRXEN */ | ||
410 | at91_set_gpio_output(AT91_PIN_PA19, 0); /* CANRS */ | ||
411 | } else { | ||
412 | at91_set_gpio_output(AT91_PIN_PA18, 0); /* CANRXEN */ | ||
413 | at91_set_gpio_output(AT91_PIN_PA19, 1); /* CANRS */ | ||
414 | } | ||
415 | } | ||
416 | |||
417 | static struct at91_can_data ek_can_data = { | ||
418 | .transceiver_switch = sam9263ek_transceiver_switch, | ||
419 | }; | ||
403 | 420 | ||
404 | static void __init ek_board_init(void) | 421 | static void __init ek_board_init(void) |
405 | { | 422 | { |
@@ -431,6 +448,8 @@ static void __init ek_board_init(void) | |||
431 | /* LEDs */ | 448 | /* LEDs */ |
432 | at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); | 449 | at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); |
433 | at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led)); | 450 | at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led)); |
451 | /* CAN */ | ||
452 | at91_add_device_can(&ek_can_data); | ||
434 | } | 453 | } |
435 | 454 | ||
436 | MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK") | 455 | MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK") |
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h index e6afff849b85..134731cd9fdf 100644 --- a/arch/arm/mach-at91/include/mach/board.h +++ b/arch/arm/mach-at91/include/mach/board.h | |||
@@ -179,6 +179,12 @@ extern void __init at91_add_device_isi(void); | |||
179 | /* Touchscreen Controller */ | 179 | /* Touchscreen Controller */ |
180 | extern void __init at91_add_device_tsadcc(void); | 180 | extern void __init at91_add_device_tsadcc(void); |
181 | 181 | ||
182 | /* CAN */ | ||
183 | struct at91_can_data { | ||
184 | void (*transceiver_switch)(int on); | ||
185 | }; | ||
186 | extern void __init at91_add_device_can(struct at91_can_data *data); | ||
187 | |||
182 | /* LEDs */ | 188 | /* LEDs */ |
183 | extern void __init at91_init_leds(u8 cpu_led, u8 timer_led); | 189 | extern void __init at91_init_leds(u8 cpu_led, u8 timer_led); |
184 | extern void __init at91_gpio_leds(struct gpio_led *leds, int nr); | 190 | extern void __init at91_gpio_leds(struct gpio_led *leds, int nr); |
diff --git a/drivers/atm/he.c b/drivers/atm/he.c index 2de64065aa1b..29e66d603d3c 100644 --- a/drivers/atm/he.c +++ b/drivers/atm/he.c | |||
@@ -790,11 +790,15 @@ he_init_group(struct he_dev *he_dev, int group) | |||
790 | he_dev->rbps_base = pci_alloc_consistent(he_dev->pci_dev, | 790 | he_dev->rbps_base = pci_alloc_consistent(he_dev->pci_dev, |
791 | CONFIG_RBPS_SIZE * sizeof(struct he_rbp), &he_dev->rbps_phys); | 791 | CONFIG_RBPS_SIZE * sizeof(struct he_rbp), &he_dev->rbps_phys); |
792 | if (he_dev->rbps_base == NULL) { | 792 | if (he_dev->rbps_base == NULL) { |
793 | hprintk("failed to alloc rbps\n"); | 793 | hprintk("failed to alloc rbps_base\n"); |
794 | return -ENOMEM; | 794 | goto out_destroy_rbps_pool; |
795 | } | 795 | } |
796 | memset(he_dev->rbps_base, 0, CONFIG_RBPS_SIZE * sizeof(struct he_rbp)); | 796 | memset(he_dev->rbps_base, 0, CONFIG_RBPS_SIZE * sizeof(struct he_rbp)); |
797 | he_dev->rbps_virt = kmalloc(CONFIG_RBPS_SIZE * sizeof(struct he_virt), GFP_KERNEL); | 797 | he_dev->rbps_virt = kmalloc(CONFIG_RBPS_SIZE * sizeof(struct he_virt), GFP_KERNEL); |
798 | if (he_dev->rbps_virt == NULL) { | ||
799 | hprintk("failed to alloc rbps_virt\n"); | ||
800 | goto out_free_rbps_base; | ||
801 | } | ||
798 | 802 | ||
799 | for (i = 0; i < CONFIG_RBPS_SIZE; ++i) { | 803 | for (i = 0; i < CONFIG_RBPS_SIZE; ++i) { |
800 | dma_addr_t dma_handle; | 804 | dma_addr_t dma_handle; |
@@ -802,7 +806,7 @@ he_init_group(struct he_dev *he_dev, int group) | |||
802 | 806 | ||
803 | cpuaddr = pci_pool_alloc(he_dev->rbps_pool, GFP_KERNEL|GFP_DMA, &dma_handle); | 807 | cpuaddr = pci_pool_alloc(he_dev->rbps_pool, GFP_KERNEL|GFP_DMA, &dma_handle); |
804 | if (cpuaddr == NULL) | 808 | if (cpuaddr == NULL) |
805 | return -ENOMEM; | 809 | goto out_free_rbps_virt; |
806 | 810 | ||
807 | he_dev->rbps_virt[i].virt = cpuaddr; | 811 | he_dev->rbps_virt[i].virt = cpuaddr; |
808 | he_dev->rbps_base[i].status = RBP_LOANED | RBP_SMALLBUF | (i << RBP_INDEX_OFF); | 812 | he_dev->rbps_base[i].status = RBP_LOANED | RBP_SMALLBUF | (i << RBP_INDEX_OFF); |
@@ -827,17 +831,21 @@ he_init_group(struct he_dev *he_dev, int group) | |||
827 | CONFIG_RBPL_BUFSIZE, 8, 0); | 831 | CONFIG_RBPL_BUFSIZE, 8, 0); |
828 | if (he_dev->rbpl_pool == NULL) { | 832 | if (he_dev->rbpl_pool == NULL) { |
829 | hprintk("unable to create rbpl pool\n"); | 833 | hprintk("unable to create rbpl pool\n"); |
830 | return -ENOMEM; | 834 | goto out_free_rbps_virt; |
831 | } | 835 | } |
832 | 836 | ||
833 | he_dev->rbpl_base = pci_alloc_consistent(he_dev->pci_dev, | 837 | he_dev->rbpl_base = pci_alloc_consistent(he_dev->pci_dev, |
834 | CONFIG_RBPL_SIZE * sizeof(struct he_rbp), &he_dev->rbpl_phys); | 838 | CONFIG_RBPL_SIZE * sizeof(struct he_rbp), &he_dev->rbpl_phys); |
835 | if (he_dev->rbpl_base == NULL) { | 839 | if (he_dev->rbpl_base == NULL) { |
836 | hprintk("failed to alloc rbpl\n"); | 840 | hprintk("failed to alloc rbpl_base\n"); |
837 | return -ENOMEM; | 841 | goto out_destroy_rbpl_pool; |
838 | } | 842 | } |
839 | memset(he_dev->rbpl_base, 0, CONFIG_RBPL_SIZE * sizeof(struct he_rbp)); | 843 | memset(he_dev->rbpl_base, 0, CONFIG_RBPL_SIZE * sizeof(struct he_rbp)); |
840 | he_dev->rbpl_virt = kmalloc(CONFIG_RBPL_SIZE * sizeof(struct he_virt), GFP_KERNEL); | 844 | he_dev->rbpl_virt = kmalloc(CONFIG_RBPL_SIZE * sizeof(struct he_virt), GFP_KERNEL); |
845 | if (he_dev->rbpl_virt == NULL) { | ||
846 | hprintk("failed to alloc rbpl_virt\n"); | ||
847 | goto out_free_rbpl_base; | ||
848 | } | ||
841 | 849 | ||
842 | for (i = 0; i < CONFIG_RBPL_SIZE; ++i) { | 850 | for (i = 0; i < CONFIG_RBPL_SIZE; ++i) { |
843 | dma_addr_t dma_handle; | 851 | dma_addr_t dma_handle; |
@@ -845,7 +853,7 @@ he_init_group(struct he_dev *he_dev, int group) | |||
845 | 853 | ||
846 | cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, GFP_KERNEL|GFP_DMA, &dma_handle); | 854 | cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, GFP_KERNEL|GFP_DMA, &dma_handle); |
847 | if (cpuaddr == NULL) | 855 | if (cpuaddr == NULL) |
848 | return -ENOMEM; | 856 | goto out_free_rbpl_virt; |
849 | 857 | ||
850 | he_dev->rbpl_virt[i].virt = cpuaddr; | 858 | he_dev->rbpl_virt[i].virt = cpuaddr; |
851 | he_dev->rbpl_base[i].status = RBP_LOANED | (i << RBP_INDEX_OFF); | 859 | he_dev->rbpl_base[i].status = RBP_LOANED | (i << RBP_INDEX_OFF); |
@@ -870,7 +878,7 @@ he_init_group(struct he_dev *he_dev, int group) | |||
870 | CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq), &he_dev->rbrq_phys); | 878 | CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq), &he_dev->rbrq_phys); |
871 | if (he_dev->rbrq_base == NULL) { | 879 | if (he_dev->rbrq_base == NULL) { |
872 | hprintk("failed to allocate rbrq\n"); | 880 | hprintk("failed to allocate rbrq\n"); |
873 | return -ENOMEM; | 881 | goto out_free_rbpl_virt; |
874 | } | 882 | } |
875 | memset(he_dev->rbrq_base, 0, CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq)); | 883 | memset(he_dev->rbrq_base, 0, CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq)); |
876 | 884 | ||
@@ -894,7 +902,7 @@ he_init_group(struct he_dev *he_dev, int group) | |||
894 | CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq), &he_dev->tbrq_phys); | 902 | CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq), &he_dev->tbrq_phys); |
895 | if (he_dev->tbrq_base == NULL) { | 903 | if (he_dev->tbrq_base == NULL) { |
896 | hprintk("failed to allocate tbrq\n"); | 904 | hprintk("failed to allocate tbrq\n"); |
897 | return -ENOMEM; | 905 | goto out_free_rbpq_base; |
898 | } | 906 | } |
899 | memset(he_dev->tbrq_base, 0, CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq)); | 907 | memset(he_dev->tbrq_base, 0, CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq)); |
900 | 908 | ||
@@ -906,6 +914,39 @@ he_init_group(struct he_dev *he_dev, int group) | |||
906 | he_writel(he_dev, CONFIG_TBRQ_THRESH, G0_TBRQ_THRESH + (group * 16)); | 914 | he_writel(he_dev, CONFIG_TBRQ_THRESH, G0_TBRQ_THRESH + (group * 16)); |
907 | 915 | ||
908 | return 0; | 916 | return 0; |
917 | |||
918 | out_free_rbpq_base: | ||
919 | pci_free_consistent(he_dev->pci_dev, CONFIG_RBRQ_SIZE * | ||
920 | sizeof(struct he_rbrq), he_dev->rbrq_base, | ||
921 | he_dev->rbrq_phys); | ||
922 | i = CONFIG_RBPL_SIZE; | ||
923 | out_free_rbpl_virt: | ||
924 | while (--i) | ||
925 | pci_pool_free(he_dev->rbps_pool, he_dev->rbpl_virt[i].virt, | ||
926 | he_dev->rbps_base[i].phys); | ||
927 | kfree(he_dev->rbpl_virt); | ||
928 | |||
929 | out_free_rbpl_base: | ||
930 | pci_free_consistent(he_dev->pci_dev, CONFIG_RBPL_SIZE * | ||
931 | sizeof(struct he_rbp), he_dev->rbpl_base, | ||
932 | he_dev->rbpl_phys); | ||
933 | out_destroy_rbpl_pool: | ||
934 | pci_pool_destroy(he_dev->rbpl_pool); | ||
935 | |||
936 | i = CONFIG_RBPL_SIZE; | ||
937 | out_free_rbps_virt: | ||
938 | while (--i) | ||
939 | pci_pool_free(he_dev->rbpl_pool, he_dev->rbps_virt[i].virt, | ||
940 | he_dev->rbpl_base[i].phys); | ||
941 | kfree(he_dev->rbps_virt); | ||
942 | |||
943 | out_free_rbps_base: | ||
944 | pci_free_consistent(he_dev->pci_dev, CONFIG_RBPS_SIZE * | ||
945 | sizeof(struct he_rbp), he_dev->rbps_base, | ||
946 | he_dev->rbps_phys); | ||
947 | out_destroy_rbps_pool: | ||
948 | pci_pool_destroy(he_dev->rbps_pool); | ||
949 | return -ENOMEM; | ||
909 | } | 950 | } |
910 | 951 | ||
911 | static int __devinit | 952 | static int __devinit |
diff --git a/drivers/atm/solos-attrlist.c b/drivers/atm/solos-attrlist.c index efa2808dd94d..1a9332e4efe0 100644 --- a/drivers/atm/solos-attrlist.c +++ b/drivers/atm/solos-attrlist.c | |||
@@ -25,6 +25,10 @@ SOLOS_ATTR_RO(RSCorrectedErrorsUp) | |||
25 | SOLOS_ATTR_RO(RSUnCorrectedErrorsUp) | 25 | SOLOS_ATTR_RO(RSUnCorrectedErrorsUp) |
26 | SOLOS_ATTR_RO(InterleaveRDn) | 26 | SOLOS_ATTR_RO(InterleaveRDn) |
27 | SOLOS_ATTR_RO(InterleaveRUp) | 27 | SOLOS_ATTR_RO(InterleaveRUp) |
28 | SOLOS_ATTR_RO(BisRDn) | ||
29 | SOLOS_ATTR_RO(BisRUp) | ||
30 | SOLOS_ATTR_RO(INPdown) | ||
31 | SOLOS_ATTR_RO(INPup) | ||
28 | SOLOS_ATTR_RO(ShowtimeStart) | 32 | SOLOS_ATTR_RO(ShowtimeStart) |
29 | SOLOS_ATTR_RO(ATURVendor) | 33 | SOLOS_ATTR_RO(ATURVendor) |
30 | SOLOS_ATTR_RO(ATUCCountry) | 34 | SOLOS_ATTR_RO(ATUCCountry) |
@@ -62,6 +66,13 @@ SOLOS_ATTR_RW(Defaults) | |||
62 | SOLOS_ATTR_RW(LineMode) | 66 | SOLOS_ATTR_RW(LineMode) |
63 | SOLOS_ATTR_RW(Profile) | 67 | SOLOS_ATTR_RW(Profile) |
64 | SOLOS_ATTR_RW(DetectNoise) | 68 | SOLOS_ATTR_RW(DetectNoise) |
69 | SOLOS_ATTR_RW(BisAForceSNRMarginDn) | ||
70 | SOLOS_ATTR_RW(BisMForceSNRMarginDn) | ||
71 | SOLOS_ATTR_RW(BisAMaxMargin) | ||
72 | SOLOS_ATTR_RW(BisMMaxMargin) | ||
73 | SOLOS_ATTR_RW(AnnexAForceSNRMarginDn) | ||
74 | SOLOS_ATTR_RW(AnnexAMaxMargin) | ||
75 | SOLOS_ATTR_RW(AnnexMMaxMargin) | ||
65 | SOLOS_ATTR_RO(SupportedAnnexes) | 76 | SOLOS_ATTR_RO(SupportedAnnexes) |
66 | SOLOS_ATTR_RO(Status) | 77 | SOLOS_ATTR_RO(Status) |
67 | SOLOS_ATTR_RO(TotalStart) | 78 | SOLOS_ATTR_RO(TotalStart) |
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c index 307321b32cb3..c5f5186d62a3 100644 --- a/drivers/atm/solos-pci.c +++ b/drivers/atm/solos-pci.c | |||
@@ -59,21 +59,29 @@ | |||
59 | #define RX_DMA_ADDR(port) (0x30 + (4 * (port))) | 59 | #define RX_DMA_ADDR(port) (0x30 + (4 * (port))) |
60 | 60 | ||
61 | #define DATA_RAM_SIZE 32768 | 61 | #define DATA_RAM_SIZE 32768 |
62 | #define BUF_SIZE 4096 | 62 | #define BUF_SIZE 2048 |
63 | #define OLD_BUF_SIZE 4096 /* For FPGA versions <= 2*/ | ||
63 | #define FPGA_PAGE 528 /* FPGA flash page size*/ | 64 | #define FPGA_PAGE 528 /* FPGA flash page size*/ |
64 | #define SOLOS_PAGE 512 /* Solos flash page size*/ | 65 | #define SOLOS_PAGE 512 /* Solos flash page size*/ |
65 | #define FPGA_BLOCK (FPGA_PAGE * 8) /* FPGA flash block size*/ | 66 | #define FPGA_BLOCK (FPGA_PAGE * 8) /* FPGA flash block size*/ |
66 | #define SOLOS_BLOCK (SOLOS_PAGE * 8) /* Solos flash block size*/ | 67 | #define SOLOS_BLOCK (SOLOS_PAGE * 8) /* Solos flash block size*/ |
67 | 68 | ||
68 | #define RX_BUF(card, nr) ((card->buffers) + (nr)*BUF_SIZE*2) | 69 | #define RX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2) |
69 | #define TX_BUF(card, nr) ((card->buffers) + (nr)*BUF_SIZE*2 + BUF_SIZE) | 70 | #define TX_BUF(card, nr) ((card->buffers) + (nr)*(card->buffer_size)*2 + (card->buffer_size)) |
71 | #define FLASH_BUF ((card->buffers) + 4*(card->buffer_size)*2) | ||
70 | 72 | ||
71 | #define RX_DMA_SIZE 2048 | 73 | #define RX_DMA_SIZE 2048 |
72 | 74 | ||
75 | #define FPGA_VERSION(a,b) (((a) << 8) + (b)) | ||
76 | #define LEGACY_BUFFERS 2 | ||
77 | #define DMA_SUPPORTED 4 | ||
78 | |||
73 | static int reset = 0; | 79 | static int reset = 0; |
74 | static int atmdebug = 0; | 80 | static int atmdebug = 0; |
75 | static int firmware_upgrade = 0; | 81 | static int firmware_upgrade = 0; |
76 | static int fpga_upgrade = 0; | 82 | static int fpga_upgrade = 0; |
83 | static int db_firmware_upgrade = 0; | ||
84 | static int db_fpga_upgrade = 0; | ||
77 | 85 | ||
78 | struct pkt_hdr { | 86 | struct pkt_hdr { |
79 | __le16 size; | 87 | __le16 size; |
@@ -116,6 +124,8 @@ struct solos_card { | |||
116 | wait_queue_head_t param_wq; | 124 | wait_queue_head_t param_wq; |
117 | wait_queue_head_t fw_wq; | 125 | wait_queue_head_t fw_wq; |
118 | int using_dma; | 126 | int using_dma; |
127 | int fpga_version; | ||
128 | int buffer_size; | ||
119 | }; | 129 | }; |
120 | 130 | ||
121 | 131 | ||
@@ -136,10 +146,14 @@ MODULE_PARM_DESC(reset, "Reset Solos chips on startup"); | |||
136 | MODULE_PARM_DESC(atmdebug, "Print ATM data"); | 146 | MODULE_PARM_DESC(atmdebug, "Print ATM data"); |
137 | MODULE_PARM_DESC(firmware_upgrade, "Initiate Solos firmware upgrade"); | 147 | MODULE_PARM_DESC(firmware_upgrade, "Initiate Solos firmware upgrade"); |
138 | MODULE_PARM_DESC(fpga_upgrade, "Initiate FPGA upgrade"); | 148 | MODULE_PARM_DESC(fpga_upgrade, "Initiate FPGA upgrade"); |
149 | MODULE_PARM_DESC(db_firmware_upgrade, "Initiate daughter board Solos firmware upgrade"); | ||
150 | MODULE_PARM_DESC(db_fpga_upgrade, "Initiate daughter board FPGA upgrade"); | ||
139 | module_param(reset, int, 0444); | 151 | module_param(reset, int, 0444); |
140 | module_param(atmdebug, int, 0644); | 152 | module_param(atmdebug, int, 0644); |
141 | module_param(firmware_upgrade, int, 0444); | 153 | module_param(firmware_upgrade, int, 0444); |
142 | module_param(fpga_upgrade, int, 0444); | 154 | module_param(fpga_upgrade, int, 0444); |
155 | module_param(db_firmware_upgrade, int, 0444); | ||
156 | module_param(db_fpga_upgrade, int, 0444); | ||
143 | 157 | ||
144 | static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb, | 158 | static void fpga_queue(struct solos_card *card, int port, struct sk_buff *skb, |
145 | struct atm_vcc *vcc); | 159 | struct atm_vcc *vcc); |
@@ -517,10 +531,32 @@ static int flash_upgrade(struct solos_card *card, int chip) | |||
517 | if (chip == 0) { | 531 | if (chip == 0) { |
518 | fw_name = "solos-FPGA.bin"; | 532 | fw_name = "solos-FPGA.bin"; |
519 | blocksize = FPGA_BLOCK; | 533 | blocksize = FPGA_BLOCK; |
520 | } else { | 534 | } |
535 | |||
536 | if (chip == 1) { | ||
521 | fw_name = "solos-Firmware.bin"; | 537 | fw_name = "solos-Firmware.bin"; |
522 | blocksize = SOLOS_BLOCK; | 538 | blocksize = SOLOS_BLOCK; |
523 | } | 539 | } |
540 | |||
541 | if (chip == 2){ | ||
542 | if (card->fpga_version > LEGACY_BUFFERS){ | ||
543 | fw_name = "solos-db-FPGA.bin"; | ||
544 | blocksize = FPGA_BLOCK; | ||
545 | } else { | ||
546 | dev_info(&card->dev->dev, "FPGA version doesn't support daughter board upgrades\n"); | ||
547 | return -EPERM; | ||
548 | } | ||
549 | } | ||
550 | |||
551 | if (chip == 3){ | ||
552 | if (card->fpga_version > LEGACY_BUFFERS){ | ||
553 | fw_name = "solos-Firmware.bin"; | ||
554 | blocksize = SOLOS_BLOCK; | ||
555 | } else { | ||
556 | dev_info(&card->dev->dev, "FPGA version doesn't support daughter board upgrades\n"); | ||
557 | return -EPERM; | ||
558 | } | ||
559 | } | ||
524 | 560 | ||
525 | if (request_firmware(&fw, fw_name, &card->dev->dev)) | 561 | if (request_firmware(&fw, fw_name, &card->dev->dev)) |
526 | return -ENOENT; | 562 | return -ENOENT; |
@@ -536,8 +572,10 @@ static int flash_upgrade(struct solos_card *card, int chip) | |||
536 | data32 = ioread32(card->config_regs + FPGA_MODE); | 572 | data32 = ioread32(card->config_regs + FPGA_MODE); |
537 | 573 | ||
538 | /* Set mode to Chip Erase */ | 574 | /* Set mode to Chip Erase */ |
539 | dev_info(&card->dev->dev, "Set FPGA Flash mode to %s Chip Erase\n", | 575 | if(chip == 0 || chip == 2) |
540 | chip?"Solos":"FPGA"); | 576 | dev_info(&card->dev->dev, "Set FPGA Flash mode to FPGA Chip Erase\n"); |
577 | if(chip == 1 || chip == 3) | ||
578 | dev_info(&card->dev->dev, "Set FPGA Flash mode to Solos Chip Erase\n"); | ||
541 | iowrite32((chip * 2), card->config_regs + FLASH_MODE); | 579 | iowrite32((chip * 2), card->config_regs + FLASH_MODE); |
542 | 580 | ||
543 | 581 | ||
@@ -557,7 +595,10 @@ static int flash_upgrade(struct solos_card *card, int chip) | |||
557 | /* Copy block to buffer, swapping each 16 bits */ | 595 | /* Copy block to buffer, swapping each 16 bits */ |
558 | for(i = 0; i < blocksize; i += 4) { | 596 | for(i = 0; i < blocksize; i += 4) { |
559 | uint32_t word = swahb32p((uint32_t *)(fw->data + offset + i)); | 597 | uint32_t word = swahb32p((uint32_t *)(fw->data + offset + i)); |
560 | iowrite32(word, RX_BUF(card, 3) + i); | 598 | if(card->fpga_version > LEGACY_BUFFERS) |
599 | iowrite32(word, FLASH_BUF + i); | ||
600 | else | ||
601 | iowrite32(word, RX_BUF(card, 3) + i); | ||
561 | } | 602 | } |
562 | 603 | ||
563 | /* Specify block number and then trigger flash write */ | 604 | /* Specify block number and then trigger flash write */ |
@@ -630,6 +671,10 @@ void solos_bh(unsigned long card_arg) | |||
630 | memcpy_fromio(header, RX_BUF(card, port), sizeof(*header)); | 671 | memcpy_fromio(header, RX_BUF(card, port), sizeof(*header)); |
631 | 672 | ||
632 | size = le16_to_cpu(header->size); | 673 | size = le16_to_cpu(header->size); |
674 | if (size > (card->buffer_size - sizeof(*header))){ | ||
675 | dev_warn(&card->dev->dev, "Invalid buffer size\n"); | ||
676 | continue; | ||
677 | } | ||
633 | 678 | ||
634 | skb = alloc_skb(size + 1, GFP_ATOMIC); | 679 | skb = alloc_skb(size + 1, GFP_ATOMIC); |
635 | if (!skb) { | 680 | if (!skb) { |
@@ -1094,12 +1139,18 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1094 | fpga_ver = (data32 & 0x0000FFFF); | 1139 | fpga_ver = (data32 & 0x0000FFFF); |
1095 | major_ver = ((data32 & 0xFF000000) >> 24); | 1140 | major_ver = ((data32 & 0xFF000000) >> 24); |
1096 | minor_ver = ((data32 & 0x00FF0000) >> 16); | 1141 | minor_ver = ((data32 & 0x00FF0000) >> 16); |
1142 | card->fpga_version = FPGA_VERSION(major_ver,minor_ver); | ||
1143 | if (card->fpga_version > LEGACY_BUFFERS) | ||
1144 | card->buffer_size = BUF_SIZE; | ||
1145 | else | ||
1146 | card->buffer_size = OLD_BUF_SIZE; | ||
1097 | dev_info(&dev->dev, "Solos FPGA Version %d.%02d svn-%d\n", | 1147 | dev_info(&dev->dev, "Solos FPGA Version %d.%02d svn-%d\n", |
1098 | major_ver, minor_ver, fpga_ver); | 1148 | major_ver, minor_ver, fpga_ver); |
1099 | 1149 | ||
1100 | if (0 && fpga_ver > 27) | 1150 | if (card->fpga_version >= DMA_SUPPORTED){ |
1101 | card->using_dma = 1; | 1151 | card->using_dma = 1; |
1102 | else { | 1152 | } else { |
1153 | card->using_dma = 0; | ||
1103 | /* Set RX empty flag for all ports */ | 1154 | /* Set RX empty flag for all ports */ |
1104 | iowrite32(0xF0, card->config_regs + FLAGS_ADDR); | 1155 | iowrite32(0xF0, card->config_regs + FLAGS_ADDR); |
1105 | } | 1156 | } |
@@ -1131,6 +1182,12 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
1131 | if (firmware_upgrade) | 1182 | if (firmware_upgrade) |
1132 | flash_upgrade(card, 1); | 1183 | flash_upgrade(card, 1); |
1133 | 1184 | ||
1185 | if (db_fpga_upgrade) | ||
1186 | flash_upgrade(card, 2); | ||
1187 | |||
1188 | if (db_firmware_upgrade) | ||
1189 | flash_upgrade(card, 3); | ||
1190 | |||
1134 | err = atm_init(card); | 1191 | err = atm_init(card); |
1135 | if (err) | 1192 | if (err) |
1136 | goto out_free_irq; | 1193 | goto out_free_irq; |
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 462d9f59c53a..83a1922e68e0 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c | |||
@@ -87,7 +87,7 @@ | |||
87 | 87 | ||
88 | /* These identify the driver base version and may not be removed. */ | 88 | /* These identify the driver base version and may not be removed. */ |
89 | static char version[] = | 89 | static char version[] = |
90 | KERN_INFO DRV_NAME ": 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n"; | 90 | DRV_NAME ": 10/100 PCI Ethernet driver v" DRV_VERSION " (" DRV_RELDATE ")\n"; |
91 | 91 | ||
92 | MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>"); | 92 | MODULE_AUTHOR("Jeff Garzik <jgarzik@pobox.com>"); |
93 | MODULE_DESCRIPTION("RealTek RTL-8139C+ series 10/100 PCI Ethernet driver"); | 93 | MODULE_DESCRIPTION("RealTek RTL-8139C+ series 10/100 PCI Ethernet driver"); |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 21333c18f344..f9fbd52b799b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -1875,7 +1875,7 @@ config 68360_ENET | |||
1875 | 1875 | ||
1876 | config FEC | 1876 | config FEC |
1877 | bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)" | 1877 | bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)" |
1878 | depends on M523x || M527x || M5272 || M528x || M520x || M532x || MACH_MX27 || ARCH_MX35 | 1878 | depends on M523x || M527x || M5272 || M528x || M520x || M532x || MACH_MX27 || ARCH_MX35 || ARCH_MX25 |
1879 | help | 1879 | help |
1880 | Say Y here if you want to use the built-in 10/100 Fast ethernet | 1880 | Say Y here if you want to use the built-in 10/100 Fast ethernet |
1881 | controller on some Motorola ColdFire and Freescale i.MX processors. | 1881 | controller on some Motorola ColdFire and Freescale i.MX processors. |
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c index be2c6cfe6e84..1372e9a99f5b 100644 --- a/drivers/net/atl1c/atl1c_main.c +++ b/drivers/net/atl1c/atl1c_main.c | |||
@@ -2296,7 +2296,7 @@ static int atl1c_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2296 | u32 ctrl; | 2296 | u32 ctrl; |
2297 | u32 mac_ctrl_data; | 2297 | u32 mac_ctrl_data; |
2298 | u32 master_ctrl_data; | 2298 | u32 master_ctrl_data; |
2299 | u32 wol_ctrl_data; | 2299 | u32 wol_ctrl_data = 0; |
2300 | u16 mii_bmsr_data; | 2300 | u16 mii_bmsr_data; |
2301 | u16 save_autoneg_advertised; | 2301 | u16 save_autoneg_advertised; |
2302 | u16 mii_intr_status_data; | 2302 | u16 mii_intr_status_data; |
diff --git a/drivers/net/atl1e/atl1e.h b/drivers/net/atl1e/atl1e.h index ba48220df16a..490d3b38e0cb 100644 --- a/drivers/net/atl1e/atl1e.h +++ b/drivers/net/atl1e/atl1e.h | |||
@@ -377,10 +377,19 @@ struct atl1e_hw { | |||
377 | */ | 377 | */ |
378 | struct atl1e_tx_buffer { | 378 | struct atl1e_tx_buffer { |
379 | struct sk_buff *skb; | 379 | struct sk_buff *skb; |
380 | u16 flags; | ||
381 | #define ATL1E_TX_PCIMAP_SINGLE 0x0001 | ||
382 | #define ATL1E_TX_PCIMAP_PAGE 0x0002 | ||
383 | #define ATL1E_TX_PCIMAP_TYPE_MASK 0x0003 | ||
380 | u16 length; | 384 | u16 length; |
381 | dma_addr_t dma; | 385 | dma_addr_t dma; |
382 | }; | 386 | }; |
383 | 387 | ||
388 | #define ATL1E_SET_PCIMAP_TYPE(tx_buff, type) do { \ | ||
389 | ((tx_buff)->flags) &= ~ATL1E_TX_PCIMAP_TYPE_MASK; \ | ||
390 | ((tx_buff)->flags) |= (type); \ | ||
391 | } while (0) | ||
392 | |||
384 | struct atl1e_rx_page { | 393 | struct atl1e_rx_page { |
385 | dma_addr_t dma; /* receive rage DMA address */ | 394 | dma_addr_t dma; /* receive rage DMA address */ |
386 | u8 *addr; /* receive rage virtual address */ | 395 | u8 *addr; /* receive rage virtual address */ |
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c index 69b830f4b68f..955da733c2ad 100644 --- a/drivers/net/atl1e/atl1e_main.c +++ b/drivers/net/atl1e/atl1e_main.c | |||
@@ -635,7 +635,11 @@ static void atl1e_clean_tx_ring(struct atl1e_adapter *adapter) | |||
635 | for (index = 0; index < ring_count; index++) { | 635 | for (index = 0; index < ring_count; index++) { |
636 | tx_buffer = &tx_ring->tx_buffer[index]; | 636 | tx_buffer = &tx_ring->tx_buffer[index]; |
637 | if (tx_buffer->dma) { | 637 | if (tx_buffer->dma) { |
638 | pci_unmap_page(pdev, tx_buffer->dma, | 638 | if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE) |
639 | pci_unmap_single(pdev, tx_buffer->dma, | ||
640 | tx_buffer->length, PCI_DMA_TODEVICE); | ||
641 | else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE) | ||
642 | pci_unmap_page(pdev, tx_buffer->dma, | ||
639 | tx_buffer->length, PCI_DMA_TODEVICE); | 643 | tx_buffer->length, PCI_DMA_TODEVICE); |
640 | tx_buffer->dma = 0; | 644 | tx_buffer->dma = 0; |
641 | } | 645 | } |
@@ -1220,7 +1224,11 @@ static bool atl1e_clean_tx_irq(struct atl1e_adapter *adapter) | |||
1220 | while (next_to_clean != hw_next_to_clean) { | 1224 | while (next_to_clean != hw_next_to_clean) { |
1221 | tx_buffer = &tx_ring->tx_buffer[next_to_clean]; | 1225 | tx_buffer = &tx_ring->tx_buffer[next_to_clean]; |
1222 | if (tx_buffer->dma) { | 1226 | if (tx_buffer->dma) { |
1223 | pci_unmap_page(adapter->pdev, tx_buffer->dma, | 1227 | if (tx_buffer->flags & ATL1E_TX_PCIMAP_SINGLE) |
1228 | pci_unmap_single(adapter->pdev, tx_buffer->dma, | ||
1229 | tx_buffer->length, PCI_DMA_TODEVICE); | ||
1230 | else if (tx_buffer->flags & ATL1E_TX_PCIMAP_PAGE) | ||
1231 | pci_unmap_page(adapter->pdev, tx_buffer->dma, | ||
1224 | tx_buffer->length, PCI_DMA_TODEVICE); | 1232 | tx_buffer->length, PCI_DMA_TODEVICE); |
1225 | tx_buffer->dma = 0; | 1233 | tx_buffer->dma = 0; |
1226 | } | 1234 | } |
@@ -1741,6 +1749,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, | |||
1741 | tx_buffer->length = map_len; | 1749 | tx_buffer->length = map_len; |
1742 | tx_buffer->dma = pci_map_single(adapter->pdev, | 1750 | tx_buffer->dma = pci_map_single(adapter->pdev, |
1743 | skb->data, hdr_len, PCI_DMA_TODEVICE); | 1751 | skb->data, hdr_len, PCI_DMA_TODEVICE); |
1752 | ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE); | ||
1744 | mapped_len += map_len; | 1753 | mapped_len += map_len; |
1745 | use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); | 1754 | use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); |
1746 | use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | | 1755 | use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | |
@@ -1766,6 +1775,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, | |||
1766 | tx_buffer->dma = | 1775 | tx_buffer->dma = |
1767 | pci_map_single(adapter->pdev, skb->data + mapped_len, | 1776 | pci_map_single(adapter->pdev, skb->data + mapped_len, |
1768 | map_len, PCI_DMA_TODEVICE); | 1777 | map_len, PCI_DMA_TODEVICE); |
1778 | ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_SINGLE); | ||
1769 | mapped_len += map_len; | 1779 | mapped_len += map_len; |
1770 | use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); | 1780 | use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); |
1771 | use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | | 1781 | use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | |
@@ -1801,6 +1811,7 @@ static void atl1e_tx_map(struct atl1e_adapter *adapter, | |||
1801 | (i * MAX_TX_BUF_LEN), | 1811 | (i * MAX_TX_BUF_LEN), |
1802 | tx_buffer->length, | 1812 | tx_buffer->length, |
1803 | PCI_DMA_TODEVICE); | 1813 | PCI_DMA_TODEVICE); |
1814 | ATL1E_SET_PCIMAP_TYPE(tx_buffer, ATL1E_TX_PCIMAP_PAGE); | ||
1804 | use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); | 1815 | use_tpd->buffer_addr = cpu_to_le64(tx_buffer->dma); |
1805 | use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | | 1816 | use_tpd->word2 = (use_tpd->word2 & (~TPD_BUFLEN_MASK)) | |
1806 | ((cpu_to_le32(tx_buffer->length) & | 1817 | ((cpu_to_le32(tx_buffer->length) & |
diff --git a/drivers/net/b44.c b/drivers/net/b44.c index 0189dcd36f31..e046943ef29d 100644 --- a/drivers/net/b44.c +++ b/drivers/net/b44.c | |||
@@ -847,23 +847,22 @@ static int b44_poll(struct napi_struct *napi, int budget) | |||
847 | { | 847 | { |
848 | struct b44 *bp = container_of(napi, struct b44, napi); | 848 | struct b44 *bp = container_of(napi, struct b44, napi); |
849 | int work_done; | 849 | int work_done; |
850 | unsigned long flags; | ||
850 | 851 | ||
851 | spin_lock_irq(&bp->lock); | 852 | spin_lock_irqsave(&bp->lock, flags); |
852 | 853 | ||
853 | if (bp->istat & (ISTAT_TX | ISTAT_TO)) { | 854 | if (bp->istat & (ISTAT_TX | ISTAT_TO)) { |
854 | /* spin_lock(&bp->tx_lock); */ | 855 | /* spin_lock(&bp->tx_lock); */ |
855 | b44_tx(bp); | 856 | b44_tx(bp); |
856 | /* spin_unlock(&bp->tx_lock); */ | 857 | /* spin_unlock(&bp->tx_lock); */ |
857 | } | 858 | } |
858 | spin_unlock_irq(&bp->lock); | 859 | spin_unlock_irqrestore(&bp->lock, flags); |
859 | 860 | ||
860 | work_done = 0; | 861 | work_done = 0; |
861 | if (bp->istat & ISTAT_RX) | 862 | if (bp->istat & ISTAT_RX) |
862 | work_done += b44_rx(bp, budget); | 863 | work_done += b44_rx(bp, budget); |
863 | 864 | ||
864 | if (bp->istat & ISTAT_ERRORS) { | 865 | if (bp->istat & ISTAT_ERRORS) { |
865 | unsigned long flags; | ||
866 | |||
867 | spin_lock_irqsave(&bp->lock, flags); | 866 | spin_lock_irqsave(&bp->lock, flags); |
868 | b44_halt(bp); | 867 | b44_halt(bp); |
869 | b44_init_rings(bp); | 868 | b44_init_rings(bp); |
diff --git a/drivers/net/benet/be.h b/drivers/net/benet/be.h index 13b72ce870de..684c6fe24c8d 100644 --- a/drivers/net/benet/be.h +++ b/drivers/net/benet/be.h | |||
@@ -362,5 +362,6 @@ static inline u8 is_udp_pkt(struct sk_buff *skb) | |||
362 | extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, | 362 | extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, |
363 | u16 num_popped); | 363 | u16 num_popped); |
364 | extern void be_link_status_update(struct be_adapter *adapter, bool link_up); | 364 | extern void be_link_status_update(struct be_adapter *adapter, bool link_up); |
365 | extern void netdev_stats_update(struct be_adapter *adapter); | ||
365 | extern int be_load_fw(struct be_adapter *adapter, u8 *func); | 366 | extern int be_load_fw(struct be_adapter *adapter, u8 *func); |
366 | #endif /* BE_H */ | 367 | #endif /* BE_H */ |
diff --git a/drivers/net/benet/be_cmds.c b/drivers/net/benet/be_cmds.c index 1db092498309..3dd76c4170bf 100644 --- a/drivers/net/benet/be_cmds.c +++ b/drivers/net/benet/be_cmds.c | |||
@@ -59,15 +59,22 @@ static int be_mcc_compl_process(struct be_adapter *adapter, | |||
59 | 59 | ||
60 | compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) & | 60 | compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) & |
61 | CQE_STATUS_COMPL_MASK; | 61 | CQE_STATUS_COMPL_MASK; |
62 | if (compl_status != MCC_STATUS_SUCCESS) { | 62 | if (compl_status == MCC_STATUS_SUCCESS) { |
63 | if (compl->tag0 == OPCODE_ETH_GET_STATISTICS) { | ||
64 | struct be_cmd_resp_get_stats *resp = | ||
65 | adapter->stats.cmd.va; | ||
66 | be_dws_le_to_cpu(&resp->hw_stats, | ||
67 | sizeof(resp->hw_stats)); | ||
68 | netdev_stats_update(adapter); | ||
69 | } | ||
70 | } else if (compl_status != MCC_STATUS_NOT_SUPPORTED) { | ||
63 | extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & | 71 | extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & |
64 | CQE_STATUS_EXTD_MASK; | 72 | CQE_STATUS_EXTD_MASK; |
65 | dev_warn(&adapter->pdev->dev, | 73 | dev_warn(&adapter->pdev->dev, |
66 | "Error in cmd completion: status(compl/extd)=%d/%d\n", | 74 | "Error in cmd completion: status(compl/extd)=%d/%d\n", |
67 | compl_status, extd_status); | 75 | compl_status, extd_status); |
68 | return -1; | ||
69 | } | 76 | } |
70 | return 0; | 77 | return compl_status; |
71 | } | 78 | } |
72 | 79 | ||
73 | /* Link state evt is a string of bytes; no need for endian swapping */ | 80 | /* Link state evt is a string of bytes; no need for endian swapping */ |
@@ -97,10 +104,10 @@ static struct be_mcc_compl *be_mcc_compl_get(struct be_adapter *adapter) | |||
97 | return NULL; | 104 | return NULL; |
98 | } | 105 | } |
99 | 106 | ||
100 | void be_process_mcc(struct be_adapter *adapter) | 107 | int be_process_mcc(struct be_adapter *adapter) |
101 | { | 108 | { |
102 | struct be_mcc_compl *compl; | 109 | struct be_mcc_compl *compl; |
103 | int num = 0; | 110 | int num = 0, status = 0; |
104 | 111 | ||
105 | spin_lock_bh(&adapter->mcc_cq_lock); | 112 | spin_lock_bh(&adapter->mcc_cq_lock); |
106 | while ((compl = be_mcc_compl_get(adapter))) { | 113 | while ((compl = be_mcc_compl_get(adapter))) { |
@@ -111,38 +118,47 @@ void be_process_mcc(struct be_adapter *adapter) | |||
111 | /* Interpret compl as a async link evt */ | 118 | /* Interpret compl as a async link evt */ |
112 | be_async_link_state_process(adapter, | 119 | be_async_link_state_process(adapter, |
113 | (struct be_async_event_link_state *) compl); | 120 | (struct be_async_event_link_state *) compl); |
114 | } else { | 121 | } else if (compl->flags & CQE_FLAGS_COMPLETED_MASK) { |
115 | be_mcc_compl_process(adapter, compl); | 122 | status = be_mcc_compl_process(adapter, compl); |
116 | atomic_dec(&adapter->mcc_obj.q.used); | 123 | atomic_dec(&adapter->mcc_obj.q.used); |
117 | } | 124 | } |
118 | be_mcc_compl_use(compl); | 125 | be_mcc_compl_use(compl); |
119 | num++; | 126 | num++; |
120 | } | 127 | } |
128 | |||
121 | if (num) | 129 | if (num) |
122 | be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, num); | 130 | be_cq_notify(adapter, adapter->mcc_obj.cq.id, true, num); |
131 | |||
123 | spin_unlock_bh(&adapter->mcc_cq_lock); | 132 | spin_unlock_bh(&adapter->mcc_cq_lock); |
133 | return status; | ||
124 | } | 134 | } |
125 | 135 | ||
126 | /* Wait till no more pending mcc requests are present */ | 136 | /* Wait till no more pending mcc requests are present */ |
127 | static void be_mcc_wait_compl(struct be_adapter *adapter) | 137 | static int be_mcc_wait_compl(struct be_adapter *adapter) |
128 | { | 138 | { |
129 | #define mcc_timeout 50000 /* 5s timeout */ | 139 | #define mcc_timeout 120000 /* 12s timeout */ |
130 | int i; | 140 | int i, status; |
131 | for (i = 0; i < mcc_timeout; i++) { | 141 | for (i = 0; i < mcc_timeout; i++) { |
132 | be_process_mcc(adapter); | 142 | status = be_process_mcc(adapter); |
143 | if (status) | ||
144 | return status; | ||
145 | |||
133 | if (atomic_read(&adapter->mcc_obj.q.used) == 0) | 146 | if (atomic_read(&adapter->mcc_obj.q.used) == 0) |
134 | break; | 147 | break; |
135 | udelay(100); | 148 | udelay(100); |
136 | } | 149 | } |
137 | if (i == mcc_timeout) | 150 | if (i == mcc_timeout) { |
138 | dev_err(&adapter->pdev->dev, "mccq poll timed out\n"); | 151 | dev_err(&adapter->pdev->dev, "mccq poll timed out\n"); |
152 | return -1; | ||
153 | } | ||
154 | return 0; | ||
139 | } | 155 | } |
140 | 156 | ||
141 | /* Notify MCC requests and wait for completion */ | 157 | /* Notify MCC requests and wait for completion */ |
142 | static void be_mcc_notify_wait(struct be_adapter *adapter) | 158 | static int be_mcc_notify_wait(struct be_adapter *adapter) |
143 | { | 159 | { |
144 | be_mcc_notify(adapter); | 160 | be_mcc_notify(adapter); |
145 | be_mcc_wait_compl(adapter); | 161 | return be_mcc_wait_compl(adapter); |
146 | } | 162 | } |
147 | 163 | ||
148 | static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) | 164 | static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) |
@@ -173,7 +189,7 @@ static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db) | |||
173 | * Insert the mailbox address into the doorbell in two steps | 189 | * Insert the mailbox address into the doorbell in two steps |
174 | * Polls on the mbox doorbell till a command completion (or a timeout) occurs | 190 | * Polls on the mbox doorbell till a command completion (or a timeout) occurs |
175 | */ | 191 | */ |
176 | static int be_mbox_notify(struct be_adapter *adapter) | 192 | static int be_mbox_notify_wait(struct be_adapter *adapter) |
177 | { | 193 | { |
178 | int status; | 194 | int status; |
179 | u32 val = 0; | 195 | u32 val = 0; |
@@ -182,8 +198,6 @@ static int be_mbox_notify(struct be_adapter *adapter) | |||
182 | struct be_mcc_mailbox *mbox = mbox_mem->va; | 198 | struct be_mcc_mailbox *mbox = mbox_mem->va; |
183 | struct be_mcc_compl *compl = &mbox->compl; | 199 | struct be_mcc_compl *compl = &mbox->compl; |
184 | 200 | ||
185 | memset(compl, 0, sizeof(*compl)); | ||
186 | |||
187 | val |= MPU_MAILBOX_DB_HI_MASK; | 201 | val |= MPU_MAILBOX_DB_HI_MASK; |
188 | /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */ | 202 | /* at bits 2 - 31 place mbox dma addr msb bits 34 - 63 */ |
189 | val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2; | 203 | val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2; |
@@ -310,34 +324,40 @@ static u32 eq_delay_to_mult(u32 usec_delay) | |||
310 | return multiplier; | 324 | return multiplier; |
311 | } | 325 | } |
312 | 326 | ||
313 | static inline struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem) | 327 | static inline struct be_mcc_wrb *wrb_from_mbox(struct be_adapter *adapter) |
314 | { | 328 | { |
315 | return &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb; | 329 | struct be_dma_mem *mbox_mem = &adapter->mbox_mem; |
330 | struct be_mcc_wrb *wrb | ||
331 | = &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb; | ||
332 | memset(wrb, 0, sizeof(*wrb)); | ||
333 | return wrb; | ||
316 | } | 334 | } |
317 | 335 | ||
318 | static inline struct be_mcc_wrb *wrb_from_mcc(struct be_queue_info *mccq) | 336 | static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter) |
319 | { | 337 | { |
320 | struct be_mcc_wrb *wrb = NULL; | 338 | struct be_queue_info *mccq = &adapter->mcc_obj.q; |
321 | if (atomic_read(&mccq->used) < mccq->len) { | 339 | struct be_mcc_wrb *wrb; |
322 | wrb = queue_head_node(mccq); | 340 | |
323 | queue_head_inc(mccq); | 341 | BUG_ON(atomic_read(&mccq->used) >= mccq->len); |
324 | atomic_inc(&mccq->used); | 342 | wrb = queue_head_node(mccq); |
325 | memset(wrb, 0, sizeof(*wrb)); | 343 | queue_head_inc(mccq); |
326 | } | 344 | atomic_inc(&mccq->used); |
345 | memset(wrb, 0, sizeof(*wrb)); | ||
327 | return wrb; | 346 | return wrb; |
328 | } | 347 | } |
329 | 348 | ||
330 | int be_cmd_eq_create(struct be_adapter *adapter, | 349 | int be_cmd_eq_create(struct be_adapter *adapter, |
331 | struct be_queue_info *eq, int eq_delay) | 350 | struct be_queue_info *eq, int eq_delay) |
332 | { | 351 | { |
333 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 352 | struct be_mcc_wrb *wrb; |
334 | struct be_cmd_req_eq_create *req = embedded_payload(wrb); | 353 | struct be_cmd_req_eq_create *req; |
335 | struct be_cmd_resp_eq_create *resp = embedded_payload(wrb); | ||
336 | struct be_dma_mem *q_mem = &eq->dma_mem; | 354 | struct be_dma_mem *q_mem = &eq->dma_mem; |
337 | int status; | 355 | int status; |
338 | 356 | ||
339 | spin_lock(&adapter->mbox_lock); | 357 | spin_lock(&adapter->mbox_lock); |
340 | memset(wrb, 0, sizeof(*wrb)); | 358 | |
359 | wrb = wrb_from_mbox(adapter); | ||
360 | req = embedded_payload(wrb); | ||
341 | 361 | ||
342 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 362 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
343 | 363 | ||
@@ -359,25 +379,29 @@ int be_cmd_eq_create(struct be_adapter *adapter, | |||
359 | 379 | ||
360 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 380 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
361 | 381 | ||
362 | status = be_mbox_notify(adapter); | 382 | status = be_mbox_notify_wait(adapter); |
363 | if (!status) { | 383 | if (!status) { |
384 | struct be_cmd_resp_eq_create *resp = embedded_payload(wrb); | ||
364 | eq->id = le16_to_cpu(resp->eq_id); | 385 | eq->id = le16_to_cpu(resp->eq_id); |
365 | eq->created = true; | 386 | eq->created = true; |
366 | } | 387 | } |
388 | |||
367 | spin_unlock(&adapter->mbox_lock); | 389 | spin_unlock(&adapter->mbox_lock); |
368 | return status; | 390 | return status; |
369 | } | 391 | } |
370 | 392 | ||
393 | /* Uses mbox */ | ||
371 | int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, | 394 | int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, |
372 | u8 type, bool permanent, u32 if_handle) | 395 | u8 type, bool permanent, u32 if_handle) |
373 | { | 396 | { |
374 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 397 | struct be_mcc_wrb *wrb; |
375 | struct be_cmd_req_mac_query *req = embedded_payload(wrb); | 398 | struct be_cmd_req_mac_query *req; |
376 | struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); | ||
377 | int status; | 399 | int status; |
378 | 400 | ||
379 | spin_lock(&adapter->mbox_lock); | 401 | spin_lock(&adapter->mbox_lock); |
380 | memset(wrb, 0, sizeof(*wrb)); | 402 | |
403 | wrb = wrb_from_mbox(adapter); | ||
404 | req = embedded_payload(wrb); | ||
381 | 405 | ||
382 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 406 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
383 | 407 | ||
@@ -388,27 +412,32 @@ int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, | |||
388 | if (permanent) { | 412 | if (permanent) { |
389 | req->permanent = 1; | 413 | req->permanent = 1; |
390 | } else { | 414 | } else { |
391 | req->if_id = cpu_to_le16((u16)if_handle); | 415 | req->if_id = cpu_to_le16((u16) if_handle); |
392 | req->permanent = 0; | 416 | req->permanent = 0; |
393 | } | 417 | } |
394 | 418 | ||
395 | status = be_mbox_notify(adapter); | 419 | status = be_mbox_notify_wait(adapter); |
396 | if (!status) | 420 | if (!status) { |
421 | struct be_cmd_resp_mac_query *resp = embedded_payload(wrb); | ||
397 | memcpy(mac_addr, resp->mac.addr, ETH_ALEN); | 422 | memcpy(mac_addr, resp->mac.addr, ETH_ALEN); |
423 | } | ||
398 | 424 | ||
399 | spin_unlock(&adapter->mbox_lock); | 425 | spin_unlock(&adapter->mbox_lock); |
400 | return status; | 426 | return status; |
401 | } | 427 | } |
402 | 428 | ||
429 | /* Uses synchronous MCCQ */ | ||
403 | int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, | 430 | int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, |
404 | u32 if_id, u32 *pmac_id) | 431 | u32 if_id, u32 *pmac_id) |
405 | { | 432 | { |
406 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 433 | struct be_mcc_wrb *wrb; |
407 | struct be_cmd_req_pmac_add *req = embedded_payload(wrb); | 434 | struct be_cmd_req_pmac_add *req; |
408 | int status; | 435 | int status; |
409 | 436 | ||
410 | spin_lock(&adapter->mbox_lock); | 437 | spin_lock_bh(&adapter->mcc_lock); |
411 | memset(wrb, 0, sizeof(*wrb)); | 438 | |
439 | wrb = wrb_from_mccq(adapter); | ||
440 | req = embedded_payload(wrb); | ||
412 | 441 | ||
413 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 442 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
414 | 443 | ||
@@ -418,24 +447,27 @@ int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, | |||
418 | req->if_id = cpu_to_le32(if_id); | 447 | req->if_id = cpu_to_le32(if_id); |
419 | memcpy(req->mac_address, mac_addr, ETH_ALEN); | 448 | memcpy(req->mac_address, mac_addr, ETH_ALEN); |
420 | 449 | ||
421 | status = be_mbox_notify(adapter); | 450 | status = be_mcc_notify_wait(adapter); |
422 | if (!status) { | 451 | if (!status) { |
423 | struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb); | 452 | struct be_cmd_resp_pmac_add *resp = embedded_payload(wrb); |
424 | *pmac_id = le32_to_cpu(resp->pmac_id); | 453 | *pmac_id = le32_to_cpu(resp->pmac_id); |
425 | } | 454 | } |
426 | 455 | ||
427 | spin_unlock(&adapter->mbox_lock); | 456 | spin_unlock_bh(&adapter->mcc_lock); |
428 | return status; | 457 | return status; |
429 | } | 458 | } |
430 | 459 | ||
460 | /* Uses synchronous MCCQ */ | ||
431 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id) | 461 | int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id) |
432 | { | 462 | { |
433 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 463 | struct be_mcc_wrb *wrb; |
434 | struct be_cmd_req_pmac_del *req = embedded_payload(wrb); | 464 | struct be_cmd_req_pmac_del *req; |
435 | int status; | 465 | int status; |
436 | 466 | ||
437 | spin_lock(&adapter->mbox_lock); | 467 | spin_lock_bh(&adapter->mcc_lock); |
438 | memset(wrb, 0, sizeof(*wrb)); | 468 | |
469 | wrb = wrb_from_mccq(adapter); | ||
470 | req = embedded_payload(wrb); | ||
439 | 471 | ||
440 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 472 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
441 | 473 | ||
@@ -445,25 +477,29 @@ int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id) | |||
445 | req->if_id = cpu_to_le32(if_id); | 477 | req->if_id = cpu_to_le32(if_id); |
446 | req->pmac_id = cpu_to_le32(pmac_id); | 478 | req->pmac_id = cpu_to_le32(pmac_id); |
447 | 479 | ||
448 | status = be_mbox_notify(adapter); | 480 | status = be_mcc_notify_wait(adapter); |
449 | spin_unlock(&adapter->mbox_lock); | 481 | |
482 | spin_unlock_bh(&adapter->mcc_lock); | ||
450 | 483 | ||
451 | return status; | 484 | return status; |
452 | } | 485 | } |
453 | 486 | ||
487 | /* Uses Mbox */ | ||
454 | int be_cmd_cq_create(struct be_adapter *adapter, | 488 | int be_cmd_cq_create(struct be_adapter *adapter, |
455 | struct be_queue_info *cq, struct be_queue_info *eq, | 489 | struct be_queue_info *cq, struct be_queue_info *eq, |
456 | bool sol_evts, bool no_delay, int coalesce_wm) | 490 | bool sol_evts, bool no_delay, int coalesce_wm) |
457 | { | 491 | { |
458 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 492 | struct be_mcc_wrb *wrb; |
459 | struct be_cmd_req_cq_create *req = embedded_payload(wrb); | 493 | struct be_cmd_req_cq_create *req; |
460 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); | ||
461 | struct be_dma_mem *q_mem = &cq->dma_mem; | 494 | struct be_dma_mem *q_mem = &cq->dma_mem; |
462 | void *ctxt = &req->context; | 495 | void *ctxt; |
463 | int status; | 496 | int status; |
464 | 497 | ||
465 | spin_lock(&adapter->mbox_lock); | 498 | spin_lock(&adapter->mbox_lock); |
466 | memset(wrb, 0, sizeof(*wrb)); | 499 | |
500 | wrb = wrb_from_mbox(adapter); | ||
501 | req = embedded_payload(wrb); | ||
502 | ctxt = &req->context; | ||
467 | 503 | ||
468 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 504 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
469 | 505 | ||
@@ -486,11 +522,13 @@ int be_cmd_cq_create(struct be_adapter *adapter, | |||
486 | 522 | ||
487 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 523 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
488 | 524 | ||
489 | status = be_mbox_notify(adapter); | 525 | status = be_mbox_notify_wait(adapter); |
490 | if (!status) { | 526 | if (!status) { |
527 | struct be_cmd_resp_cq_create *resp = embedded_payload(wrb); | ||
491 | cq->id = le16_to_cpu(resp->cq_id); | 528 | cq->id = le16_to_cpu(resp->cq_id); |
492 | cq->created = true; | 529 | cq->created = true; |
493 | } | 530 | } |
531 | |||
494 | spin_unlock(&adapter->mbox_lock); | 532 | spin_unlock(&adapter->mbox_lock); |
495 | 533 | ||
496 | return status; | 534 | return status; |
@@ -508,14 +546,17 @@ int be_cmd_mccq_create(struct be_adapter *adapter, | |||
508 | struct be_queue_info *mccq, | 546 | struct be_queue_info *mccq, |
509 | struct be_queue_info *cq) | 547 | struct be_queue_info *cq) |
510 | { | 548 | { |
511 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 549 | struct be_mcc_wrb *wrb; |
512 | struct be_cmd_req_mcc_create *req = embedded_payload(wrb); | 550 | struct be_cmd_req_mcc_create *req; |
513 | struct be_dma_mem *q_mem = &mccq->dma_mem; | 551 | struct be_dma_mem *q_mem = &mccq->dma_mem; |
514 | void *ctxt = &req->context; | 552 | void *ctxt; |
515 | int status; | 553 | int status; |
516 | 554 | ||
517 | spin_lock(&adapter->mbox_lock); | 555 | spin_lock(&adapter->mbox_lock); |
518 | memset(wrb, 0, sizeof(*wrb)); | 556 | |
557 | wrb = wrb_from_mbox(adapter); | ||
558 | req = embedded_payload(wrb); | ||
559 | ctxt = &req->context; | ||
519 | 560 | ||
520 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 561 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
521 | 562 | ||
@@ -534,7 +575,7 @@ int be_cmd_mccq_create(struct be_adapter *adapter, | |||
534 | 575 | ||
535 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 576 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
536 | 577 | ||
537 | status = be_mbox_notify(adapter); | 578 | status = be_mbox_notify_wait(adapter); |
538 | if (!status) { | 579 | if (!status) { |
539 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); | 580 | struct be_cmd_resp_mcc_create *resp = embedded_payload(wrb); |
540 | mccq->id = le16_to_cpu(resp->id); | 581 | mccq->id = le16_to_cpu(resp->id); |
@@ -549,15 +590,17 @@ int be_cmd_txq_create(struct be_adapter *adapter, | |||
549 | struct be_queue_info *txq, | 590 | struct be_queue_info *txq, |
550 | struct be_queue_info *cq) | 591 | struct be_queue_info *cq) |
551 | { | 592 | { |
552 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 593 | struct be_mcc_wrb *wrb; |
553 | struct be_cmd_req_eth_tx_create *req = embedded_payload(wrb); | 594 | struct be_cmd_req_eth_tx_create *req; |
554 | struct be_dma_mem *q_mem = &txq->dma_mem; | 595 | struct be_dma_mem *q_mem = &txq->dma_mem; |
555 | void *ctxt = &req->context; | 596 | void *ctxt; |
556 | int status; | 597 | int status; |
557 | u32 len_encoded; | ||
558 | 598 | ||
559 | spin_lock(&adapter->mbox_lock); | 599 | spin_lock(&adapter->mbox_lock); |
560 | memset(wrb, 0, sizeof(*wrb)); | 600 | |
601 | wrb = wrb_from_mbox(adapter); | ||
602 | req = embedded_payload(wrb); | ||
603 | ctxt = &req->context; | ||
561 | 604 | ||
562 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 605 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
563 | 606 | ||
@@ -568,10 +611,8 @@ int be_cmd_txq_create(struct be_adapter *adapter, | |||
568 | req->ulp_num = BE_ULP1_NUM; | 611 | req->ulp_num = BE_ULP1_NUM; |
569 | req->type = BE_ETH_TX_RING_TYPE_STANDARD; | 612 | req->type = BE_ETH_TX_RING_TYPE_STANDARD; |
570 | 613 | ||
571 | len_encoded = fls(txq->len); /* log2(len) + 1 */ | 614 | AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, |
572 | if (len_encoded == 16) | 615 | be_encoded_q_len(txq->len)); |
573 | len_encoded = 0; | ||
574 | AMAP_SET_BITS(struct amap_tx_context, tx_ring_size, ctxt, len_encoded); | ||
575 | AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt, | 616 | AMAP_SET_BITS(struct amap_tx_context, pci_func_id, ctxt, |
576 | be_pci_func(adapter)); | 617 | be_pci_func(adapter)); |
577 | AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); | 618 | AMAP_SET_BITS(struct amap_tx_context, ctx_valid, ctxt, 1); |
@@ -581,28 +622,32 @@ int be_cmd_txq_create(struct be_adapter *adapter, | |||
581 | 622 | ||
582 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); | 623 | be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); |
583 | 624 | ||
584 | status = be_mbox_notify(adapter); | 625 | status = be_mbox_notify_wait(adapter); |
585 | if (!status) { | 626 | if (!status) { |
586 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); | 627 | struct be_cmd_resp_eth_tx_create *resp = embedded_payload(wrb); |
587 | txq->id = le16_to_cpu(resp->cid); | 628 | txq->id = le16_to_cpu(resp->cid); |
588 | txq->created = true; | 629 | txq->created = true; |
589 | } | 630 | } |
631 | |||
590 | spin_unlock(&adapter->mbox_lock); | 632 | spin_unlock(&adapter->mbox_lock); |
591 | 633 | ||
592 | return status; | 634 | return status; |
593 | } | 635 | } |
594 | 636 | ||
637 | /* Uses mbox */ | ||
595 | int be_cmd_rxq_create(struct be_adapter *adapter, | 638 | int be_cmd_rxq_create(struct be_adapter *adapter, |
596 | struct be_queue_info *rxq, u16 cq_id, u16 frag_size, | 639 | struct be_queue_info *rxq, u16 cq_id, u16 frag_size, |
597 | u16 max_frame_size, u32 if_id, u32 rss) | 640 | u16 max_frame_size, u32 if_id, u32 rss) |
598 | { | 641 | { |
599 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 642 | struct be_mcc_wrb *wrb; |
600 | struct be_cmd_req_eth_rx_create *req = embedded_payload(wrb); | 643 | struct be_cmd_req_eth_rx_create *req; |
601 | struct be_dma_mem *q_mem = &rxq->dma_mem; | 644 | struct be_dma_mem *q_mem = &rxq->dma_mem; |
602 | int status; | 645 | int status; |
603 | 646 | ||
604 | spin_lock(&adapter->mbox_lock); | 647 | spin_lock(&adapter->mbox_lock); |
605 | memset(wrb, 0, sizeof(*wrb)); | 648 | |
649 | wrb = wrb_from_mbox(adapter); | ||
650 | req = embedded_payload(wrb); | ||
606 | 651 | ||
607 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 652 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
608 | 653 | ||
@@ -617,29 +662,34 @@ int be_cmd_rxq_create(struct be_adapter *adapter, | |||
617 | req->max_frame_size = cpu_to_le16(max_frame_size); | 662 | req->max_frame_size = cpu_to_le16(max_frame_size); |
618 | req->rss_queue = cpu_to_le32(rss); | 663 | req->rss_queue = cpu_to_le32(rss); |
619 | 664 | ||
620 | status = be_mbox_notify(adapter); | 665 | status = be_mbox_notify_wait(adapter); |
621 | if (!status) { | 666 | if (!status) { |
622 | struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); | 667 | struct be_cmd_resp_eth_rx_create *resp = embedded_payload(wrb); |
623 | rxq->id = le16_to_cpu(resp->id); | 668 | rxq->id = le16_to_cpu(resp->id); |
624 | rxq->created = true; | 669 | rxq->created = true; |
625 | } | 670 | } |
671 | |||
626 | spin_unlock(&adapter->mbox_lock); | 672 | spin_unlock(&adapter->mbox_lock); |
627 | 673 | ||
628 | return status; | 674 | return status; |
629 | } | 675 | } |
630 | 676 | ||
631 | /* Generic destroyer function for all types of queues */ | 677 | /* Generic destroyer function for all types of queues |
678 | * Uses Mbox | ||
679 | */ | ||
632 | int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, | 680 | int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, |
633 | int queue_type) | 681 | int queue_type) |
634 | { | 682 | { |
635 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 683 | struct be_mcc_wrb *wrb; |
636 | struct be_cmd_req_q_destroy *req = embedded_payload(wrb); | 684 | struct be_cmd_req_q_destroy *req; |
637 | u8 subsys = 0, opcode = 0; | 685 | u8 subsys = 0, opcode = 0; |
638 | int status; | 686 | int status; |
639 | 687 | ||
640 | spin_lock(&adapter->mbox_lock); | 688 | spin_lock(&adapter->mbox_lock); |
641 | 689 | ||
642 | memset(wrb, 0, sizeof(*wrb)); | 690 | wrb = wrb_from_mbox(adapter); |
691 | req = embedded_payload(wrb); | ||
692 | |||
643 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 693 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
644 | 694 | ||
645 | switch (queue_type) { | 695 | switch (queue_type) { |
@@ -669,23 +719,27 @@ int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, | |||
669 | be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); | 719 | be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); |
670 | req->id = cpu_to_le16(q->id); | 720 | req->id = cpu_to_le16(q->id); |
671 | 721 | ||
672 | status = be_mbox_notify(adapter); | 722 | status = be_mbox_notify_wait(adapter); |
673 | 723 | ||
674 | spin_unlock(&adapter->mbox_lock); | 724 | spin_unlock(&adapter->mbox_lock); |
675 | 725 | ||
676 | return status; | 726 | return status; |
677 | } | 727 | } |
678 | 728 | ||
679 | /* Create an rx filtering policy configuration on an i/f */ | 729 | /* Create an rx filtering policy configuration on an i/f |
730 | * Uses mbox | ||
731 | */ | ||
680 | int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, | 732 | int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, |
681 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id) | 733 | bool pmac_invalid, u32 *if_handle, u32 *pmac_id) |
682 | { | 734 | { |
683 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 735 | struct be_mcc_wrb *wrb; |
684 | struct be_cmd_req_if_create *req = embedded_payload(wrb); | 736 | struct be_cmd_req_if_create *req; |
685 | int status; | 737 | int status; |
686 | 738 | ||
687 | spin_lock(&adapter->mbox_lock); | 739 | spin_lock(&adapter->mbox_lock); |
688 | memset(wrb, 0, sizeof(*wrb)); | 740 | |
741 | wrb = wrb_from_mbox(adapter); | ||
742 | req = embedded_payload(wrb); | ||
689 | 743 | ||
690 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 744 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
691 | 745 | ||
@@ -694,10 +748,11 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, | |||
694 | 748 | ||
695 | req->capability_flags = cpu_to_le32(flags); | 749 | req->capability_flags = cpu_to_le32(flags); |
696 | req->enable_flags = cpu_to_le32(flags); | 750 | req->enable_flags = cpu_to_le32(flags); |
751 | req->pmac_invalid = pmac_invalid; | ||
697 | if (!pmac_invalid) | 752 | if (!pmac_invalid) |
698 | memcpy(req->mac_addr, mac, ETH_ALEN); | 753 | memcpy(req->mac_addr, mac, ETH_ALEN); |
699 | 754 | ||
700 | status = be_mbox_notify(adapter); | 755 | status = be_mbox_notify_wait(adapter); |
701 | if (!status) { | 756 | if (!status) { |
702 | struct be_cmd_resp_if_create *resp = embedded_payload(wrb); | 757 | struct be_cmd_resp_if_create *resp = embedded_payload(wrb); |
703 | *if_handle = le32_to_cpu(resp->interface_id); | 758 | *if_handle = le32_to_cpu(resp->interface_id); |
@@ -709,14 +764,17 @@ int be_cmd_if_create(struct be_adapter *adapter, u32 flags, u8 *mac, | |||
709 | return status; | 764 | return status; |
710 | } | 765 | } |
711 | 766 | ||
767 | /* Uses mbox */ | ||
712 | int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id) | 768 | int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id) |
713 | { | 769 | { |
714 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 770 | struct be_mcc_wrb *wrb; |
715 | struct be_cmd_req_if_destroy *req = embedded_payload(wrb); | 771 | struct be_cmd_req_if_destroy *req; |
716 | int status; | 772 | int status; |
717 | 773 | ||
718 | spin_lock(&adapter->mbox_lock); | 774 | spin_lock(&adapter->mbox_lock); |
719 | memset(wrb, 0, sizeof(*wrb)); | 775 | |
776 | wrb = wrb_from_mbox(adapter); | ||
777 | req = embedded_payload(wrb); | ||
720 | 778 | ||
721 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 779 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
722 | 780 | ||
@@ -724,7 +782,8 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id) | |||
724 | OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req)); | 782 | OPCODE_COMMON_NTWK_INTERFACE_DESTROY, sizeof(*req)); |
725 | 783 | ||
726 | req->interface_id = cpu_to_le32(interface_id); | 784 | req->interface_id = cpu_to_le32(interface_id); |
727 | status = be_mbox_notify(adapter); | 785 | |
786 | status = be_mbox_notify_wait(adapter); | ||
728 | 787 | ||
729 | spin_unlock(&adapter->mbox_lock); | 788 | spin_unlock(&adapter->mbox_lock); |
730 | 789 | ||
@@ -733,20 +792,22 @@ int be_cmd_if_destroy(struct be_adapter *adapter, u32 interface_id) | |||
733 | 792 | ||
734 | /* Get stats is a non embedded command: the request is not embedded inside | 793 | /* Get stats is a non embedded command: the request is not embedded inside |
735 | * WRB but is a separate dma memory block | 794 | * WRB but is a separate dma memory block |
795 | * Uses asynchronous MCC | ||
736 | */ | 796 | */ |
737 | int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) | 797 | int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) |
738 | { | 798 | { |
739 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 799 | struct be_mcc_wrb *wrb; |
740 | struct be_cmd_req_get_stats *req = nonemb_cmd->va; | 800 | struct be_cmd_req_get_stats *req; |
741 | struct be_sge *sge = nonembedded_sgl(wrb); | 801 | struct be_sge *sge; |
742 | int status; | ||
743 | 802 | ||
744 | spin_lock(&adapter->mbox_lock); | 803 | spin_lock_bh(&adapter->mcc_lock); |
745 | memset(wrb, 0, sizeof(*wrb)); | ||
746 | 804 | ||
747 | memset(req, 0, sizeof(*req)); | 805 | wrb = wrb_from_mccq(adapter); |
806 | req = nonemb_cmd->va; | ||
807 | sge = nonembedded_sgl(wrb); | ||
748 | 808 | ||
749 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); | 809 | be_wrb_hdr_prepare(wrb, sizeof(*req), false, 1); |
810 | wrb->tag0 = OPCODE_ETH_GET_STATISTICS; | ||
750 | 811 | ||
751 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, | 812 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ETH, |
752 | OPCODE_ETH_GET_STATISTICS, sizeof(*req)); | 813 | OPCODE_ETH_GET_STATISTICS, sizeof(*req)); |
@@ -754,59 +815,61 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd) | |||
754 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); | 815 | sge->pa_lo = cpu_to_le32(nonemb_cmd->dma & 0xFFFFFFFF); |
755 | sge->len = cpu_to_le32(nonemb_cmd->size); | 816 | sge->len = cpu_to_le32(nonemb_cmd->size); |
756 | 817 | ||
757 | status = be_mbox_notify(adapter); | 818 | be_mcc_notify(adapter); |
758 | if (!status) { | ||
759 | struct be_cmd_resp_get_stats *resp = nonemb_cmd->va; | ||
760 | be_dws_le_to_cpu(&resp->hw_stats, sizeof(resp->hw_stats)); | ||
761 | } | ||
762 | 819 | ||
763 | spin_unlock(&adapter->mbox_lock); | 820 | spin_unlock_bh(&adapter->mcc_lock); |
764 | return status; | 821 | return 0; |
765 | } | 822 | } |
766 | 823 | ||
824 | /* Uses synchronous mcc */ | ||
767 | int be_cmd_link_status_query(struct be_adapter *adapter, | 825 | int be_cmd_link_status_query(struct be_adapter *adapter, |
768 | bool *link_up) | 826 | bool *link_up) |
769 | { | 827 | { |
770 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 828 | struct be_mcc_wrb *wrb; |
771 | struct be_cmd_req_link_status *req = embedded_payload(wrb); | 829 | struct be_cmd_req_link_status *req; |
772 | int status; | 830 | int status; |
773 | 831 | ||
774 | spin_lock(&adapter->mbox_lock); | 832 | spin_lock_bh(&adapter->mcc_lock); |
833 | |||
834 | wrb = wrb_from_mccq(adapter); | ||
835 | req = embedded_payload(wrb); | ||
775 | 836 | ||
776 | *link_up = false; | 837 | *link_up = false; |
777 | memset(wrb, 0, sizeof(*wrb)); | ||
778 | 838 | ||
779 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 839 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
780 | 840 | ||
781 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 841 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
782 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req)); | 842 | OPCODE_COMMON_NTWK_LINK_STATUS_QUERY, sizeof(*req)); |
783 | 843 | ||
784 | status = be_mbox_notify(adapter); | 844 | status = be_mcc_notify_wait(adapter); |
785 | if (!status) { | 845 | if (!status) { |
786 | struct be_cmd_resp_link_status *resp = embedded_payload(wrb); | 846 | struct be_cmd_resp_link_status *resp = embedded_payload(wrb); |
787 | if (resp->mac_speed != PHY_LINK_SPEED_ZERO) | 847 | if (resp->mac_speed != PHY_LINK_SPEED_ZERO) |
788 | *link_up = true; | 848 | *link_up = true; |
789 | } | 849 | } |
790 | 850 | ||
791 | spin_unlock(&adapter->mbox_lock); | 851 | spin_unlock_bh(&adapter->mcc_lock); |
792 | return status; | 852 | return status; |
793 | } | 853 | } |
794 | 854 | ||
855 | /* Uses Mbox */ | ||
795 | int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) | 856 | int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) |
796 | { | 857 | { |
797 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 858 | struct be_mcc_wrb *wrb; |
798 | struct be_cmd_req_get_fw_version *req = embedded_payload(wrb); | 859 | struct be_cmd_req_get_fw_version *req; |
799 | int status; | 860 | int status; |
800 | 861 | ||
801 | spin_lock(&adapter->mbox_lock); | 862 | spin_lock(&adapter->mbox_lock); |
802 | memset(wrb, 0, sizeof(*wrb)); | 863 | |
864 | wrb = wrb_from_mbox(adapter); | ||
865 | req = embedded_payload(wrb); | ||
803 | 866 | ||
804 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 867 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
805 | 868 | ||
806 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 869 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
807 | OPCODE_COMMON_GET_FW_VERSION, sizeof(*req)); | 870 | OPCODE_COMMON_GET_FW_VERSION, sizeof(*req)); |
808 | 871 | ||
809 | status = be_mbox_notify(adapter); | 872 | status = be_mbox_notify_wait(adapter); |
810 | if (!status) { | 873 | if (!status) { |
811 | struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); | 874 | struct be_cmd_resp_get_fw_version *resp = embedded_payload(wrb); |
812 | strncpy(fw_ver, resp->firmware_version_string, FW_VER_LEN); | 875 | strncpy(fw_ver, resp->firmware_version_string, FW_VER_LEN); |
@@ -816,15 +879,18 @@ int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver) | |||
816 | return status; | 879 | return status; |
817 | } | 880 | } |
818 | 881 | ||
819 | /* set the EQ delay interval of an EQ to specified value */ | 882 | /* set the EQ delay interval of an EQ to specified value |
883 | * Uses async mcc | ||
884 | */ | ||
820 | int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd) | 885 | int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd) |
821 | { | 886 | { |
822 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 887 | struct be_mcc_wrb *wrb; |
823 | struct be_cmd_req_modify_eq_delay *req = embedded_payload(wrb); | 888 | struct be_cmd_req_modify_eq_delay *req; |
824 | int status; | ||
825 | 889 | ||
826 | spin_lock(&adapter->mbox_lock); | 890 | spin_lock_bh(&adapter->mcc_lock); |
827 | memset(wrb, 0, sizeof(*wrb)); | 891 | |
892 | wrb = wrb_from_mccq(adapter); | ||
893 | req = embedded_payload(wrb); | ||
828 | 894 | ||
829 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 895 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
830 | 896 | ||
@@ -836,21 +902,24 @@ int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd) | |||
836 | req->delay[0].phase = 0; | 902 | req->delay[0].phase = 0; |
837 | req->delay[0].delay_multiplier = cpu_to_le32(eqd); | 903 | req->delay[0].delay_multiplier = cpu_to_le32(eqd); |
838 | 904 | ||
839 | status = be_mbox_notify(adapter); | 905 | be_mcc_notify(adapter); |
840 | 906 | ||
841 | spin_unlock(&adapter->mbox_lock); | 907 | spin_unlock_bh(&adapter->mcc_lock); |
842 | return status; | 908 | return 0; |
843 | } | 909 | } |
844 | 910 | ||
911 | /* Uses sycnhronous mcc */ | ||
845 | int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, | 912 | int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, |
846 | u32 num, bool untagged, bool promiscuous) | 913 | u32 num, bool untagged, bool promiscuous) |
847 | { | 914 | { |
848 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 915 | struct be_mcc_wrb *wrb; |
849 | struct be_cmd_req_vlan_config *req = embedded_payload(wrb); | 916 | struct be_cmd_req_vlan_config *req; |
850 | int status; | 917 | int status; |
851 | 918 | ||
852 | spin_lock(&adapter->mbox_lock); | 919 | spin_lock_bh(&adapter->mcc_lock); |
853 | memset(wrb, 0, sizeof(*wrb)); | 920 | |
921 | wrb = wrb_from_mccq(adapter); | ||
922 | req = embedded_payload(wrb); | ||
854 | 923 | ||
855 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 924 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
856 | 925 | ||
@@ -866,23 +935,24 @@ int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array, | |||
866 | req->num_vlan * sizeof(vtag_array[0])); | 935 | req->num_vlan * sizeof(vtag_array[0])); |
867 | } | 936 | } |
868 | 937 | ||
869 | status = be_mbox_notify(adapter); | 938 | status = be_mcc_notify_wait(adapter); |
870 | 939 | ||
871 | spin_unlock(&adapter->mbox_lock); | 940 | spin_unlock_bh(&adapter->mcc_lock); |
872 | return status; | 941 | return status; |
873 | } | 942 | } |
874 | 943 | ||
875 | /* Use MCC for this command as it may be called in BH context */ | 944 | /* Uses MCC for this command as it may be called in BH context |
945 | * Uses synchronous mcc | ||
946 | */ | ||
876 | int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en) | 947 | int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en) |
877 | { | 948 | { |
878 | struct be_mcc_wrb *wrb; | 949 | struct be_mcc_wrb *wrb; |
879 | struct be_cmd_req_promiscuous_config *req; | 950 | struct be_cmd_req_promiscuous_config *req; |
951 | int status; | ||
880 | 952 | ||
881 | spin_lock_bh(&adapter->mcc_lock); | 953 | spin_lock_bh(&adapter->mcc_lock); |
882 | 954 | ||
883 | wrb = wrb_from_mcc(&adapter->mcc_obj.q); | 955 | wrb = wrb_from_mccq(adapter); |
884 | BUG_ON(!wrb); | ||
885 | |||
886 | req = embedded_payload(wrb); | 956 | req = embedded_payload(wrb); |
887 | 957 | ||
888 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 958 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -895,14 +965,14 @@ int be_cmd_promiscuous_config(struct be_adapter *adapter, u8 port_num, bool en) | |||
895 | else | 965 | else |
896 | req->port0_promiscuous = en; | 966 | req->port0_promiscuous = en; |
897 | 967 | ||
898 | be_mcc_notify_wait(adapter); | 968 | status = be_mcc_notify_wait(adapter); |
899 | 969 | ||
900 | spin_unlock_bh(&adapter->mcc_lock); | 970 | spin_unlock_bh(&adapter->mcc_lock); |
901 | return 0; | 971 | return status; |
902 | } | 972 | } |
903 | 973 | ||
904 | /* | 974 | /* |
905 | * Use MCC for this command as it may be called in BH context | 975 | * Uses MCC for this command as it may be called in BH context |
906 | * (mc == NULL) => multicast promiscous | 976 | * (mc == NULL) => multicast promiscous |
907 | */ | 977 | */ |
908 | int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, | 978 | int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, |
@@ -914,9 +984,7 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, | |||
914 | 984 | ||
915 | spin_lock_bh(&adapter->mcc_lock); | 985 | spin_lock_bh(&adapter->mcc_lock); |
916 | 986 | ||
917 | wrb = wrb_from_mcc(&adapter->mcc_obj.q); | 987 | wrb = wrb_from_mccq(adapter); |
918 | BUG_ON(!wrb); | ||
919 | |||
920 | req = embedded_payload(wrb); | 988 | req = embedded_payload(wrb); |
921 | 989 | ||
922 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 990 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
@@ -944,15 +1012,17 @@ int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id, | |||
944 | return 0; | 1012 | return 0; |
945 | } | 1013 | } |
946 | 1014 | ||
1015 | /* Uses synchrounous mcc */ | ||
947 | int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc) | 1016 | int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc) |
948 | { | 1017 | { |
949 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 1018 | struct be_mcc_wrb *wrb; |
950 | struct be_cmd_req_set_flow_control *req = embedded_payload(wrb); | 1019 | struct be_cmd_req_set_flow_control *req; |
951 | int status; | 1020 | int status; |
952 | 1021 | ||
953 | spin_lock(&adapter->mbox_lock); | 1022 | spin_lock_bh(&adapter->mcc_lock); |
954 | 1023 | ||
955 | memset(wrb, 0, sizeof(*wrb)); | 1024 | wrb = wrb_from_mccq(adapter); |
1025 | req = embedded_payload(wrb); | ||
956 | 1026 | ||
957 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 1027 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
958 | 1028 | ||
@@ -962,28 +1032,30 @@ int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc) | |||
962 | req->tx_flow_control = cpu_to_le16((u16)tx_fc); | 1032 | req->tx_flow_control = cpu_to_le16((u16)tx_fc); |
963 | req->rx_flow_control = cpu_to_le16((u16)rx_fc); | 1033 | req->rx_flow_control = cpu_to_le16((u16)rx_fc); |
964 | 1034 | ||
965 | status = be_mbox_notify(adapter); | 1035 | status = be_mcc_notify_wait(adapter); |
966 | 1036 | ||
967 | spin_unlock(&adapter->mbox_lock); | 1037 | spin_unlock_bh(&adapter->mcc_lock); |
968 | return status; | 1038 | return status; |
969 | } | 1039 | } |
970 | 1040 | ||
1041 | /* Uses sycn mcc */ | ||
971 | int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc) | 1042 | int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc) |
972 | { | 1043 | { |
973 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 1044 | struct be_mcc_wrb *wrb; |
974 | struct be_cmd_req_get_flow_control *req = embedded_payload(wrb); | 1045 | struct be_cmd_req_get_flow_control *req; |
975 | int status; | 1046 | int status; |
976 | 1047 | ||
977 | spin_lock(&adapter->mbox_lock); | 1048 | spin_lock_bh(&adapter->mcc_lock); |
978 | 1049 | ||
979 | memset(wrb, 0, sizeof(*wrb)); | 1050 | wrb = wrb_from_mccq(adapter); |
1051 | req = embedded_payload(wrb); | ||
980 | 1052 | ||
981 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 1053 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
982 | 1054 | ||
983 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 1055 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
984 | OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req)); | 1056 | OPCODE_COMMON_GET_FLOW_CONTROL, sizeof(*req)); |
985 | 1057 | ||
986 | status = be_mbox_notify(adapter); | 1058 | status = be_mcc_notify_wait(adapter); |
987 | if (!status) { | 1059 | if (!status) { |
988 | struct be_cmd_resp_get_flow_control *resp = | 1060 | struct be_cmd_resp_get_flow_control *resp = |
989 | embedded_payload(wrb); | 1061 | embedded_payload(wrb); |
@@ -991,26 +1063,28 @@ int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc) | |||
991 | *rx_fc = le16_to_cpu(resp->rx_flow_control); | 1063 | *rx_fc = le16_to_cpu(resp->rx_flow_control); |
992 | } | 1064 | } |
993 | 1065 | ||
994 | spin_unlock(&adapter->mbox_lock); | 1066 | spin_unlock_bh(&adapter->mcc_lock); |
995 | return status; | 1067 | return status; |
996 | } | 1068 | } |
997 | 1069 | ||
1070 | /* Uses mbox */ | ||
998 | int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num) | 1071 | int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num) |
999 | { | 1072 | { |
1000 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 1073 | struct be_mcc_wrb *wrb; |
1001 | struct be_cmd_req_query_fw_cfg *req = embedded_payload(wrb); | 1074 | struct be_cmd_req_query_fw_cfg *req; |
1002 | int status; | 1075 | int status; |
1003 | 1076 | ||
1004 | spin_lock(&adapter->mbox_lock); | 1077 | spin_lock(&adapter->mbox_lock); |
1005 | 1078 | ||
1006 | memset(wrb, 0, sizeof(*wrb)); | 1079 | wrb = wrb_from_mbox(adapter); |
1080 | req = embedded_payload(wrb); | ||
1007 | 1081 | ||
1008 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 1082 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
1009 | 1083 | ||
1010 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 1084 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
1011 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req)); | 1085 | OPCODE_COMMON_QUERY_FIRMWARE_CONFIG, sizeof(*req)); |
1012 | 1086 | ||
1013 | status = be_mbox_notify(adapter); | 1087 | status = be_mbox_notify_wait(adapter); |
1014 | if (!status) { | 1088 | if (!status) { |
1015 | struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); | 1089 | struct be_cmd_resp_query_fw_cfg *resp = embedded_payload(wrb); |
1016 | *port_num = le32_to_cpu(resp->phys_port); | 1090 | *port_num = le32_to_cpu(resp->phys_port); |
@@ -1020,22 +1094,24 @@ int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num) | |||
1020 | return status; | 1094 | return status; |
1021 | } | 1095 | } |
1022 | 1096 | ||
1097 | /* Uses mbox */ | ||
1023 | int be_cmd_reset_function(struct be_adapter *adapter) | 1098 | int be_cmd_reset_function(struct be_adapter *adapter) |
1024 | { | 1099 | { |
1025 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 1100 | struct be_mcc_wrb *wrb; |
1026 | struct be_cmd_req_hdr *req = embedded_payload(wrb); | 1101 | struct be_cmd_req_hdr *req; |
1027 | int status; | 1102 | int status; |
1028 | 1103 | ||
1029 | spin_lock(&adapter->mbox_lock); | 1104 | spin_lock(&adapter->mbox_lock); |
1030 | 1105 | ||
1031 | memset(wrb, 0, sizeof(*wrb)); | 1106 | wrb = wrb_from_mbox(adapter); |
1107 | req = embedded_payload(wrb); | ||
1032 | 1108 | ||
1033 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); | 1109 | be_wrb_hdr_prepare(wrb, sizeof(*req), true, 0); |
1034 | 1110 | ||
1035 | be_cmd_hdr_prepare(req, CMD_SUBSYSTEM_COMMON, | 1111 | be_cmd_hdr_prepare(req, CMD_SUBSYSTEM_COMMON, |
1036 | OPCODE_COMMON_FUNCTION_RESET, sizeof(*req)); | 1112 | OPCODE_COMMON_FUNCTION_RESET, sizeof(*req)); |
1037 | 1113 | ||
1038 | status = be_mbox_notify(adapter); | 1114 | status = be_mbox_notify_wait(adapter); |
1039 | 1115 | ||
1040 | spin_unlock(&adapter->mbox_lock); | 1116 | spin_unlock(&adapter->mbox_lock); |
1041 | return status; | 1117 | return status; |
@@ -1044,13 +1120,17 @@ int be_cmd_reset_function(struct be_adapter *adapter) | |||
1044 | int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, | 1120 | int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, |
1045 | u32 flash_type, u32 flash_opcode, u32 buf_size) | 1121 | u32 flash_type, u32 flash_opcode, u32 buf_size) |
1046 | { | 1122 | { |
1047 | struct be_mcc_wrb *wrb = wrb_from_mbox(&adapter->mbox_mem); | 1123 | struct be_mcc_wrb *wrb; |
1048 | struct be_cmd_write_flashrom *req = cmd->va; | 1124 | struct be_cmd_write_flashrom *req = cmd->va; |
1049 | struct be_sge *sge = nonembedded_sgl(wrb); | 1125 | struct be_sge *sge; |
1050 | int status; | 1126 | int status; |
1051 | 1127 | ||
1052 | spin_lock(&adapter->mbox_lock); | 1128 | spin_lock_bh(&adapter->mcc_lock); |
1053 | memset(wrb, 0, sizeof(*wrb)); | 1129 | |
1130 | wrb = wrb_from_mccq(adapter); | ||
1131 | req = embedded_payload(wrb); | ||
1132 | sge = nonembedded_sgl(wrb); | ||
1133 | |||
1054 | be_wrb_hdr_prepare(wrb, cmd->size, false, 1); | 1134 | be_wrb_hdr_prepare(wrb, cmd->size, false, 1); |
1055 | 1135 | ||
1056 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, | 1136 | be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, |
@@ -1063,8 +1143,8 @@ int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd, | |||
1063 | req->params.op_code = cpu_to_le32(flash_opcode); | 1143 | req->params.op_code = cpu_to_le32(flash_opcode); |
1064 | req->params.data_buf_size = cpu_to_le32(buf_size); | 1144 | req->params.data_buf_size = cpu_to_le32(buf_size); |
1065 | 1145 | ||
1066 | status = be_mbox_notify(adapter); | 1146 | status = be_mcc_notify_wait(adapter); |
1067 | 1147 | ||
1068 | spin_unlock(&adapter->mbox_lock); | 1148 | spin_unlock_bh(&adapter->mcc_lock); |
1069 | return status; | 1149 | return status; |
1070 | } | 1150 | } |
diff --git a/drivers/net/benet/be_cmds.h b/drivers/net/benet/be_cmds.h index fd7028e5b78e..93e432f3d926 100644 --- a/drivers/net/benet/be_cmds.h +++ b/drivers/net/benet/be_cmds.h | |||
@@ -61,7 +61,8 @@ enum { | |||
61 | /* The command is completing because the queue was getting flushed */ | 61 | /* The command is completing because the queue was getting flushed */ |
62 | MCC_STATUS_QUEUE_FLUSHING = 0x4, | 62 | MCC_STATUS_QUEUE_FLUSHING = 0x4, |
63 | /* The command is completing with a DMA error */ | 63 | /* The command is completing with a DMA error */ |
64 | MCC_STATUS_DMA_FAILED = 0x5 | 64 | MCC_STATUS_DMA_FAILED = 0x5, |
65 | MCC_STATUS_NOT_SUPPORTED = 0x66 | ||
65 | }; | 66 | }; |
66 | 67 | ||
67 | #define CQE_STATUS_COMPL_MASK 0xFFFF | 68 | #define CQE_STATUS_COMPL_MASK 0xFFFF |
@@ -761,7 +762,7 @@ extern int be_cmd_get_flow_control(struct be_adapter *adapter, | |||
761 | u32 *tx_fc, u32 *rx_fc); | 762 | u32 *tx_fc, u32 *rx_fc); |
762 | extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num); | 763 | extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num); |
763 | extern int be_cmd_reset_function(struct be_adapter *adapter); | 764 | extern int be_cmd_reset_function(struct be_adapter *adapter); |
764 | extern void be_process_mcc(struct be_adapter *adapter); | 765 | extern int be_process_mcc(struct be_adapter *adapter); |
765 | extern int be_cmd_write_flashrom(struct be_adapter *adapter, | 766 | extern int be_cmd_write_flashrom(struct be_adapter *adapter, |
766 | struct be_dma_mem *cmd, u32 flash_oper, | 767 | struct be_dma_mem *cmd, u32 flash_oper, |
767 | u32 flash_opcode, u32 buf_size); | 768 | u32 flash_opcode, u32 buf_size); |
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index ce11bba2cb67..409cf0595903 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -135,7 +135,7 @@ static int be_mac_addr_set(struct net_device *netdev, void *p) | |||
135 | return status; | 135 | return status; |
136 | } | 136 | } |
137 | 137 | ||
138 | static void netdev_stats_update(struct be_adapter *adapter) | 138 | void netdev_stats_update(struct be_adapter *adapter) |
139 | { | 139 | { |
140 | struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats.cmd.va); | 140 | struct be_hw_stats *hw_stats = hw_stats_from_cmd(adapter->stats.cmd.va); |
141 | struct be_rxf_stats *rxf_stats = &hw_stats->rxf; | 141 | struct be_rxf_stats *rxf_stats = &hw_stats->rxf; |
@@ -431,8 +431,7 @@ static int make_tx_wrbs(struct be_adapter *adapter, | |||
431 | } | 431 | } |
432 | 432 | ||
433 | static netdev_tx_t be_xmit(struct sk_buff *skb, | 433 | static netdev_tx_t be_xmit(struct sk_buff *skb, |
434 | struct net_device *netdev) | 434 | struct net_device *netdev) |
435 | |||
436 | { | 435 | { |
437 | struct be_adapter *adapter = netdev_priv(netdev); | 436 | struct be_adapter *adapter = netdev_priv(netdev); |
438 | struct be_tx_obj *tx_obj = &adapter->tx_obj; | 437 | struct be_tx_obj *tx_obj = &adapter->tx_obj; |
@@ -490,11 +489,11 @@ static int be_change_mtu(struct net_device *netdev, int new_mtu) | |||
490 | * program them in BE. If more than BE_NUM_VLANS_SUPPORTED are configured, | 489 | * program them in BE. If more than BE_NUM_VLANS_SUPPORTED are configured, |
491 | * set the BE in promiscuous VLAN mode. | 490 | * set the BE in promiscuous VLAN mode. |
492 | */ | 491 | */ |
493 | static void be_vid_config(struct net_device *netdev) | 492 | static int be_vid_config(struct be_adapter *adapter) |
494 | { | 493 | { |
495 | struct be_adapter *adapter = netdev_priv(netdev); | ||
496 | u16 vtag[BE_NUM_VLANS_SUPPORTED]; | 494 | u16 vtag[BE_NUM_VLANS_SUPPORTED]; |
497 | u16 ntags = 0, i; | 495 | u16 ntags = 0, i; |
496 | int status; | ||
498 | 497 | ||
499 | if (adapter->num_vlans <= BE_NUM_VLANS_SUPPORTED) { | 498 | if (adapter->num_vlans <= BE_NUM_VLANS_SUPPORTED) { |
500 | /* Construct VLAN Table to give to HW */ | 499 | /* Construct VLAN Table to give to HW */ |
@@ -504,12 +503,13 @@ static void be_vid_config(struct net_device *netdev) | |||
504 | ntags++; | 503 | ntags++; |
505 | } | 504 | } |
506 | } | 505 | } |
507 | be_cmd_vlan_config(adapter, adapter->if_handle, | 506 | status = be_cmd_vlan_config(adapter, adapter->if_handle, |
508 | vtag, ntags, 1, 0); | 507 | vtag, ntags, 1, 0); |
509 | } else { | 508 | } else { |
510 | be_cmd_vlan_config(adapter, adapter->if_handle, | 509 | status = be_cmd_vlan_config(adapter, adapter->if_handle, |
511 | NULL, 0, 1, 1); | 510 | NULL, 0, 1, 1); |
512 | } | 511 | } |
512 | return status; | ||
513 | } | 513 | } |
514 | 514 | ||
515 | static void be_vlan_register(struct net_device *netdev, struct vlan_group *grp) | 515 | static void be_vlan_register(struct net_device *netdev, struct vlan_group *grp) |
@@ -532,7 +532,7 @@ static void be_vlan_add_vid(struct net_device *netdev, u16 vid) | |||
532 | adapter->num_vlans++; | 532 | adapter->num_vlans++; |
533 | adapter->vlan_tag[vid] = 1; | 533 | adapter->vlan_tag[vid] = 1; |
534 | 534 | ||
535 | be_vid_config(netdev); | 535 | be_vid_config(adapter); |
536 | } | 536 | } |
537 | 537 | ||
538 | static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) | 538 | static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) |
@@ -543,7 +543,7 @@ static void be_vlan_rem_vid(struct net_device *netdev, u16 vid) | |||
543 | adapter->vlan_tag[vid] = 0; | 543 | adapter->vlan_tag[vid] = 0; |
544 | 544 | ||
545 | vlan_group_set_device(adapter->vlan_grp, vid, NULL); | 545 | vlan_group_set_device(adapter->vlan_grp, vid, NULL); |
546 | be_vid_config(netdev); | 546 | be_vid_config(adapter); |
547 | } | 547 | } |
548 | 548 | ||
549 | static void be_set_multicast_list(struct net_device *netdev) | 549 | static void be_set_multicast_list(struct net_device *netdev) |
@@ -1444,12 +1444,8 @@ static void be_worker(struct work_struct *work) | |||
1444 | { | 1444 | { |
1445 | struct be_adapter *adapter = | 1445 | struct be_adapter *adapter = |
1446 | container_of(work, struct be_adapter, work.work); | 1446 | container_of(work, struct be_adapter, work.work); |
1447 | int status; | ||
1448 | 1447 | ||
1449 | /* Get Stats */ | 1448 | be_cmd_get_stats(adapter, &adapter->stats.cmd); |
1450 | status = be_cmd_get_stats(adapter, &adapter->stats.cmd); | ||
1451 | if (!status) | ||
1452 | netdev_stats_update(adapter); | ||
1453 | 1449 | ||
1454 | /* Set EQ delay */ | 1450 | /* Set EQ delay */ |
1455 | be_rx_eqd_update(adapter); | 1451 | be_rx_eqd_update(adapter); |
@@ -1622,11 +1618,6 @@ static int be_setup(struct be_adapter *adapter) | |||
1622 | if (status != 0) | 1618 | if (status != 0) |
1623 | goto do_none; | 1619 | goto do_none; |
1624 | 1620 | ||
1625 | be_vid_config(netdev); | ||
1626 | |||
1627 | status = be_cmd_set_flow_control(adapter, true, true); | ||
1628 | if (status != 0) | ||
1629 | goto if_destroy; | ||
1630 | 1621 | ||
1631 | status = be_tx_queues_create(adapter); | 1622 | status = be_tx_queues_create(adapter); |
1632 | if (status != 0) | 1623 | if (status != 0) |
@@ -1640,8 +1631,17 @@ static int be_setup(struct be_adapter *adapter) | |||
1640 | if (status != 0) | 1631 | if (status != 0) |
1641 | goto rx_qs_destroy; | 1632 | goto rx_qs_destroy; |
1642 | 1633 | ||
1634 | status = be_vid_config(adapter); | ||
1635 | if (status != 0) | ||
1636 | goto mccqs_destroy; | ||
1637 | |||
1638 | status = be_cmd_set_flow_control(adapter, true, true); | ||
1639 | if (status != 0) | ||
1640 | goto mccqs_destroy; | ||
1643 | return 0; | 1641 | return 0; |
1644 | 1642 | ||
1643 | mccqs_destroy: | ||
1644 | be_mcc_queues_destroy(adapter); | ||
1645 | rx_qs_destroy: | 1645 | rx_qs_destroy: |
1646 | be_rx_queues_destroy(adapter); | 1646 | be_rx_queues_destroy(adapter); |
1647 | tx_qs_destroy: | 1647 | tx_qs_destroy: |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index a7e731f8a0da..69c5b15e22da 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -1093,15 +1093,8 @@ static struct slave *bond_find_best_slave(struct bonding *bond) | |||
1093 | return NULL; /* still no slave, return NULL */ | 1093 | return NULL; /* still no slave, return NULL */ |
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | /* | ||
1097 | * first try the primary link; if arping, a link must tx/rx | ||
1098 | * traffic before it can be considered the curr_active_slave. | ||
1099 | * also, we would skip slaves between the curr_active_slave | ||
1100 | * and primary_slave that may be up and able to arp | ||
1101 | */ | ||
1102 | if ((bond->primary_slave) && | 1096 | if ((bond->primary_slave) && |
1103 | (!bond->params.arp_interval) && | 1097 | bond->primary_slave->link == BOND_LINK_UP) { |
1104 | (IS_UP(bond->primary_slave->dev))) { | ||
1105 | new_active = bond->primary_slave; | 1098 | new_active = bond->primary_slave; |
1106 | } | 1099 | } |
1107 | 1100 | ||
@@ -1109,15 +1102,14 @@ static struct slave *bond_find_best_slave(struct bonding *bond) | |||
1109 | old_active = new_active; | 1102 | old_active = new_active; |
1110 | 1103 | ||
1111 | bond_for_each_slave_from(bond, new_active, i, old_active) { | 1104 | bond_for_each_slave_from(bond, new_active, i, old_active) { |
1112 | if (IS_UP(new_active->dev)) { | 1105 | if (new_active->link == BOND_LINK_UP) { |
1113 | if (new_active->link == BOND_LINK_UP) { | 1106 | return new_active; |
1114 | return new_active; | 1107 | } else if (new_active->link == BOND_LINK_BACK && |
1115 | } else if (new_active->link == BOND_LINK_BACK) { | 1108 | IS_UP(new_active->dev)) { |
1116 | /* link up, but waiting for stabilization */ | 1109 | /* link up, but waiting for stabilization */ |
1117 | if (new_active->delay < mintime) { | 1110 | if (new_active->delay < mintime) { |
1118 | mintime = new_active->delay; | 1111 | mintime = new_active->delay; |
1119 | bestslave = new_active; | 1112 | bestslave = new_active; |
1120 | } | ||
1121 | } | 1113 | } |
1122 | } | 1114 | } |
1123 | } | 1115 | } |
@@ -1211,7 +1203,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
1211 | write_unlock_bh(&bond->curr_slave_lock); | 1203 | write_unlock_bh(&bond->curr_slave_lock); |
1212 | read_unlock(&bond->lock); | 1204 | read_unlock(&bond->lock); |
1213 | 1205 | ||
1214 | netdev_bonding_change(bond->dev); | 1206 | netdev_bonding_change(bond->dev, NETDEV_BONDING_FAILOVER); |
1215 | 1207 | ||
1216 | read_lock(&bond->lock); | 1208 | read_lock(&bond->lock); |
1217 | write_lock_bh(&bond->curr_slave_lock); | 1209 | write_lock_bh(&bond->curr_slave_lock); |
@@ -1469,14 +1461,17 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1469 | */ | 1461 | */ |
1470 | if (bond->slave_cnt == 0) { | 1462 | if (bond->slave_cnt == 0) { |
1471 | if (bond_dev->type != slave_dev->type) { | 1463 | if (bond_dev->type != slave_dev->type) { |
1472 | dev_close(bond_dev); | ||
1473 | pr_debug("%s: change device type from %d to %d\n", | 1464 | pr_debug("%s: change device type from %d to %d\n", |
1474 | bond_dev->name, bond_dev->type, slave_dev->type); | 1465 | bond_dev->name, bond_dev->type, slave_dev->type); |
1466 | |||
1467 | netdev_bonding_change(bond_dev, NETDEV_BONDING_OLDTYPE); | ||
1468 | |||
1475 | if (slave_dev->type != ARPHRD_ETHER) | 1469 | if (slave_dev->type != ARPHRD_ETHER) |
1476 | bond_setup_by_slave(bond_dev, slave_dev); | 1470 | bond_setup_by_slave(bond_dev, slave_dev); |
1477 | else | 1471 | else |
1478 | ether_setup(bond_dev); | 1472 | ether_setup(bond_dev); |
1479 | dev_open(bond_dev); | 1473 | |
1474 | netdev_bonding_change(bond_dev, NETDEV_BONDING_NEWTYPE); | ||
1480 | } | 1475 | } |
1481 | } else if (bond_dev->type != slave_dev->type) { | 1476 | } else if (bond_dev->type != slave_dev->type) { |
1482 | pr_err(DRV_NAME ": %s ether type (%d) is different " | 1477 | pr_err(DRV_NAME ": %s ether type (%d) is different " |
@@ -2929,18 +2924,6 @@ static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks) | |||
2929 | } | 2924 | } |
2930 | } | 2925 | } |
2931 | 2926 | ||
2932 | read_lock(&bond->curr_slave_lock); | ||
2933 | |||
2934 | /* | ||
2935 | * Trigger a commit if the primary option setting has changed. | ||
2936 | */ | ||
2937 | if (bond->primary_slave && | ||
2938 | (bond->primary_slave != bond->curr_active_slave) && | ||
2939 | (bond->primary_slave->link == BOND_LINK_UP)) | ||
2940 | commit++; | ||
2941 | |||
2942 | read_unlock(&bond->curr_slave_lock); | ||
2943 | |||
2944 | return commit; | 2927 | return commit; |
2945 | } | 2928 | } |
2946 | 2929 | ||
@@ -2961,90 +2944,58 @@ static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks) | |||
2961 | continue; | 2944 | continue; |
2962 | 2945 | ||
2963 | case BOND_LINK_UP: | 2946 | case BOND_LINK_UP: |
2964 | write_lock_bh(&bond->curr_slave_lock); | 2947 | if ((!bond->curr_active_slave && |
2965 | 2948 | time_before_eq(jiffies, | |
2966 | if (!bond->curr_active_slave && | 2949 | dev_trans_start(slave->dev) + |
2967 | time_before_eq(jiffies, dev_trans_start(slave->dev) + | 2950 | delta_in_ticks)) || |
2968 | delta_in_ticks)) { | 2951 | bond->curr_active_slave != slave) { |
2969 | slave->link = BOND_LINK_UP; | 2952 | slave->link = BOND_LINK_UP; |
2970 | bond_change_active_slave(bond, slave); | ||
2971 | bond->current_arp_slave = NULL; | 2953 | bond->current_arp_slave = NULL; |
2972 | 2954 | ||
2973 | pr_info(DRV_NAME | 2955 | pr_info(DRV_NAME |
2974 | ": %s: %s is up and now the " | 2956 | ": %s: link status definitely " |
2975 | "active interface\n", | 2957 | "up for interface %s.\n", |
2976 | bond->dev->name, slave->dev->name); | 2958 | bond->dev->name, slave->dev->name); |
2977 | |||
2978 | } else if (bond->curr_active_slave != slave) { | ||
2979 | /* this slave has just come up but we | ||
2980 | * already have a current slave; this can | ||
2981 | * also happen if bond_enslave adds a new | ||
2982 | * slave that is up while we are searching | ||
2983 | * for a new slave | ||
2984 | */ | ||
2985 | slave->link = BOND_LINK_UP; | ||
2986 | bond_set_slave_inactive_flags(slave); | ||
2987 | bond->current_arp_slave = NULL; | ||
2988 | 2959 | ||
2989 | pr_info(DRV_NAME | 2960 | if (!bond->curr_active_slave || |
2990 | ": %s: backup interface %s is now up\n", | 2961 | (slave == bond->primary_slave)) |
2991 | bond->dev->name, slave->dev->name); | 2962 | goto do_failover; |
2992 | } | ||
2993 | 2963 | ||
2994 | write_unlock_bh(&bond->curr_slave_lock); | 2964 | } |
2995 | 2965 | ||
2996 | break; | 2966 | continue; |
2997 | 2967 | ||
2998 | case BOND_LINK_DOWN: | 2968 | case BOND_LINK_DOWN: |
2999 | if (slave->link_failure_count < UINT_MAX) | 2969 | if (slave->link_failure_count < UINT_MAX) |
3000 | slave->link_failure_count++; | 2970 | slave->link_failure_count++; |
3001 | 2971 | ||
3002 | slave->link = BOND_LINK_DOWN; | 2972 | slave->link = BOND_LINK_DOWN; |
2973 | bond_set_slave_inactive_flags(slave); | ||
3003 | 2974 | ||
3004 | if (slave == bond->curr_active_slave) { | 2975 | pr_info(DRV_NAME |
3005 | pr_info(DRV_NAME | 2976 | ": %s: link status definitely down for " |
3006 | ": %s: link status down for active " | 2977 | "interface %s, disabling it\n", |
3007 | "interface %s, disabling it\n", | 2978 | bond->dev->name, slave->dev->name); |
3008 | bond->dev->name, slave->dev->name); | ||
3009 | |||
3010 | bond_set_slave_inactive_flags(slave); | ||
3011 | |||
3012 | write_lock_bh(&bond->curr_slave_lock); | ||
3013 | |||
3014 | bond_select_active_slave(bond); | ||
3015 | if (bond->curr_active_slave) | ||
3016 | bond->curr_active_slave->jiffies = | ||
3017 | jiffies; | ||
3018 | |||
3019 | write_unlock_bh(&bond->curr_slave_lock); | ||
3020 | 2979 | ||
2980 | if (slave == bond->curr_active_slave) { | ||
3021 | bond->current_arp_slave = NULL; | 2981 | bond->current_arp_slave = NULL; |
3022 | 2982 | goto do_failover; | |
3023 | } else if (slave->state == BOND_STATE_BACKUP) { | ||
3024 | pr_info(DRV_NAME | ||
3025 | ": %s: backup interface %s is now down\n", | ||
3026 | bond->dev->name, slave->dev->name); | ||
3027 | |||
3028 | bond_set_slave_inactive_flags(slave); | ||
3029 | } | 2983 | } |
3030 | break; | 2984 | |
2985 | continue; | ||
3031 | 2986 | ||
3032 | default: | 2987 | default: |
3033 | pr_err(DRV_NAME | 2988 | pr_err(DRV_NAME |
3034 | ": %s: impossible: new_link %d on slave %s\n", | 2989 | ": %s: impossible: new_link %d on slave %s\n", |
3035 | bond->dev->name, slave->new_link, | 2990 | bond->dev->name, slave->new_link, |
3036 | slave->dev->name); | 2991 | slave->dev->name); |
2992 | continue; | ||
3037 | } | 2993 | } |
3038 | } | ||
3039 | 2994 | ||
3040 | /* | 2995 | do_failover: |
3041 | * No race with changes to primary via sysfs, as we hold rtnl. | 2996 | ASSERT_RTNL(); |
3042 | */ | ||
3043 | if (bond->primary_slave && | ||
3044 | (bond->primary_slave != bond->curr_active_slave) && | ||
3045 | (bond->primary_slave->link == BOND_LINK_UP)) { | ||
3046 | write_lock_bh(&bond->curr_slave_lock); | 2997 | write_lock_bh(&bond->curr_slave_lock); |
3047 | bond_change_active_slave(bond, bond->primary_slave); | 2998 | bond_select_active_slave(bond); |
3048 | write_unlock_bh(&bond->curr_slave_lock); | 2999 | write_unlock_bh(&bond->curr_slave_lock); |
3049 | } | 3000 | } |
3050 | 3001 | ||
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig index 090074372462..df32c109b7ac 100644 --- a/drivers/net/can/Kconfig +++ b/drivers/net/can/Kconfig | |||
@@ -75,6 +75,13 @@ config CAN_EMS_PCI | |||
75 | CPC-PCIe and CPC-104P cards from EMS Dr. Thomas Wuensche | 75 | CPC-PCIe and CPC-104P cards from EMS Dr. Thomas Wuensche |
76 | (http://www.ems-wuensche.de). | 76 | (http://www.ems-wuensche.de). |
77 | 77 | ||
78 | config CAN_EMS_USB | ||
79 | tristate "EMS CPC-USB/ARM7 CAN/USB interface" | ||
80 | depends on USB && CAN_DEV | ||
81 | ---help--- | ||
82 | This driver is for the one channel CPC-USB/ARM7 CAN/USB interface | ||
83 | from from EMS Dr. Thomas Wuensche (http://www.ems-wuensche.de). | ||
84 | |||
78 | config CAN_KVASER_PCI | 85 | config CAN_KVASER_PCI |
79 | tristate "Kvaser PCIcanx and Kvaser PCIcan PCI Cards" | 86 | tristate "Kvaser PCIcanx and Kvaser PCIcan PCI Cards" |
80 | depends on PCI && CAN_SJA1000 | 87 | depends on PCI && CAN_SJA1000 |
@@ -82,6 +89,12 @@ config CAN_KVASER_PCI | |||
82 | This driver is for the the PCIcanx and PCIcan cards (1, 2 or | 89 | This driver is for the the PCIcanx and PCIcan cards (1, 2 or |
83 | 4 channel) from Kvaser (http://www.kvaser.com). | 90 | 4 channel) from Kvaser (http://www.kvaser.com). |
84 | 91 | ||
92 | config CAN_AT91 | ||
93 | tristate "Atmel AT91 onchip CAN controller" | ||
94 | depends on CAN && CAN_DEV && ARCH_AT91SAM9263 | ||
95 | ---help--- | ||
96 | This is a driver for the SoC CAN controller in Atmel's AT91SAM9263. | ||
97 | |||
85 | config CAN_DEBUG_DEVICES | 98 | config CAN_DEBUG_DEVICES |
86 | bool "CAN devices debugging messages" | 99 | bool "CAN devices debugging messages" |
87 | depends on CAN | 100 | depends on CAN |
diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile index 523a941b358b..0dea62721f2f 100644 --- a/drivers/net/can/Makefile +++ b/drivers/net/can/Makefile | |||
@@ -7,6 +7,9 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o | |||
7 | obj-$(CONFIG_CAN_DEV) += can-dev.o | 7 | obj-$(CONFIG_CAN_DEV) += can-dev.o |
8 | can-dev-y := dev.o | 8 | can-dev-y := dev.o |
9 | 9 | ||
10 | obj-y += usb/ | ||
11 | |||
10 | obj-$(CONFIG_CAN_SJA1000) += sja1000/ | 12 | obj-$(CONFIG_CAN_SJA1000) += sja1000/ |
13 | obj-$(CONFIG_CAN_AT91) += at91_can.o | ||
11 | 14 | ||
12 | ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG | 15 | ccflags-$(CONFIG_CAN_DEBUG_DEVICES) := -DDEBUG |
diff --git a/drivers/net/can/usb/Makefile b/drivers/net/can/usb/Makefile new file mode 100644 index 000000000000..c3f75ba701b1 --- /dev/null +++ b/drivers/net/can/usb/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # | ||
2 | # Makefile for the Linux Controller Area Network USB drivers. | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_CAN_EMS_USB) += ems_usb.o | ||
diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c new file mode 100644 index 000000000000..9012e0abc626 --- /dev/null +++ b/drivers/net/can/usb/ems_usb.c | |||
@@ -0,0 +1,1155 @@ | |||
1 | /* | ||
2 | * CAN driver for EMS Dr. Thomas Wuensche CPC-USB/ARM7 | ||
3 | * | ||
4 | * Copyright (C) 2004-2009 EMS Dr. Thomas Wuensche | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published | ||
8 | * by the Free Software Foundation; version 2 of the License. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/signal.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/netdevice.h> | ||
24 | #include <linux/usb.h> | ||
25 | |||
26 | #include <linux/can.h> | ||
27 | #include <linux/can/dev.h> | ||
28 | #include <linux/can/error.h> | ||
29 | |||
30 | MODULE_AUTHOR("Sebastian Haas <haas@ems-wuensche.com>"); | ||
31 | MODULE_DESCRIPTION("CAN driver for EMS Dr. Thomas Wuensche CAN/USB interfaces"); | ||
32 | MODULE_LICENSE("GPL v2"); | ||
33 | |||
34 | /* Control-Values for CPC_Control() Command Subject Selection */ | ||
35 | #define CONTR_CAN_MESSAGE 0x04 | ||
36 | #define CONTR_CAN_STATE 0x0C | ||
37 | #define CONTR_BUS_ERROR 0x1C | ||
38 | |||
39 | /* Control Command Actions */ | ||
40 | #define CONTR_CONT_OFF 0 | ||
41 | #define CONTR_CONT_ON 1 | ||
42 | #define CONTR_ONCE 2 | ||
43 | |||
44 | /* Messages from CPC to PC */ | ||
45 | #define CPC_MSG_TYPE_CAN_FRAME 1 /* CAN data frame */ | ||
46 | #define CPC_MSG_TYPE_RTR_FRAME 8 /* CAN remote frame */ | ||
47 | #define CPC_MSG_TYPE_CAN_PARAMS 12 /* Actual CAN parameters */ | ||
48 | #define CPC_MSG_TYPE_CAN_STATE 14 /* CAN state message */ | ||
49 | #define CPC_MSG_TYPE_EXT_CAN_FRAME 16 /* Extended CAN data frame */ | ||
50 | #define CPC_MSG_TYPE_EXT_RTR_FRAME 17 /* Extended remote frame */ | ||
51 | #define CPC_MSG_TYPE_CONTROL 19 /* change interface behavior */ | ||
52 | #define CPC_MSG_TYPE_CONFIRM 20 /* command processed confirmation */ | ||
53 | #define CPC_MSG_TYPE_OVERRUN 21 /* overrun events */ | ||
54 | #define CPC_MSG_TYPE_CAN_FRAME_ERROR 23 /* detected bus errors */ | ||
55 | #define CPC_MSG_TYPE_ERR_COUNTER 25 /* RX/TX error counter */ | ||
56 | |||
57 | /* Messages from the PC to the CPC interface */ | ||
58 | #define CPC_CMD_TYPE_CAN_FRAME 1 /* CAN data frame */ | ||
59 | #define CPC_CMD_TYPE_CONTROL 3 /* control of interface behavior */ | ||
60 | #define CPC_CMD_TYPE_CAN_PARAMS 6 /* set CAN parameters */ | ||
61 | #define CPC_CMD_TYPE_RTR_FRAME 13 /* CAN remote frame */ | ||
62 | #define CPC_CMD_TYPE_CAN_STATE 14 /* CAN state message */ | ||
63 | #define CPC_CMD_TYPE_EXT_CAN_FRAME 15 /* Extended CAN data frame */ | ||
64 | #define CPC_CMD_TYPE_EXT_RTR_FRAME 16 /* Extended CAN remote frame */ | ||
65 | #define CPC_CMD_TYPE_CAN_EXIT 200 /* exit the CAN */ | ||
66 | |||
67 | #define CPC_CMD_TYPE_INQ_ERR_COUNTER 25 /* request the CAN error counters */ | ||
68 | #define CPC_CMD_TYPE_CLEAR_MSG_QUEUE 8 /* clear CPC_MSG queue */ | ||
69 | #define CPC_CMD_TYPE_CLEAR_CMD_QUEUE 28 /* clear CPC_CMD queue */ | ||
70 | |||
71 | #define CPC_CC_TYPE_SJA1000 2 /* Philips basic CAN controller */ | ||
72 | |||
73 | #define CPC_CAN_ECODE_ERRFRAME 0x01 /* Ecode type */ | ||
74 | |||
75 | /* Overrun types */ | ||
76 | #define CPC_OVR_EVENT_CAN 0x01 | ||
77 | #define CPC_OVR_EVENT_CANSTATE 0x02 | ||
78 | #define CPC_OVR_EVENT_BUSERROR 0x04 | ||
79 | |||
80 | /* | ||
81 | * If the CAN controller lost a message we indicate it with the highest bit | ||
82 | * set in the count field. | ||
83 | */ | ||
84 | #define CPC_OVR_HW 0x80 | ||
85 | |||
86 | /* Size of the "struct ems_cpc_msg" without the union */ | ||
87 | #define CPC_MSG_HEADER_LEN 11 | ||
88 | #define CPC_CAN_MSG_MIN_SIZE 5 | ||
89 | |||
90 | /* Define these values to match your devices */ | ||
91 | #define USB_CPCUSB_VENDOR_ID 0x12D6 | ||
92 | |||
93 | #define USB_CPCUSB_ARM7_PRODUCT_ID 0x0444 | ||
94 | |||
95 | /* Mode register NXP LPC2119/SJA1000 CAN Controller */ | ||
96 | #define SJA1000_MOD_NORMAL 0x00 | ||
97 | #define SJA1000_MOD_RM 0x01 | ||
98 | |||
99 | /* ECC register NXP LPC2119/SJA1000 CAN Controller */ | ||
100 | #define SJA1000_ECC_SEG 0x1F | ||
101 | #define SJA1000_ECC_DIR 0x20 | ||
102 | #define SJA1000_ECC_ERR 0x06 | ||
103 | #define SJA1000_ECC_BIT 0x00 | ||
104 | #define SJA1000_ECC_FORM 0x40 | ||
105 | #define SJA1000_ECC_STUFF 0x80 | ||
106 | #define SJA1000_ECC_MASK 0xc0 | ||
107 | |||
108 | /* Status register content */ | ||
109 | #define SJA1000_SR_BS 0x80 | ||
110 | #define SJA1000_SR_ES 0x40 | ||
111 | |||
112 | #define SJA1000_DEFAULT_OUTPUT_CONTROL 0xDA | ||
113 | |||
114 | /* | ||
115 | * The device actually uses a 16MHz clock to generate the CAN clock | ||
116 | * but it expects SJA1000 bit settings based on 8MHz (is internally | ||
117 | * converted). | ||
118 | */ | ||
119 | #define EMS_USB_ARM7_CLOCK 8000000 | ||
120 | |||
121 | /* | ||
122 | * CAN-Message representation in a CPC_MSG. Message object type is | ||
123 | * CPC_MSG_TYPE_CAN_FRAME or CPC_MSG_TYPE_RTR_FRAME or | ||
124 | * CPC_MSG_TYPE_EXT_CAN_FRAME or CPC_MSG_TYPE_EXT_RTR_FRAME. | ||
125 | */ | ||
126 | struct cpc_can_msg { | ||
127 | u32 id; | ||
128 | u8 length; | ||
129 | u8 msg[8]; | ||
130 | }; | ||
131 | |||
132 | /* Representation of the CAN parameters for the SJA1000 controller */ | ||
133 | struct cpc_sja1000_params { | ||
134 | u8 mode; | ||
135 | u8 acc_code0; | ||
136 | u8 acc_code1; | ||
137 | u8 acc_code2; | ||
138 | u8 acc_code3; | ||
139 | u8 acc_mask0; | ||
140 | u8 acc_mask1; | ||
141 | u8 acc_mask2; | ||
142 | u8 acc_mask3; | ||
143 | u8 btr0; | ||
144 | u8 btr1; | ||
145 | u8 outp_contr; | ||
146 | }; | ||
147 | |||
148 | /* CAN params message representation */ | ||
149 | struct cpc_can_params { | ||
150 | u8 cc_type; | ||
151 | |||
152 | /* Will support M16C CAN controller in the future */ | ||
153 | union { | ||
154 | struct cpc_sja1000_params sja1000; | ||
155 | } cc_params; | ||
156 | }; | ||
157 | |||
158 | /* Structure for confirmed message handling */ | ||
159 | struct cpc_confirm { | ||
160 | u8 error; /* error code */ | ||
161 | }; | ||
162 | |||
163 | /* Structure for overrun conditions */ | ||
164 | struct cpc_overrun { | ||
165 | u8 event; | ||
166 | u8 count; | ||
167 | }; | ||
168 | |||
169 | /* SJA1000 CAN errors (compatible to NXP LPC2119) */ | ||
170 | struct cpc_sja1000_can_error { | ||
171 | u8 ecc; | ||
172 | u8 rxerr; | ||
173 | u8 txerr; | ||
174 | }; | ||
175 | |||
176 | /* structure for CAN error conditions */ | ||
177 | struct cpc_can_error { | ||
178 | u8 ecode; | ||
179 | |||
180 | struct { | ||
181 | u8 cc_type; | ||
182 | |||
183 | /* Other controllers may also provide error code capture regs */ | ||
184 | union { | ||
185 | struct cpc_sja1000_can_error sja1000; | ||
186 | } regs; | ||
187 | } cc; | ||
188 | }; | ||
189 | |||
190 | /* | ||
191 | * Structure containing RX/TX error counter. This structure is used to request | ||
192 | * the values of the CAN controllers TX and RX error counter. | ||
193 | */ | ||
194 | struct cpc_can_err_counter { | ||
195 | u8 rx; | ||
196 | u8 tx; | ||
197 | }; | ||
198 | |||
199 | /* Main message type used between library and application */ | ||
200 | struct __attribute__ ((packed)) ems_cpc_msg { | ||
201 | u8 type; /* type of message */ | ||
202 | u8 length; /* length of data within union 'msg' */ | ||
203 | u8 msgid; /* confirmation handle */ | ||
204 | u32 ts_sec; /* timestamp in seconds */ | ||
205 | u32 ts_nsec; /* timestamp in nano seconds */ | ||
206 | |||
207 | union { | ||
208 | u8 generic[64]; | ||
209 | struct cpc_can_msg can_msg; | ||
210 | struct cpc_can_params can_params; | ||
211 | struct cpc_confirm confirmation; | ||
212 | struct cpc_overrun overrun; | ||
213 | struct cpc_can_error error; | ||
214 | struct cpc_can_err_counter err_counter; | ||
215 | u8 can_state; | ||
216 | } msg; | ||
217 | }; | ||
218 | |||
219 | /* | ||
220 | * Table of devices that work with this driver | ||
221 | * NOTE: This driver supports only CPC-USB/ARM7 (LPC2119) yet. | ||
222 | */ | ||
223 | static struct usb_device_id ems_usb_table[] = { | ||
224 | {USB_DEVICE(USB_CPCUSB_VENDOR_ID, USB_CPCUSB_ARM7_PRODUCT_ID)}, | ||
225 | {} /* Terminating entry */ | ||
226 | }; | ||
227 | |||
228 | MODULE_DEVICE_TABLE(usb, ems_usb_table); | ||
229 | |||
230 | #define RX_BUFFER_SIZE 64 | ||
231 | #define CPC_HEADER_SIZE 4 | ||
232 | #define INTR_IN_BUFFER_SIZE 4 | ||
233 | |||
234 | #define MAX_RX_URBS 10 | ||
235 | #define MAX_TX_URBS CAN_ECHO_SKB_MAX | ||
236 | |||
237 | struct ems_usb; | ||
238 | |||
239 | struct ems_tx_urb_context { | ||
240 | struct ems_usb *dev; | ||
241 | |||
242 | u32 echo_index; | ||
243 | u8 dlc; | ||
244 | }; | ||
245 | |||
246 | struct ems_usb { | ||
247 | struct can_priv can; /* must be the first member */ | ||
248 | int open_time; | ||
249 | |||
250 | struct sk_buff *echo_skb[MAX_TX_URBS]; | ||
251 | |||
252 | struct usb_device *udev; | ||
253 | struct net_device *netdev; | ||
254 | |||
255 | atomic_t active_tx_urbs; | ||
256 | struct usb_anchor tx_submitted; | ||
257 | struct ems_tx_urb_context tx_contexts[MAX_TX_URBS]; | ||
258 | |||
259 | struct usb_anchor rx_submitted; | ||
260 | |||
261 | struct urb *intr_urb; | ||
262 | |||
263 | u8 *tx_msg_buffer; | ||
264 | |||
265 | u8 *intr_in_buffer; | ||
266 | unsigned int free_slots; /* remember number of available slots */ | ||
267 | |||
268 | struct ems_cpc_msg active_params; /* active controller parameters */ | ||
269 | }; | ||
270 | |||
271 | static void ems_usb_read_interrupt_callback(struct urb *urb) | ||
272 | { | ||
273 | struct ems_usb *dev = urb->context; | ||
274 | struct net_device *netdev = dev->netdev; | ||
275 | int err; | ||
276 | |||
277 | if (!netif_device_present(netdev)) | ||
278 | return; | ||
279 | |||
280 | switch (urb->status) { | ||
281 | case 0: | ||
282 | dev->free_slots = dev->intr_in_buffer[1]; | ||
283 | break; | ||
284 | |||
285 | case -ECONNRESET: /* unlink */ | ||
286 | case -ENOENT: | ||
287 | case -ESHUTDOWN: | ||
288 | return; | ||
289 | |||
290 | default: | ||
291 | dev_info(netdev->dev.parent, "Rx interrupt aborted %d\n", | ||
292 | urb->status); | ||
293 | break; | ||
294 | } | ||
295 | |||
296 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
297 | |||
298 | if (err == -ENODEV) | ||
299 | netif_device_detach(netdev); | ||
300 | else if (err) | ||
301 | dev_err(netdev->dev.parent, | ||
302 | "failed resubmitting intr urb: %d\n", err); | ||
303 | |||
304 | return; | ||
305 | } | ||
306 | |||
307 | static void ems_usb_rx_can_msg(struct ems_usb *dev, struct ems_cpc_msg *msg) | ||
308 | { | ||
309 | struct can_frame *cf; | ||
310 | struct sk_buff *skb; | ||
311 | int i; | ||
312 | struct net_device_stats *stats = &dev->netdev->stats; | ||
313 | |||
314 | skb = netdev_alloc_skb(dev->netdev, sizeof(struct can_frame)); | ||
315 | if (skb == NULL) | ||
316 | return; | ||
317 | |||
318 | skb->protocol = htons(ETH_P_CAN); | ||
319 | |||
320 | cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); | ||
321 | |||
322 | cf->can_id = msg->msg.can_msg.id; | ||
323 | cf->can_dlc = min_t(u8, msg->msg.can_msg.length, 8); | ||
324 | |||
325 | if (msg->type == CPC_MSG_TYPE_EXT_CAN_FRAME | ||
326 | || msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME) | ||
327 | cf->can_id |= CAN_EFF_FLAG; | ||
328 | |||
329 | if (msg->type == CPC_MSG_TYPE_RTR_FRAME | ||
330 | || msg->type == CPC_MSG_TYPE_EXT_RTR_FRAME) { | ||
331 | cf->can_id |= CAN_RTR_FLAG; | ||
332 | } else { | ||
333 | for (i = 0; i < cf->can_dlc; i++) | ||
334 | cf->data[i] = msg->msg.can_msg.msg[i]; | ||
335 | } | ||
336 | |||
337 | netif_rx(skb); | ||
338 | |||
339 | stats->rx_packets++; | ||
340 | stats->rx_bytes += cf->can_dlc; | ||
341 | } | ||
342 | |||
343 | static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg) | ||
344 | { | ||
345 | struct can_frame *cf; | ||
346 | struct sk_buff *skb; | ||
347 | struct net_device_stats *stats = &dev->netdev->stats; | ||
348 | |||
349 | skb = netdev_alloc_skb(dev->netdev, sizeof(struct can_frame)); | ||
350 | if (skb == NULL) | ||
351 | return; | ||
352 | |||
353 | skb->protocol = htons(ETH_P_CAN); | ||
354 | |||
355 | cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame)); | ||
356 | memset(cf, 0, sizeof(struct can_frame)); | ||
357 | |||
358 | cf->can_id = CAN_ERR_FLAG; | ||
359 | cf->can_dlc = CAN_ERR_DLC; | ||
360 | |||
361 | if (msg->type == CPC_MSG_TYPE_CAN_STATE) { | ||
362 | u8 state = msg->msg.can_state; | ||
363 | |||
364 | if (state & SJA1000_SR_BS) { | ||
365 | dev->can.state = CAN_STATE_BUS_OFF; | ||
366 | cf->can_id |= CAN_ERR_BUSOFF; | ||
367 | |||
368 | can_bus_off(dev->netdev); | ||
369 | } else if (state & SJA1000_SR_ES) { | ||
370 | dev->can.state = CAN_STATE_ERROR_WARNING; | ||
371 | dev->can.can_stats.error_warning++; | ||
372 | } else { | ||
373 | dev->can.state = CAN_STATE_ERROR_ACTIVE; | ||
374 | dev->can.can_stats.error_passive++; | ||
375 | } | ||
376 | } else if (msg->type == CPC_MSG_TYPE_CAN_FRAME_ERROR) { | ||
377 | u8 ecc = msg->msg.error.cc.regs.sja1000.ecc; | ||
378 | u8 txerr = msg->msg.error.cc.regs.sja1000.txerr; | ||
379 | u8 rxerr = msg->msg.error.cc.regs.sja1000.rxerr; | ||
380 | |||
381 | /* bus error interrupt */ | ||
382 | dev->can.can_stats.bus_error++; | ||
383 | stats->rx_errors++; | ||
384 | |||
385 | cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; | ||
386 | |||
387 | switch (ecc & SJA1000_ECC_MASK) { | ||
388 | case SJA1000_ECC_BIT: | ||
389 | cf->data[2] |= CAN_ERR_PROT_BIT; | ||
390 | break; | ||
391 | case SJA1000_ECC_FORM: | ||
392 | cf->data[2] |= CAN_ERR_PROT_FORM; | ||
393 | break; | ||
394 | case SJA1000_ECC_STUFF: | ||
395 | cf->data[2] |= CAN_ERR_PROT_STUFF; | ||
396 | break; | ||
397 | default: | ||
398 | cf->data[2] |= CAN_ERR_PROT_UNSPEC; | ||
399 | cf->data[3] = ecc & SJA1000_ECC_SEG; | ||
400 | break; | ||
401 | } | ||
402 | |||
403 | /* Error occured during transmission? */ | ||
404 | if ((ecc & SJA1000_ECC_DIR) == 0) | ||
405 | cf->data[2] |= CAN_ERR_PROT_TX; | ||
406 | |||
407 | if (dev->can.state == CAN_STATE_ERROR_WARNING || | ||
408 | dev->can.state == CAN_STATE_ERROR_PASSIVE) { | ||
409 | cf->data[1] = (txerr > rxerr) ? | ||
410 | CAN_ERR_CRTL_TX_PASSIVE : CAN_ERR_CRTL_RX_PASSIVE; | ||
411 | } | ||
412 | } else if (msg->type == CPC_MSG_TYPE_OVERRUN) { | ||
413 | cf->can_id |= CAN_ERR_CRTL; | ||
414 | cf->data[1] = CAN_ERR_CRTL_RX_OVERFLOW; | ||
415 | |||
416 | stats->rx_over_errors++; | ||
417 | stats->rx_errors++; | ||
418 | } | ||
419 | |||
420 | netif_rx(skb); | ||
421 | |||
422 | stats->rx_packets++; | ||
423 | stats->rx_bytes += cf->can_dlc; | ||
424 | } | ||
425 | |||
426 | /* | ||
427 | * callback for bulk IN urb | ||
428 | */ | ||
429 | static void ems_usb_read_bulk_callback(struct urb *urb) | ||
430 | { | ||
431 | struct ems_usb *dev = urb->context; | ||
432 | struct net_device *netdev; | ||
433 | int retval; | ||
434 | |||
435 | netdev = dev->netdev; | ||
436 | |||
437 | if (!netif_device_present(netdev)) | ||
438 | return; | ||
439 | |||
440 | switch (urb->status) { | ||
441 | case 0: /* success */ | ||
442 | break; | ||
443 | |||
444 | case -ENOENT: | ||
445 | return; | ||
446 | |||
447 | default: | ||
448 | dev_info(netdev->dev.parent, "Rx URB aborted (%d)\n", | ||
449 | urb->status); | ||
450 | goto resubmit_urb; | ||
451 | } | ||
452 | |||
453 | if (urb->actual_length > CPC_HEADER_SIZE) { | ||
454 | struct ems_cpc_msg *msg; | ||
455 | u8 *ibuf = urb->transfer_buffer; | ||
456 | u8 msg_count, again, start; | ||
457 | |||
458 | msg_count = ibuf[0] & ~0x80; | ||
459 | again = ibuf[0] & 0x80; | ||
460 | |||
461 | start = CPC_HEADER_SIZE; | ||
462 | |||
463 | while (msg_count) { | ||
464 | msg = (struct ems_cpc_msg *)&ibuf[start]; | ||
465 | |||
466 | switch (msg->type) { | ||
467 | case CPC_MSG_TYPE_CAN_STATE: | ||
468 | /* Process CAN state changes */ | ||
469 | ems_usb_rx_err(dev, msg); | ||
470 | break; | ||
471 | |||
472 | case CPC_MSG_TYPE_CAN_FRAME: | ||
473 | case CPC_MSG_TYPE_EXT_CAN_FRAME: | ||
474 | case CPC_MSG_TYPE_RTR_FRAME: | ||
475 | case CPC_MSG_TYPE_EXT_RTR_FRAME: | ||
476 | ems_usb_rx_can_msg(dev, msg); | ||
477 | break; | ||
478 | |||
479 | case CPC_MSG_TYPE_CAN_FRAME_ERROR: | ||
480 | /* Process errorframe */ | ||
481 | ems_usb_rx_err(dev, msg); | ||
482 | break; | ||
483 | |||
484 | case CPC_MSG_TYPE_OVERRUN: | ||
485 | /* Message lost while receiving */ | ||
486 | ems_usb_rx_err(dev, msg); | ||
487 | break; | ||
488 | } | ||
489 | |||
490 | start += CPC_MSG_HEADER_LEN + msg->length; | ||
491 | msg_count--; | ||
492 | |||
493 | if (start > urb->transfer_buffer_length) { | ||
494 | dev_err(netdev->dev.parent, "format error\n"); | ||
495 | break; | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | |||
500 | resubmit_urb: | ||
501 | usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2), | ||
502 | urb->transfer_buffer, RX_BUFFER_SIZE, | ||
503 | ems_usb_read_bulk_callback, dev); | ||
504 | |||
505 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
506 | |||
507 | if (retval == -ENODEV) | ||
508 | netif_device_detach(netdev); | ||
509 | else if (retval) | ||
510 | dev_err(netdev->dev.parent, | ||
511 | "failed resubmitting read bulk urb: %d\n", retval); | ||
512 | |||
513 | return; | ||
514 | } | ||
515 | |||
516 | /* | ||
517 | * callback for bulk IN urb | ||
518 | */ | ||
519 | static void ems_usb_write_bulk_callback(struct urb *urb) | ||
520 | { | ||
521 | struct ems_tx_urb_context *context = urb->context; | ||
522 | struct ems_usb *dev; | ||
523 | struct net_device *netdev; | ||
524 | |||
525 | BUG_ON(!context); | ||
526 | |||
527 | dev = context->dev; | ||
528 | netdev = dev->netdev; | ||
529 | |||
530 | /* free up our allocated buffer */ | ||
531 | usb_buffer_free(urb->dev, urb->transfer_buffer_length, | ||
532 | urb->transfer_buffer, urb->transfer_dma); | ||
533 | |||
534 | atomic_dec(&dev->active_tx_urbs); | ||
535 | |||
536 | if (!netif_device_present(netdev)) | ||
537 | return; | ||
538 | |||
539 | if (urb->status) | ||
540 | dev_info(netdev->dev.parent, "Tx URB aborted (%d)\n", | ||
541 | urb->status); | ||
542 | |||
543 | netdev->trans_start = jiffies; | ||
544 | |||
545 | /* transmission complete interrupt */ | ||
546 | netdev->stats.tx_packets++; | ||
547 | netdev->stats.tx_bytes += context->dlc; | ||
548 | |||
549 | can_get_echo_skb(netdev, context->echo_index); | ||
550 | |||
551 | /* Release context */ | ||
552 | context->echo_index = MAX_TX_URBS; | ||
553 | |||
554 | if (netif_queue_stopped(netdev)) | ||
555 | netif_wake_queue(netdev); | ||
556 | } | ||
557 | |||
558 | /* | ||
559 | * Send the given CPC command synchronously | ||
560 | */ | ||
561 | static int ems_usb_command_msg(struct ems_usb *dev, struct ems_cpc_msg *msg) | ||
562 | { | ||
563 | int actual_length; | ||
564 | |||
565 | /* Copy payload */ | ||
566 | memcpy(&dev->tx_msg_buffer[CPC_HEADER_SIZE], msg, | ||
567 | msg->length + CPC_MSG_HEADER_LEN); | ||
568 | |||
569 | /* Clear header */ | ||
570 | memset(&dev->tx_msg_buffer[0], 0, CPC_HEADER_SIZE); | ||
571 | |||
572 | return usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 2), | ||
573 | &dev->tx_msg_buffer[0], | ||
574 | msg->length + CPC_MSG_HEADER_LEN + CPC_HEADER_SIZE, | ||
575 | &actual_length, 1000); | ||
576 | } | ||
577 | |||
578 | /* | ||
579 | * Change CAN controllers' mode register | ||
580 | */ | ||
581 | static int ems_usb_write_mode(struct ems_usb *dev, u8 mode) | ||
582 | { | ||
583 | dev->active_params.msg.can_params.cc_params.sja1000.mode = mode; | ||
584 | |||
585 | return ems_usb_command_msg(dev, &dev->active_params); | ||
586 | } | ||
587 | |||
588 | /* | ||
589 | * Send a CPC_Control command to change behaviour when interface receives a CAN | ||
590 | * message, bus error or CAN state changed notifications. | ||
591 | */ | ||
592 | static int ems_usb_control_cmd(struct ems_usb *dev, u8 val) | ||
593 | { | ||
594 | struct ems_cpc_msg cmd; | ||
595 | |||
596 | cmd.type = CPC_CMD_TYPE_CONTROL; | ||
597 | cmd.length = CPC_MSG_HEADER_LEN + 1; | ||
598 | |||
599 | cmd.msgid = 0; | ||
600 | |||
601 | cmd.msg.generic[0] = val; | ||
602 | |||
603 | return ems_usb_command_msg(dev, &cmd); | ||
604 | } | ||
605 | |||
606 | /* | ||
607 | * Start interface | ||
608 | */ | ||
609 | static int ems_usb_start(struct ems_usb *dev) | ||
610 | { | ||
611 | struct net_device *netdev = dev->netdev; | ||
612 | int err, i; | ||
613 | |||
614 | dev->intr_in_buffer[0] = 0; | ||
615 | dev->free_slots = 15; /* initial size */ | ||
616 | |||
617 | for (i = 0; i < MAX_RX_URBS; i++) { | ||
618 | struct urb *urb = NULL; | ||
619 | u8 *buf = NULL; | ||
620 | |||
621 | /* create a URB, and a buffer for it */ | ||
622 | urb = usb_alloc_urb(0, GFP_KERNEL); | ||
623 | if (!urb) { | ||
624 | dev_err(netdev->dev.parent, | ||
625 | "No memory left for URBs\n"); | ||
626 | return -ENOMEM; | ||
627 | } | ||
628 | |||
629 | buf = usb_buffer_alloc(dev->udev, RX_BUFFER_SIZE, GFP_KERNEL, | ||
630 | &urb->transfer_dma); | ||
631 | if (!buf) { | ||
632 | dev_err(netdev->dev.parent, | ||
633 | "No memory left for USB buffer\n"); | ||
634 | usb_free_urb(urb); | ||
635 | return -ENOMEM; | ||
636 | } | ||
637 | |||
638 | usb_fill_bulk_urb(urb, dev->udev, usb_rcvbulkpipe(dev->udev, 2), | ||
639 | buf, RX_BUFFER_SIZE, | ||
640 | ems_usb_read_bulk_callback, dev); | ||
641 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
642 | usb_anchor_urb(urb, &dev->rx_submitted); | ||
643 | |||
644 | err = usb_submit_urb(urb, GFP_KERNEL); | ||
645 | if (err) { | ||
646 | if (err == -ENODEV) | ||
647 | netif_device_detach(dev->netdev); | ||
648 | |||
649 | usb_unanchor_urb(urb); | ||
650 | usb_buffer_free(dev->udev, RX_BUFFER_SIZE, buf, | ||
651 | urb->transfer_dma); | ||
652 | break; | ||
653 | } | ||
654 | |||
655 | /* Drop reference, USB core will take care of freeing it */ | ||
656 | usb_free_urb(urb); | ||
657 | } | ||
658 | |||
659 | /* Did we submit any URBs */ | ||
660 | if (i == 0) { | ||
661 | dev_warn(netdev->dev.parent, "couldn't setup read URBs\n"); | ||
662 | return err; | ||
663 | } | ||
664 | |||
665 | /* Warn if we've couldn't transmit all the URBs */ | ||
666 | if (i < MAX_RX_URBS) | ||
667 | dev_warn(netdev->dev.parent, "rx performance may be slow\n"); | ||
668 | |||
669 | /* Setup and start interrupt URB */ | ||
670 | usb_fill_int_urb(dev->intr_urb, dev->udev, | ||
671 | usb_rcvintpipe(dev->udev, 1), | ||
672 | dev->intr_in_buffer, | ||
673 | INTR_IN_BUFFER_SIZE, | ||
674 | ems_usb_read_interrupt_callback, dev, 1); | ||
675 | |||
676 | err = usb_submit_urb(dev->intr_urb, GFP_KERNEL); | ||
677 | if (err) { | ||
678 | if (err == -ENODEV) | ||
679 | netif_device_detach(dev->netdev); | ||
680 | |||
681 | dev_warn(netdev->dev.parent, "intr URB submit failed: %d\n", | ||
682 | err); | ||
683 | |||
684 | return err; | ||
685 | } | ||
686 | |||
687 | /* CPC-USB will transfer received message to host */ | ||
688 | err = ems_usb_control_cmd(dev, CONTR_CAN_MESSAGE | CONTR_CONT_ON); | ||
689 | if (err) | ||
690 | goto failed; | ||
691 | |||
692 | /* CPC-USB will transfer CAN state changes to host */ | ||
693 | err = ems_usb_control_cmd(dev, CONTR_CAN_STATE | CONTR_CONT_ON); | ||
694 | if (err) | ||
695 | goto failed; | ||
696 | |||
697 | /* CPC-USB will transfer bus errors to host */ | ||
698 | err = ems_usb_control_cmd(dev, CONTR_BUS_ERROR | CONTR_CONT_ON); | ||
699 | if (err) | ||
700 | goto failed; | ||
701 | |||
702 | err = ems_usb_write_mode(dev, SJA1000_MOD_NORMAL); | ||
703 | if (err) | ||
704 | goto failed; | ||
705 | |||
706 | dev->can.state = CAN_STATE_ERROR_ACTIVE; | ||
707 | |||
708 | return 0; | ||
709 | |||
710 | failed: | ||
711 | if (err == -ENODEV) | ||
712 | netif_device_detach(dev->netdev); | ||
713 | |||
714 | dev_warn(netdev->dev.parent, "couldn't submit control: %d\n", err); | ||
715 | |||
716 | return err; | ||
717 | } | ||
718 | |||
719 | static void unlink_all_urbs(struct ems_usb *dev) | ||
720 | { | ||
721 | int i; | ||
722 | |||
723 | usb_unlink_urb(dev->intr_urb); | ||
724 | |||
725 | usb_kill_anchored_urbs(&dev->rx_submitted); | ||
726 | |||
727 | usb_kill_anchored_urbs(&dev->tx_submitted); | ||
728 | atomic_set(&dev->active_tx_urbs, 0); | ||
729 | |||
730 | for (i = 0; i < MAX_TX_URBS; i++) | ||
731 | dev->tx_contexts[i].echo_index = MAX_TX_URBS; | ||
732 | } | ||
733 | |||
734 | static int ems_usb_open(struct net_device *netdev) | ||
735 | { | ||
736 | struct ems_usb *dev = netdev_priv(netdev); | ||
737 | int err; | ||
738 | |||
739 | err = ems_usb_write_mode(dev, SJA1000_MOD_RM); | ||
740 | if (err) | ||
741 | return err; | ||
742 | |||
743 | /* common open */ | ||
744 | err = open_candev(netdev); | ||
745 | if (err) | ||
746 | return err; | ||
747 | |||
748 | /* finally start device */ | ||
749 | err = ems_usb_start(dev); | ||
750 | if (err) { | ||
751 | if (err == -ENODEV) | ||
752 | netif_device_detach(dev->netdev); | ||
753 | |||
754 | dev_warn(netdev->dev.parent, "couldn't start device: %d\n", | ||
755 | err); | ||
756 | |||
757 | close_candev(netdev); | ||
758 | |||
759 | return err; | ||
760 | } | ||
761 | |||
762 | dev->open_time = jiffies; | ||
763 | |||
764 | netif_start_queue(netdev); | ||
765 | |||
766 | return 0; | ||
767 | } | ||
768 | |||
769 | static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *netdev) | ||
770 | { | ||
771 | struct ems_usb *dev = netdev_priv(netdev); | ||
772 | struct ems_tx_urb_context *context = NULL; | ||
773 | struct net_device_stats *stats = &netdev->stats; | ||
774 | struct can_frame *cf = (struct can_frame *)skb->data; | ||
775 | struct ems_cpc_msg *msg; | ||
776 | struct urb *urb; | ||
777 | u8 *buf; | ||
778 | int i, err; | ||
779 | size_t size = CPC_HEADER_SIZE + CPC_MSG_HEADER_LEN | ||
780 | + sizeof(struct cpc_can_msg); | ||
781 | |||
782 | /* create a URB, and a buffer for it, and copy the data to the URB */ | ||
783 | urb = usb_alloc_urb(0, GFP_ATOMIC); | ||
784 | if (!urb) { | ||
785 | dev_err(netdev->dev.parent, "No memory left for URBs\n"); | ||
786 | goto nomem; | ||
787 | } | ||
788 | |||
789 | buf = usb_buffer_alloc(dev->udev, size, GFP_ATOMIC, &urb->transfer_dma); | ||
790 | if (!buf) { | ||
791 | dev_err(netdev->dev.parent, "No memory left for USB buffer\n"); | ||
792 | usb_free_urb(urb); | ||
793 | goto nomem; | ||
794 | } | ||
795 | |||
796 | msg = (struct ems_cpc_msg *)&buf[CPC_HEADER_SIZE]; | ||
797 | |||
798 | msg->msg.can_msg.id = cf->can_id & CAN_ERR_MASK; | ||
799 | msg->msg.can_msg.length = cf->can_dlc; | ||
800 | |||
801 | if (cf->can_id & CAN_RTR_FLAG) { | ||
802 | msg->type = cf->can_id & CAN_EFF_FLAG ? | ||
803 | CPC_CMD_TYPE_EXT_RTR_FRAME : CPC_CMD_TYPE_RTR_FRAME; | ||
804 | |||
805 | msg->length = CPC_CAN_MSG_MIN_SIZE; | ||
806 | } else { | ||
807 | msg->type = cf->can_id & CAN_EFF_FLAG ? | ||
808 | CPC_CMD_TYPE_EXT_CAN_FRAME : CPC_CMD_TYPE_CAN_FRAME; | ||
809 | |||
810 | for (i = 0; i < cf->can_dlc; i++) | ||
811 | msg->msg.can_msg.msg[i] = cf->data[i]; | ||
812 | |||
813 | msg->length = CPC_CAN_MSG_MIN_SIZE + cf->can_dlc; | ||
814 | } | ||
815 | |||
816 | for (i = 0; i < MAX_TX_URBS; i++) { | ||
817 | if (dev->tx_contexts[i].echo_index == MAX_TX_URBS) { | ||
818 | context = &dev->tx_contexts[i]; | ||
819 | break; | ||
820 | } | ||
821 | } | ||
822 | |||
823 | /* | ||
824 | * May never happen! When this happens we'd more URBs in flight as | ||
825 | * allowed (MAX_TX_URBS). | ||
826 | */ | ||
827 | if (!context) { | ||
828 | usb_unanchor_urb(urb); | ||
829 | usb_buffer_free(dev->udev, size, buf, urb->transfer_dma); | ||
830 | |||
831 | dev_warn(netdev->dev.parent, "couldn't find free context\n"); | ||
832 | |||
833 | return NETDEV_TX_BUSY; | ||
834 | } | ||
835 | |||
836 | context->dev = dev; | ||
837 | context->echo_index = i; | ||
838 | context->dlc = cf->can_dlc; | ||
839 | |||
840 | usb_fill_bulk_urb(urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), buf, | ||
841 | size, ems_usb_write_bulk_callback, context); | ||
842 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
843 | usb_anchor_urb(urb, &dev->tx_submitted); | ||
844 | |||
845 | can_put_echo_skb(skb, netdev, context->echo_index); | ||
846 | |||
847 | atomic_inc(&dev->active_tx_urbs); | ||
848 | |||
849 | err = usb_submit_urb(urb, GFP_ATOMIC); | ||
850 | if (unlikely(err)) { | ||
851 | can_free_echo_skb(netdev, context->echo_index); | ||
852 | |||
853 | usb_unanchor_urb(urb); | ||
854 | usb_buffer_free(dev->udev, size, buf, urb->transfer_dma); | ||
855 | dev_kfree_skb(skb); | ||
856 | |||
857 | atomic_dec(&dev->active_tx_urbs); | ||
858 | |||
859 | if (err == -ENODEV) { | ||
860 | netif_device_detach(netdev); | ||
861 | } else { | ||
862 | dev_warn(netdev->dev.parent, "failed tx_urb %d\n", err); | ||
863 | |||
864 | stats->tx_dropped++; | ||
865 | } | ||
866 | } else { | ||
867 | netdev->trans_start = jiffies; | ||
868 | |||
869 | /* Slow down tx path */ | ||
870 | if (atomic_read(&dev->active_tx_urbs) >= MAX_TX_URBS || | ||
871 | dev->free_slots < 5) { | ||
872 | netif_stop_queue(netdev); | ||
873 | } | ||
874 | } | ||
875 | |||
876 | /* | ||
877 | * Release our reference to this URB, the USB core will eventually free | ||
878 | * it entirely. | ||
879 | */ | ||
880 | usb_free_urb(urb); | ||
881 | |||
882 | return NETDEV_TX_OK; | ||
883 | |||
884 | nomem: | ||
885 | if (skb) | ||
886 | dev_kfree_skb(skb); | ||
887 | |||
888 | stats->tx_dropped++; | ||
889 | |||
890 | return NETDEV_TX_OK; | ||
891 | } | ||
892 | |||
893 | static int ems_usb_close(struct net_device *netdev) | ||
894 | { | ||
895 | struct ems_usb *dev = netdev_priv(netdev); | ||
896 | |||
897 | /* Stop polling */ | ||
898 | unlink_all_urbs(dev); | ||
899 | |||
900 | netif_stop_queue(netdev); | ||
901 | |||
902 | /* Set CAN controller to reset mode */ | ||
903 | if (ems_usb_write_mode(dev, SJA1000_MOD_RM)) | ||
904 | dev_warn(netdev->dev.parent, "couldn't stop device"); | ||
905 | |||
906 | close_candev(netdev); | ||
907 | |||
908 | dev->open_time = 0; | ||
909 | |||
910 | return 0; | ||
911 | } | ||
912 | |||
913 | static const struct net_device_ops ems_usb_netdev_ops = { | ||
914 | .ndo_open = ems_usb_open, | ||
915 | .ndo_stop = ems_usb_close, | ||
916 | .ndo_start_xmit = ems_usb_start_xmit, | ||
917 | }; | ||
918 | |||
919 | static struct can_bittiming_const ems_usb_bittiming_const = { | ||
920 | .name = "ems_usb", | ||
921 | .tseg1_min = 1, | ||
922 | .tseg1_max = 16, | ||
923 | .tseg2_min = 1, | ||
924 | .tseg2_max = 8, | ||
925 | .sjw_max = 4, | ||
926 | .brp_min = 1, | ||
927 | .brp_max = 64, | ||
928 | .brp_inc = 1, | ||
929 | }; | ||
930 | |||
931 | static int ems_usb_set_mode(struct net_device *netdev, enum can_mode mode) | ||
932 | { | ||
933 | struct ems_usb *dev = netdev_priv(netdev); | ||
934 | |||
935 | if (!dev->open_time) | ||
936 | return -EINVAL; | ||
937 | |||
938 | switch (mode) { | ||
939 | case CAN_MODE_START: | ||
940 | if (ems_usb_write_mode(dev, SJA1000_MOD_NORMAL)) | ||
941 | dev_warn(netdev->dev.parent, "couldn't start device"); | ||
942 | |||
943 | if (netif_queue_stopped(netdev)) | ||
944 | netif_wake_queue(netdev); | ||
945 | break; | ||
946 | |||
947 | default: | ||
948 | return -EOPNOTSUPP; | ||
949 | } | ||
950 | |||
951 | return 0; | ||
952 | } | ||
953 | |||
954 | static int ems_usb_set_bittiming(struct net_device *netdev) | ||
955 | { | ||
956 | struct ems_usb *dev = netdev_priv(netdev); | ||
957 | struct can_bittiming *bt = &dev->can.bittiming; | ||
958 | u8 btr0, btr1; | ||
959 | |||
960 | btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6); | ||
961 | btr1 = ((bt->prop_seg + bt->phase_seg1 - 1) & 0xf) | | ||
962 | (((bt->phase_seg2 - 1) & 0x7) << 4); | ||
963 | if (dev->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) | ||
964 | btr1 |= 0x80; | ||
965 | |||
966 | dev_info(netdev->dev.parent, "setting BTR0=0x%02x BTR1=0x%02x\n", | ||
967 | btr0, btr1); | ||
968 | |||
969 | dev->active_params.msg.can_params.cc_params.sja1000.btr0 = btr0; | ||
970 | dev->active_params.msg.can_params.cc_params.sja1000.btr1 = btr1; | ||
971 | |||
972 | return ems_usb_command_msg(dev, &dev->active_params); | ||
973 | } | ||
974 | |||
975 | static void init_params_sja1000(struct ems_cpc_msg *msg) | ||
976 | { | ||
977 | struct cpc_sja1000_params *sja1000 = | ||
978 | &msg->msg.can_params.cc_params.sja1000; | ||
979 | |||
980 | msg->type = CPC_CMD_TYPE_CAN_PARAMS; | ||
981 | msg->length = sizeof(struct cpc_can_params); | ||
982 | msg->msgid = 0; | ||
983 | |||
984 | msg->msg.can_params.cc_type = CPC_CC_TYPE_SJA1000; | ||
985 | |||
986 | /* Acceptance filter open */ | ||
987 | sja1000->acc_code0 = 0x00; | ||
988 | sja1000->acc_code1 = 0x00; | ||
989 | sja1000->acc_code2 = 0x00; | ||
990 | sja1000->acc_code3 = 0x00; | ||
991 | |||
992 | /* Acceptance filter open */ | ||
993 | sja1000->acc_mask0 = 0xFF; | ||
994 | sja1000->acc_mask1 = 0xFF; | ||
995 | sja1000->acc_mask2 = 0xFF; | ||
996 | sja1000->acc_mask3 = 0xFF; | ||
997 | |||
998 | sja1000->btr0 = 0; | ||
999 | sja1000->btr1 = 0; | ||
1000 | |||
1001 | sja1000->outp_contr = SJA1000_DEFAULT_OUTPUT_CONTROL; | ||
1002 | sja1000->mode = SJA1000_MOD_RM; | ||
1003 | } | ||
1004 | |||
1005 | /* | ||
1006 | * probe function for new CPC-USB devices | ||
1007 | */ | ||
1008 | static int ems_usb_probe(struct usb_interface *intf, | ||
1009 | const struct usb_device_id *id) | ||
1010 | { | ||
1011 | struct net_device *netdev; | ||
1012 | struct ems_usb *dev; | ||
1013 | int i, err = -ENOMEM; | ||
1014 | |||
1015 | netdev = alloc_candev(sizeof(struct ems_usb)); | ||
1016 | if (!netdev) { | ||
1017 | dev_err(netdev->dev.parent, "Couldn't alloc candev\n"); | ||
1018 | return -ENOMEM; | ||
1019 | } | ||
1020 | |||
1021 | dev = netdev_priv(netdev); | ||
1022 | |||
1023 | dev->udev = interface_to_usbdev(intf); | ||
1024 | dev->netdev = netdev; | ||
1025 | |||
1026 | dev->can.state = CAN_STATE_STOPPED; | ||
1027 | dev->can.clock.freq = EMS_USB_ARM7_CLOCK; | ||
1028 | dev->can.bittiming_const = &ems_usb_bittiming_const; | ||
1029 | dev->can.do_set_bittiming = ems_usb_set_bittiming; | ||
1030 | dev->can.do_set_mode = ems_usb_set_mode; | ||
1031 | |||
1032 | netdev->flags |= IFF_ECHO; /* we support local echo */ | ||
1033 | |||
1034 | netdev->netdev_ops = &ems_usb_netdev_ops; | ||
1035 | |||
1036 | netdev->flags |= IFF_ECHO; /* we support local echo */ | ||
1037 | |||
1038 | init_usb_anchor(&dev->rx_submitted); | ||
1039 | |||
1040 | init_usb_anchor(&dev->tx_submitted); | ||
1041 | atomic_set(&dev->active_tx_urbs, 0); | ||
1042 | |||
1043 | for (i = 0; i < MAX_TX_URBS; i++) | ||
1044 | dev->tx_contexts[i].echo_index = MAX_TX_URBS; | ||
1045 | |||
1046 | dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
1047 | if (!dev->intr_urb) { | ||
1048 | dev_err(netdev->dev.parent, "Couldn't alloc intr URB\n"); | ||
1049 | goto cleanup_candev; | ||
1050 | } | ||
1051 | |||
1052 | dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL); | ||
1053 | if (!dev->intr_in_buffer) { | ||
1054 | dev_err(netdev->dev.parent, "Couldn't alloc Intr buffer\n"); | ||
1055 | goto cleanup_intr_urb; | ||
1056 | } | ||
1057 | |||
1058 | dev->tx_msg_buffer = kzalloc(CPC_HEADER_SIZE + | ||
1059 | sizeof(struct ems_cpc_msg), GFP_KERNEL); | ||
1060 | if (!dev->tx_msg_buffer) { | ||
1061 | dev_err(netdev->dev.parent, "Couldn't alloc Tx buffer\n"); | ||
1062 | goto cleanup_intr_in_buffer; | ||
1063 | } | ||
1064 | |||
1065 | usb_set_intfdata(intf, dev); | ||
1066 | |||
1067 | SET_NETDEV_DEV(netdev, &intf->dev); | ||
1068 | |||
1069 | init_params_sja1000(&dev->active_params); | ||
1070 | |||
1071 | err = ems_usb_command_msg(dev, &dev->active_params); | ||
1072 | if (err) { | ||
1073 | dev_err(netdev->dev.parent, | ||
1074 | "couldn't initialize controller: %d\n", err); | ||
1075 | goto cleanup_tx_msg_buffer; | ||
1076 | } | ||
1077 | |||
1078 | err = register_candev(netdev); | ||
1079 | if (err) { | ||
1080 | dev_err(netdev->dev.parent, | ||
1081 | "couldn't register CAN device: %d\n", err); | ||
1082 | goto cleanup_tx_msg_buffer; | ||
1083 | } | ||
1084 | |||
1085 | return 0; | ||
1086 | |||
1087 | cleanup_tx_msg_buffer: | ||
1088 | kfree(dev->tx_msg_buffer); | ||
1089 | |||
1090 | cleanup_intr_in_buffer: | ||
1091 | kfree(dev->intr_in_buffer); | ||
1092 | |||
1093 | cleanup_intr_urb: | ||
1094 | usb_free_urb(dev->intr_urb); | ||
1095 | |||
1096 | cleanup_candev: | ||
1097 | free_candev(netdev); | ||
1098 | |||
1099 | return err; | ||
1100 | } | ||
1101 | |||
1102 | /* | ||
1103 | * called by the usb core when the device is removed from the system | ||
1104 | */ | ||
1105 | static void ems_usb_disconnect(struct usb_interface *intf) | ||
1106 | { | ||
1107 | struct ems_usb *dev = usb_get_intfdata(intf); | ||
1108 | |||
1109 | usb_set_intfdata(intf, NULL); | ||
1110 | |||
1111 | if (dev) { | ||
1112 | unregister_netdev(dev->netdev); | ||
1113 | free_candev(dev->netdev); | ||
1114 | |||
1115 | unlink_all_urbs(dev); | ||
1116 | |||
1117 | usb_free_urb(dev->intr_urb); | ||
1118 | |||
1119 | kfree(dev->intr_in_buffer); | ||
1120 | } | ||
1121 | } | ||
1122 | |||
1123 | /* usb specific object needed to register this driver with the usb subsystem */ | ||
1124 | static struct usb_driver ems_usb_driver = { | ||
1125 | .name = "ems_usb", | ||
1126 | .probe = ems_usb_probe, | ||
1127 | .disconnect = ems_usb_disconnect, | ||
1128 | .id_table = ems_usb_table, | ||
1129 | }; | ||
1130 | |||
1131 | static int __init ems_usb_init(void) | ||
1132 | { | ||
1133 | int err; | ||
1134 | |||
1135 | printk(KERN_INFO "CPC-USB kernel driver loaded\n"); | ||
1136 | |||
1137 | /* register this driver with the USB subsystem */ | ||
1138 | err = usb_register(&ems_usb_driver); | ||
1139 | |||
1140 | if (err) { | ||
1141 | err("usb_register failed. Error number %d\n", err); | ||
1142 | return err; | ||
1143 | } | ||
1144 | |||
1145 | return 0; | ||
1146 | } | ||
1147 | |||
1148 | static void __exit ems_usb_exit(void) | ||
1149 | { | ||
1150 | /* deregister this driver with the USB subsystem */ | ||
1151 | usb_deregister(&ems_usb_driver); | ||
1152 | } | ||
1153 | |||
1154 | module_init(ems_usb_init); | ||
1155 | module_exit(ems_usb_exit); | ||
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c index 6971f6cd37fa..80ac56313981 100644 --- a/drivers/net/can/vcan.c +++ b/drivers/net/can/vcan.c | |||
@@ -80,7 +80,7 @@ static void vcan_rx(struct sk_buff *skb, struct net_device *dev) | |||
80 | skb->dev = dev; | 80 | skb->dev = dev; |
81 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 81 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
82 | 82 | ||
83 | netif_rx(skb); | 83 | netif_rx_ni(skb); |
84 | } | 84 | } |
85 | 85 | ||
86 | static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev) | 86 | static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev) |
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c index d45eacb76702..211c8e9182fc 100644 --- a/drivers/net/cnic.c +++ b/drivers/net/cnic.c | |||
@@ -85,8 +85,6 @@ static int cnic_uio_open(struct uio_info *uinfo, struct inode *inode) | |||
85 | 85 | ||
86 | cp->uio_dev = iminor(inode); | 86 | cp->uio_dev = iminor(inode); |
87 | 87 | ||
88 | cnic_shutdown_bnx2_rx_ring(dev); | ||
89 | |||
90 | cnic_init_bnx2_tx_ring(dev); | 88 | cnic_init_bnx2_tx_ring(dev); |
91 | cnic_init_bnx2_rx_ring(dev); | 89 | cnic_init_bnx2_rx_ring(dev); |
92 | 90 | ||
@@ -98,6 +96,8 @@ static int cnic_uio_close(struct uio_info *uinfo, struct inode *inode) | |||
98 | struct cnic_dev *dev = uinfo->priv; | 96 | struct cnic_dev *dev = uinfo->priv; |
99 | struct cnic_local *cp = dev->cnic_priv; | 97 | struct cnic_local *cp = dev->cnic_priv; |
100 | 98 | ||
99 | cnic_shutdown_bnx2_rx_ring(dev); | ||
100 | |||
101 | cp->uio_dev = -1; | 101 | cp->uio_dev = -1; |
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index 3e3fab8afb1e..61f9da2b4943 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c | |||
@@ -1109,7 +1109,7 @@ static int external_switch; | |||
1109 | static int __devinit cpmac_probe(struct platform_device *pdev) | 1109 | static int __devinit cpmac_probe(struct platform_device *pdev) |
1110 | { | 1110 | { |
1111 | int rc, phy_id; | 1111 | int rc, phy_id; |
1112 | char mdio_bus_id[BUS_ID_SIZE]; | 1112 | char mdio_bus_id[MII_BUS_ID_SIZE]; |
1113 | struct resource *mem; | 1113 | struct resource *mem; |
1114 | struct cpmac_priv *priv; | 1114 | struct cpmac_priv *priv; |
1115 | struct net_device *dev; | 1115 | struct net_device *dev; |
@@ -1118,7 +1118,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1118 | pdata = pdev->dev.platform_data; | 1118 | pdata = pdev->dev.platform_data; |
1119 | 1119 | ||
1120 | if (external_switch || dumb_switch) { | 1120 | if (external_switch || dumb_switch) { |
1121 | strncpy(mdio_bus_id, "0", BUS_ID_SIZE); /* fixed phys bus */ | 1121 | strncpy(mdio_bus_id, "0", MII_BUS_ID_SIZE); /* fixed phys bus */ |
1122 | phy_id = pdev->id; | 1122 | phy_id = pdev->id; |
1123 | } else { | 1123 | } else { |
1124 | for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { | 1124 | for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { |
@@ -1126,7 +1126,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1126 | continue; | 1126 | continue; |
1127 | if (!cpmac_mii->phy_map[phy_id]) | 1127 | if (!cpmac_mii->phy_map[phy_id]) |
1128 | continue; | 1128 | continue; |
1129 | strncpy(mdio_bus_id, cpmac_mii->id, BUS_ID_SIZE); | 1129 | strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE); |
1130 | break; | 1130 | break; |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
@@ -1167,7 +1167,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1167 | priv->msg_enable = netif_msg_init(debug_level, 0xff); | 1167 | priv->msg_enable = netif_msg_init(debug_level, 0xff); |
1168 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); | 1168 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); |
1169 | 1169 | ||
1170 | snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); | 1170 | snprintf(priv->phy_name, MII_BUS_ID_SIZE, PHY_ID_FMT, mdio_bus_id, phy_id); |
1171 | 1171 | ||
1172 | priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, | 1172 | priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, |
1173 | PHY_INTERFACE_MODE_MII); | 1173 | PHY_INTERFACE_MODE_MII); |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 977c3d358279..41bd7aeafd82 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -3083,7 +3083,6 @@ static const struct net_device_ops ehea_netdev_ops = { | |||
3083 | .ndo_poll_controller = ehea_netpoll, | 3083 | .ndo_poll_controller = ehea_netpoll, |
3084 | #endif | 3084 | #endif |
3085 | .ndo_get_stats = ehea_get_stats, | 3085 | .ndo_get_stats = ehea_get_stats, |
3086 | .ndo_change_mtu = eth_change_mtu, | ||
3087 | .ndo_set_mac_address = ehea_set_mac_addr, | 3086 | .ndo_set_mac_address = ehea_set_mac_addr, |
3088 | .ndo_validate_addr = eth_validate_addr, | 3087 | .ndo_validate_addr = eth_validate_addr, |
3089 | .ndo_set_multicast_list = ehea_set_multicast_list, | 3088 | .ndo_set_multicast_list = ehea_set_multicast_list, |
diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c index 6158c0f3b205..f8f5772557ce 100644 --- a/drivers/net/igb/e1000_82575.c +++ b/drivers/net/igb/e1000_82575.c | |||
@@ -49,11 +49,10 @@ static s32 igb_read_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16 *); | |||
49 | static s32 igb_reset_hw_82575(struct e1000_hw *); | 49 | static s32 igb_reset_hw_82575(struct e1000_hw *); |
50 | static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool); | 50 | static s32 igb_set_d0_lplu_state_82575(struct e1000_hw *, bool); |
51 | static s32 igb_setup_copper_link_82575(struct e1000_hw *); | 51 | static s32 igb_setup_copper_link_82575(struct e1000_hw *); |
52 | static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *); | 52 | static s32 igb_setup_serdes_link_82575(struct e1000_hw *); |
53 | static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16); | 53 | static s32 igb_write_phy_reg_sgmii_82575(struct e1000_hw *, u32, u16); |
54 | static void igb_clear_hw_cntrs_82575(struct e1000_hw *); | 54 | static void igb_clear_hw_cntrs_82575(struct e1000_hw *); |
55 | static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *, u16); | 55 | static s32 igb_acquire_swfw_sync_82575(struct e1000_hw *, u16); |
56 | static void igb_configure_pcs_link_82575(struct e1000_hw *); | ||
57 | static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *, | 56 | static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *, u16 *, |
58 | u16 *); | 57 | u16 *); |
59 | static s32 igb_get_phy_id_82575(struct e1000_hw *); | 58 | static s32 igb_get_phy_id_82575(struct e1000_hw *); |
@@ -105,16 +104,20 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
105 | dev_spec->sgmii_active = false; | 104 | dev_spec->sgmii_active = false; |
106 | 105 | ||
107 | ctrl_ext = rd32(E1000_CTRL_EXT); | 106 | ctrl_ext = rd32(E1000_CTRL_EXT); |
108 | if ((ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) == | 107 | switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) { |
109 | E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES) { | 108 | case E1000_CTRL_EXT_LINK_MODE_SGMII: |
110 | hw->phy.media_type = e1000_media_type_internal_serdes; | ||
111 | ctrl_ext |= E1000_CTRL_I2C_ENA; | ||
112 | } else if (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_SGMII) { | ||
113 | dev_spec->sgmii_active = true; | 109 | dev_spec->sgmii_active = true; |
114 | ctrl_ext |= E1000_CTRL_I2C_ENA; | 110 | ctrl_ext |= E1000_CTRL_I2C_ENA; |
115 | } else { | 111 | break; |
112 | case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES: | ||
113 | hw->phy.media_type = e1000_media_type_internal_serdes; | ||
114 | ctrl_ext |= E1000_CTRL_I2C_ENA; | ||
115 | break; | ||
116 | default: | ||
116 | ctrl_ext &= ~E1000_CTRL_I2C_ENA; | 117 | ctrl_ext &= ~E1000_CTRL_I2C_ENA; |
118 | break; | ||
117 | } | 119 | } |
120 | |||
118 | wr32(E1000_CTRL_EXT, ctrl_ext); | 121 | wr32(E1000_CTRL_EXT, ctrl_ext); |
119 | 122 | ||
120 | /* Set mta register count */ | 123 | /* Set mta register count */ |
@@ -134,7 +137,7 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
134 | mac->ops.setup_physical_interface = | 137 | mac->ops.setup_physical_interface = |
135 | (hw->phy.media_type == e1000_media_type_copper) | 138 | (hw->phy.media_type == e1000_media_type_copper) |
136 | ? igb_setup_copper_link_82575 | 139 | ? igb_setup_copper_link_82575 |
137 | : igb_setup_fiber_serdes_link_82575; | 140 | : igb_setup_serdes_link_82575; |
138 | 141 | ||
139 | /* NVM initialization */ | 142 | /* NVM initialization */ |
140 | eecd = rd32(E1000_EECD); | 143 | eecd = rd32(E1000_EECD); |
@@ -379,6 +382,7 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw) | |||
379 | struct e1000_phy_info *phy = &hw->phy; | 382 | struct e1000_phy_info *phy = &hw->phy; |
380 | s32 ret_val = 0; | 383 | s32 ret_val = 0; |
381 | u16 phy_id; | 384 | u16 phy_id; |
385 | u32 ctrl_ext; | ||
382 | 386 | ||
383 | /* | 387 | /* |
384 | * For SGMII PHYs, we try the list of possible addresses until | 388 | * For SGMII PHYs, we try the list of possible addresses until |
@@ -393,6 +397,12 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw) | |||
393 | goto out; | 397 | goto out; |
394 | } | 398 | } |
395 | 399 | ||
400 | /* Power on sgmii phy if it is disabled */ | ||
401 | ctrl_ext = rd32(E1000_CTRL_EXT); | ||
402 | wr32(E1000_CTRL_EXT, ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA); | ||
403 | wrfl(); | ||
404 | msleep(300); | ||
405 | |||
396 | /* | 406 | /* |
397 | * The address field in the I2CCMD register is 3 bits and 0 is invalid. | 407 | * The address field in the I2CCMD register is 3 bits and 0 is invalid. |
398 | * Therefore, we need to test 1-7 | 408 | * Therefore, we need to test 1-7 |
@@ -418,9 +428,12 @@ static s32 igb_get_phy_id_82575(struct e1000_hw *hw) | |||
418 | phy->addr = 0; | 428 | phy->addr = 0; |
419 | ret_val = -E1000_ERR_PHY; | 429 | ret_val = -E1000_ERR_PHY; |
420 | goto out; | 430 | goto out; |
431 | } else { | ||
432 | ret_val = igb_get_phy_id(hw); | ||
421 | } | 433 | } |
422 | 434 | ||
423 | ret_val = igb_get_phy_id(hw); | 435 | /* restore previous sfp cage power state */ |
436 | wr32(E1000_CTRL_EXT, ctrl_ext); | ||
424 | 437 | ||
425 | out: | 438 | out: |
426 | return ret_val; | 439 | return ret_val; |
@@ -766,17 +779,18 @@ static s32 igb_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw, u16 *speed, | |||
766 | } | 779 | } |
767 | 780 | ||
768 | /** | 781 | /** |
769 | * igb_shutdown_fiber_serdes_link_82575 - Remove link during power down | 782 | * igb_shutdown_serdes_link_82575 - Remove link during power down |
770 | * @hw: pointer to the HW structure | 783 | * @hw: pointer to the HW structure |
771 | * | 784 | * |
772 | * In the case of fiber serdes, shut down optics and PCS on driver unload | 785 | * In the case of fiber serdes, shut down optics and PCS on driver unload |
773 | * when management pass thru is not enabled. | 786 | * when management pass thru is not enabled. |
774 | **/ | 787 | **/ |
775 | void igb_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw) | 788 | void igb_shutdown_serdes_link_82575(struct e1000_hw *hw) |
776 | { | 789 | { |
777 | u32 reg; | 790 | u32 reg; |
778 | 791 | ||
779 | if (hw->phy.media_type != e1000_media_type_internal_serdes) | 792 | if (hw->phy.media_type != e1000_media_type_internal_serdes || |
793 | igb_sgmii_active_82575(hw)) | ||
780 | return; | 794 | return; |
781 | 795 | ||
782 | /* if the management interface is not enabled, then power down */ | 796 | /* if the management interface is not enabled, then power down */ |
@@ -788,7 +802,7 @@ void igb_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw) | |||
788 | 802 | ||
789 | /* shutdown the laser */ | 803 | /* shutdown the laser */ |
790 | reg = rd32(E1000_CTRL_EXT); | 804 | reg = rd32(E1000_CTRL_EXT); |
791 | reg |= E1000_CTRL_EXT_SDP7_DATA; | 805 | reg |= E1000_CTRL_EXT_SDP3_DATA; |
792 | wr32(E1000_CTRL_EXT, reg); | 806 | wr32(E1000_CTRL_EXT, reg); |
793 | 807 | ||
794 | /* flush the write to verify completion */ | 808 | /* flush the write to verify completion */ |
@@ -927,6 +941,17 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw) | |||
927 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); | 941 | ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); |
928 | wr32(E1000_CTRL, ctrl); | 942 | wr32(E1000_CTRL, ctrl); |
929 | 943 | ||
944 | ret_val = igb_setup_serdes_link_82575(hw); | ||
945 | if (ret_val) | ||
946 | goto out; | ||
947 | |||
948 | if (igb_sgmii_active_82575(hw) && !hw->phy.reset_disable) { | ||
949 | ret_val = hw->phy.ops.reset(hw); | ||
950 | if (ret_val) { | ||
951 | hw_dbg("Error resetting the PHY.\n"); | ||
952 | goto out; | ||
953 | } | ||
954 | } | ||
930 | switch (hw->phy.type) { | 955 | switch (hw->phy.type) { |
931 | case e1000_phy_m88: | 956 | case e1000_phy_m88: |
932 | ret_val = igb_copper_link_setup_m88(hw); | 957 | ret_val = igb_copper_link_setup_m88(hw); |
@@ -963,8 +988,6 @@ static s32 igb_setup_copper_link_82575(struct e1000_hw *hw) | |||
963 | } | 988 | } |
964 | } | 989 | } |
965 | 990 | ||
966 | igb_configure_pcs_link_82575(hw); | ||
967 | |||
968 | /* | 991 | /* |
969 | * Check link status. Wait up to 100 microseconds for link to become | 992 | * Check link status. Wait up to 100 microseconds for link to become |
970 | * valid. | 993 | * valid. |
@@ -987,14 +1010,18 @@ out: | |||
987 | } | 1010 | } |
988 | 1011 | ||
989 | /** | 1012 | /** |
990 | * igb_setup_fiber_serdes_link_82575 - Setup link for fiber/serdes | 1013 | * igb_setup_serdes_link_82575 - Setup link for fiber/serdes |
991 | * @hw: pointer to the HW structure | 1014 | * @hw: pointer to the HW structure |
992 | * | 1015 | * |
993 | * Configures speed and duplex for fiber and serdes links. | 1016 | * Configures speed and duplex for fiber and serdes links. |
994 | **/ | 1017 | **/ |
995 | static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw) | 1018 | static s32 igb_setup_serdes_link_82575(struct e1000_hw *hw) |
996 | { | 1019 | { |
997 | u32 reg; | 1020 | u32 ctrl_reg, reg; |
1021 | |||
1022 | if ((hw->phy.media_type != e1000_media_type_internal_serdes) && | ||
1023 | !igb_sgmii_active_82575(hw)) | ||
1024 | return 0; | ||
998 | 1025 | ||
999 | /* | 1026 | /* |
1000 | * On the 82575, SerDes loopback mode persists until it is | 1027 | * On the 82575, SerDes loopback mode persists until it is |
@@ -1004,26 +1031,38 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw) | |||
1004 | */ | 1031 | */ |
1005 | wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); | 1032 | wr32(E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK); |
1006 | 1033 | ||
1007 | /* Force link up, set 1gb, set both sw defined pins */ | 1034 | /* power on the sfp cage if present */ |
1008 | reg = rd32(E1000_CTRL); | 1035 | reg = rd32(E1000_CTRL_EXT); |
1009 | reg |= E1000_CTRL_SLU | | 1036 | reg &= ~E1000_CTRL_EXT_SDP3_DATA; |
1010 | E1000_CTRL_SPD_1000 | | 1037 | wr32(E1000_CTRL_EXT, reg); |
1011 | E1000_CTRL_FRCSPD | | 1038 | |
1012 | E1000_CTRL_SWDPIN0 | | 1039 | ctrl_reg = rd32(E1000_CTRL); |
1013 | E1000_CTRL_SWDPIN1; | 1040 | ctrl_reg |= E1000_CTRL_SLU; |
1014 | wr32(E1000_CTRL, reg); | 1041 | |
1015 | 1042 | if (hw->mac.type == e1000_82575 || hw->mac.type == e1000_82576) { | |
1016 | /* Power on phy for 82576 fiber adapters */ | 1043 | /* set both sw defined pins */ |
1017 | if (hw->mac.type == e1000_82576) { | 1044 | ctrl_reg |= E1000_CTRL_SWDPIN0 | E1000_CTRL_SWDPIN1; |
1018 | reg = rd32(E1000_CTRL_EXT); | 1045 | |
1019 | reg &= ~E1000_CTRL_EXT_SDP7_DATA; | 1046 | /* Set switch control to serdes energy detect */ |
1020 | wr32(E1000_CTRL_EXT, reg); | 1047 | reg = rd32(E1000_CONNSW); |
1048 | reg |= E1000_CONNSW_ENRGSRC; | ||
1049 | wr32(E1000_CONNSW, reg); | ||
1050 | } | ||
1051 | |||
1052 | reg = rd32(E1000_PCS_LCTL); | ||
1053 | |||
1054 | if (igb_sgmii_active_82575(hw)) { | ||
1055 | /* allow time for SFP cage to power up phy */ | ||
1056 | msleep(300); | ||
1057 | |||
1058 | /* AN time out should be disabled for SGMII mode */ | ||
1059 | reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT); | ||
1060 | } else { | ||
1061 | ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD | | ||
1062 | E1000_CTRL_FD | E1000_CTRL_FRCDPX; | ||
1021 | } | 1063 | } |
1022 | 1064 | ||
1023 | /* Set switch control to serdes energy detect */ | 1065 | wr32(E1000_CTRL, ctrl_reg); |
1024 | reg = rd32(E1000_CONNSW); | ||
1025 | reg |= E1000_CONNSW_ENRGSRC; | ||
1026 | wr32(E1000_CONNSW, reg); | ||
1027 | 1066 | ||
1028 | /* | 1067 | /* |
1029 | * New SerDes mode allows for forcing speed or autonegotiating speed | 1068 | * New SerDes mode allows for forcing speed or autonegotiating speed |
@@ -1031,12 +1070,21 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw) | |||
1031 | * mode that will be compatible with older link partners and switches. | 1070 | * mode that will be compatible with older link partners and switches. |
1032 | * However, both are supported by the hardware and some drivers/tools. | 1071 | * However, both are supported by the hardware and some drivers/tools. |
1033 | */ | 1072 | */ |
1034 | reg = rd32(E1000_PCS_LCTL); | ||
1035 | 1073 | ||
1036 | reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP | | 1074 | reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP | |
1037 | E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); | 1075 | E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); |
1038 | 1076 | ||
1039 | if (hw->mac.autoneg) { | 1077 | /* |
1078 | * We force flow control to prevent the CTRL register values from being | ||
1079 | * overwritten by the autonegotiated flow control values | ||
1080 | */ | ||
1081 | reg |= E1000_PCS_LCTL_FORCE_FCTRL; | ||
1082 | |||
1083 | /* | ||
1084 | * we always set sgmii to autoneg since it is the phy that will be | ||
1085 | * forcing the link and the serdes is just a go-between | ||
1086 | */ | ||
1087 | if (hw->mac.autoneg || igb_sgmii_active_82575(hw)) { | ||
1040 | /* Set PCS register for autoneg */ | 1088 | /* Set PCS register for autoneg */ |
1041 | reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */ | 1089 | reg |= E1000_PCS_LCTL_FSV_1000 | /* Force 1000 */ |
1042 | E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */ | 1090 | E1000_PCS_LCTL_FDV_FULL | /* SerDes Full duplex */ |
@@ -1053,75 +1101,12 @@ static s32 igb_setup_fiber_serdes_link_82575(struct e1000_hw *hw) | |||
1053 | hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg); | 1101 | hw_dbg("Configuring Forced Link; PCS_LCTL = 0x%08X\n", reg); |
1054 | } | 1102 | } |
1055 | 1103 | ||
1056 | if (hw->mac.type == e1000_82576) { | ||
1057 | reg |= E1000_PCS_LCTL_FORCE_FCTRL; | ||
1058 | igb_force_mac_fc(hw); | ||
1059 | } | ||
1060 | |||
1061 | wr32(E1000_PCS_LCTL, reg); | 1104 | wr32(E1000_PCS_LCTL, reg); |
1062 | 1105 | ||
1063 | return 0; | 1106 | if (!igb_sgmii_active_82575(hw)) |
1064 | } | 1107 | igb_force_mac_fc(hw); |
1065 | |||
1066 | /** | ||
1067 | * igb_configure_pcs_link_82575 - Configure PCS link | ||
1068 | * @hw: pointer to the HW structure | ||
1069 | * | ||
1070 | * Configure the physical coding sub-layer (PCS) link. The PCS link is | ||
1071 | * only used on copper connections where the serialized gigabit media | ||
1072 | * independent interface (sgmii) is being used. Configures the link | ||
1073 | * for auto-negotiation or forces speed/duplex. | ||
1074 | **/ | ||
1075 | static void igb_configure_pcs_link_82575(struct e1000_hw *hw) | ||
1076 | { | ||
1077 | struct e1000_mac_info *mac = &hw->mac; | ||
1078 | u32 reg = 0; | ||
1079 | |||
1080 | if (hw->phy.media_type != e1000_media_type_copper || | ||
1081 | !(igb_sgmii_active_82575(hw))) | ||
1082 | return; | ||
1083 | |||
1084 | /* For SGMII, we need to issue a PCS autoneg restart */ | ||
1085 | reg = rd32(E1000_PCS_LCTL); | ||
1086 | |||
1087 | /* AN time out should be disabled for SGMII mode */ | ||
1088 | reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT); | ||
1089 | |||
1090 | if (mac->autoneg) { | ||
1091 | /* Make sure forced speed and force link are not set */ | ||
1092 | reg &= ~(E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK); | ||
1093 | |||
1094 | /* | ||
1095 | * The PHY should be setup prior to calling this function. | ||
1096 | * All we need to do is restart autoneg and enable autoneg. | ||
1097 | */ | ||
1098 | reg |= E1000_PCS_LCTL_AN_RESTART | E1000_PCS_LCTL_AN_ENABLE; | ||
1099 | } else { | ||
1100 | /* Set PCS register for forced speed */ | ||
1101 | |||
1102 | /* Turn off bits for full duplex, speed, and autoneg */ | ||
1103 | reg &= ~(E1000_PCS_LCTL_FSV_1000 | | ||
1104 | E1000_PCS_LCTL_FSV_100 | | ||
1105 | E1000_PCS_LCTL_FDV_FULL | | ||
1106 | E1000_PCS_LCTL_AN_ENABLE); | ||
1107 | |||
1108 | /* Check for duplex first */ | ||
1109 | if (mac->forced_speed_duplex & E1000_ALL_FULL_DUPLEX) | ||
1110 | reg |= E1000_PCS_LCTL_FDV_FULL; | ||
1111 | |||
1112 | /* Now set speed */ | ||
1113 | if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) | ||
1114 | reg |= E1000_PCS_LCTL_FSV_100; | ||
1115 | |||
1116 | /* Force speed and force link */ | ||
1117 | reg |= E1000_PCS_LCTL_FSD | | ||
1118 | E1000_PCS_LCTL_FORCE_LINK | | ||
1119 | E1000_PCS_LCTL_FLV_LINK_UP; | ||
1120 | 1108 | ||
1121 | hw_dbg("Wrote 0x%08X to PCS_LCTL to configure forced link\n", | 1109 | return 0; |
1122 | reg); | ||
1123 | } | ||
1124 | wr32(E1000_PCS_LCTL, reg); | ||
1125 | } | 1110 | } |
1126 | 1111 | ||
1127 | /** | 1112 | /** |
@@ -1248,7 +1233,8 @@ static void igb_clear_hw_cntrs_82575(struct e1000_hw *hw) | |||
1248 | temp = rd32(E1000_LENERRS); | 1233 | temp = rd32(E1000_LENERRS); |
1249 | 1234 | ||
1250 | /* This register should not be read in copper configurations */ | 1235 | /* This register should not be read in copper configurations */ |
1251 | if (hw->phy.media_type == e1000_media_type_internal_serdes) | 1236 | if (hw->phy.media_type == e1000_media_type_internal_serdes || |
1237 | igb_sgmii_active_82575(hw)) | ||
1252 | temp = rd32(E1000_SCVPC); | 1238 | temp = rd32(E1000_SCVPC); |
1253 | } | 1239 | } |
1254 | 1240 | ||
diff --git a/drivers/net/igb/e1000_82575.h b/drivers/net/igb/e1000_82575.h index 8a1e6597061f..ebd146fd4e15 100644 --- a/drivers/net/igb/e1000_82575.h +++ b/drivers/net/igb/e1000_82575.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #ifndef _E1000_82575_H_ | 28 | #ifndef _E1000_82575_H_ |
29 | #define _E1000_82575_H_ | 29 | #define _E1000_82575_H_ |
30 | 30 | ||
31 | extern void igb_shutdown_fiber_serdes_link_82575(struct e1000_hw *hw); | 31 | extern void igb_shutdown_serdes_link_82575(struct e1000_hw *hw); |
32 | extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw); | 32 | extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw); |
33 | 33 | ||
34 | #define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \ | 34 | #define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \ |
diff --git a/drivers/net/igb/e1000_defines.h b/drivers/net/igb/e1000_defines.h index c85829355d50..cb916833f303 100644 --- a/drivers/net/igb/e1000_defines.h +++ b/drivers/net/igb/e1000_defines.h | |||
@@ -44,7 +44,7 @@ | |||
44 | #define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */ | 44 | #define E1000_WUFC_BC 0x00000010 /* Broadcast Wakeup Enable */ |
45 | 45 | ||
46 | /* Extended Device Control */ | 46 | /* Extended Device Control */ |
47 | #define E1000_CTRL_EXT_SDP7_DATA 0x00000080 /* Value of SW Defineable Pin 7 */ | 47 | #define E1000_CTRL_EXT_SDP3_DATA 0x00000080 /* Value of SW Defineable Pin 3 */ |
48 | /* Physical Func Reset Done Indication */ | 48 | /* Physical Func Reset Done Indication */ |
49 | #define E1000_CTRL_EXT_PFRSTD 0x00004000 | 49 | #define E1000_CTRL_EXT_PFRSTD 0x00004000 |
50 | #define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 | 50 | #define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 |
diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c index a0231cd079f1..7d76bb085e10 100644 --- a/drivers/net/igb/e1000_mac.c +++ b/drivers/net/igb/e1000_mac.c | |||
@@ -286,41 +286,6 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value) | |||
286 | } | 286 | } |
287 | 287 | ||
288 | /** | 288 | /** |
289 | * igb_update_mc_addr_list - Update Multicast addresses | ||
290 | * @hw: pointer to the HW structure | ||
291 | * @mc_addr_list: array of multicast addresses to program | ||
292 | * @mc_addr_count: number of multicast addresses to program | ||
293 | * | ||
294 | * Updates entire Multicast Table Array. | ||
295 | * The caller must have a packed mc_addr_list of multicast addresses. | ||
296 | **/ | ||
297 | void igb_update_mc_addr_list(struct e1000_hw *hw, | ||
298 | u8 *mc_addr_list, u32 mc_addr_count) | ||
299 | { | ||
300 | u32 hash_value, hash_bit, hash_reg; | ||
301 | int i; | ||
302 | |||
303 | /* clear mta_shadow */ | ||
304 | memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow)); | ||
305 | |||
306 | /* update mta_shadow from mc_addr_list */ | ||
307 | for (i = 0; (u32) i < mc_addr_count; i++) { | ||
308 | hash_value = igb_hash_mc_addr(hw, mc_addr_list); | ||
309 | |||
310 | hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1); | ||
311 | hash_bit = hash_value & 0x1F; | ||
312 | |||
313 | hw->mac.mta_shadow[hash_reg] |= (1 << hash_bit); | ||
314 | mc_addr_list += (ETH_ALEN); | ||
315 | } | ||
316 | |||
317 | /* replace the entire MTA table */ | ||
318 | for (i = hw->mac.mta_reg_count - 1; i >= 0; i--) | ||
319 | array_wr32(E1000_MTA, i, hw->mac.mta_shadow[i]); | ||
320 | wrfl(); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * igb_hash_mc_addr - Generate a multicast hash value | 289 | * igb_hash_mc_addr - Generate a multicast hash value |
325 | * @hw: pointer to the HW structure | 290 | * @hw: pointer to the HW structure |
326 | * @mc_addr: pointer to a multicast address | 291 | * @mc_addr: pointer to a multicast address |
@@ -329,7 +294,7 @@ void igb_update_mc_addr_list(struct e1000_hw *hw, | |||
329 | * the multicast filter table array address and new table value. See | 294 | * the multicast filter table array address and new table value. See |
330 | * igb_mta_set() | 295 | * igb_mta_set() |
331 | **/ | 296 | **/ |
332 | u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) | 297 | static u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) |
333 | { | 298 | { |
334 | u32 hash_value, hash_mask; | 299 | u32 hash_value, hash_mask; |
335 | u8 bit_shift = 0; | 300 | u8 bit_shift = 0; |
@@ -392,6 +357,41 @@ u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) | |||
392 | } | 357 | } |
393 | 358 | ||
394 | /** | 359 | /** |
360 | * igb_update_mc_addr_list - Update Multicast addresses | ||
361 | * @hw: pointer to the HW structure | ||
362 | * @mc_addr_list: array of multicast addresses to program | ||
363 | * @mc_addr_count: number of multicast addresses to program | ||
364 | * | ||
365 | * Updates entire Multicast Table Array. | ||
366 | * The caller must have a packed mc_addr_list of multicast addresses. | ||
367 | **/ | ||
368 | void igb_update_mc_addr_list(struct e1000_hw *hw, | ||
369 | u8 *mc_addr_list, u32 mc_addr_count) | ||
370 | { | ||
371 | u32 hash_value, hash_bit, hash_reg; | ||
372 | int i; | ||
373 | |||
374 | /* clear mta_shadow */ | ||
375 | memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow)); | ||
376 | |||
377 | /* update mta_shadow from mc_addr_list */ | ||
378 | for (i = 0; (u32) i < mc_addr_count; i++) { | ||
379 | hash_value = igb_hash_mc_addr(hw, mc_addr_list); | ||
380 | |||
381 | hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1); | ||
382 | hash_bit = hash_value & 0x1F; | ||
383 | |||
384 | hw->mac.mta_shadow[hash_reg] |= (1 << hash_bit); | ||
385 | mc_addr_list += (ETH_ALEN); | ||
386 | } | ||
387 | |||
388 | /* replace the entire MTA table */ | ||
389 | for (i = hw->mac.mta_reg_count - 1; i >= 0; i--) | ||
390 | array_wr32(E1000_MTA, i, hw->mac.mta_shadow[i]); | ||
391 | wrfl(); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * igb_clear_hw_cntrs_base - Clear base hardware counters | 395 | * igb_clear_hw_cntrs_base - Clear base hardware counters |
396 | * @hw: pointer to the HW structure | 396 | * @hw: pointer to the HW structure |
397 | * | 397 | * |
diff --git a/drivers/net/igb/e1000_mac.h b/drivers/net/igb/e1000_mac.h index 7518af8cbbf5..bca17d882417 100644 --- a/drivers/net/igb/e1000_mac.h +++ b/drivers/net/igb/e1000_mac.h | |||
@@ -88,6 +88,5 @@ enum e1000_mng_mode { | |||
88 | #define E1000_MNG_DHCP_COOKIE_STATUS_VLAN 0x2 | 88 | #define E1000_MNG_DHCP_COOKIE_STATUS_VLAN 0x2 |
89 | 89 | ||
90 | extern void e1000_init_function_pointers_82575(struct e1000_hw *hw); | 90 | extern void e1000_init_function_pointers_82575(struct e1000_hw *hw); |
91 | extern u32 igb_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr); | ||
92 | 91 | ||
93 | #endif | 92 | #endif |
diff --git a/drivers/net/igb/e1000_phy.c b/drivers/net/igb/e1000_phy.c index c1f4da630420..ee460600e74b 100644 --- a/drivers/net/igb/e1000_phy.c +++ b/drivers/net/igb/e1000_phy.c | |||
@@ -1565,9 +1565,12 @@ out: | |||
1565 | **/ | 1565 | **/ |
1566 | s32 igb_phy_sw_reset(struct e1000_hw *hw) | 1566 | s32 igb_phy_sw_reset(struct e1000_hw *hw) |
1567 | { | 1567 | { |
1568 | s32 ret_val; | 1568 | s32 ret_val = 0; |
1569 | u16 phy_ctrl; | 1569 | u16 phy_ctrl; |
1570 | 1570 | ||
1571 | if (!(hw->phy.ops.read_reg)) | ||
1572 | goto out; | ||
1573 | |||
1571 | ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); | 1574 | ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); |
1572 | if (ret_val) | 1575 | if (ret_val) |
1573 | goto out; | 1576 | goto out; |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 943186b78483..d2639c4a086d 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -5320,7 +5320,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake) | |||
5320 | 5320 | ||
5321 | *enable_wake = wufc || adapter->en_mng_pt; | 5321 | *enable_wake = wufc || adapter->en_mng_pt; |
5322 | if (!*enable_wake) | 5322 | if (!*enable_wake) |
5323 | igb_shutdown_fiber_serdes_link_82575(hw); | 5323 | igb_shutdown_serdes_link_82575(hw); |
5324 | 5324 | ||
5325 | /* Release control of h/w to f/w. If f/w is AMT enabled, this | 5325 | /* Release control of h/w to f/w. If f/w is AMT enabled, this |
5326 | * would have already happened in close and is redundant. */ | 5326 | * would have already happened in close and is redundant. */ |
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h index dd688d45e9cd..385be6016667 100644 --- a/drivers/net/ixgbe/ixgbe.h +++ b/drivers/net/ixgbe/ixgbe.h | |||
@@ -267,7 +267,8 @@ struct ixgbe_adapter { | |||
267 | enum ixgbe_fc_mode last_lfc_mode; | 267 | enum ixgbe_fc_mode last_lfc_mode; |
268 | 268 | ||
269 | /* Interrupt Throttle Rate */ | 269 | /* Interrupt Throttle Rate */ |
270 | u32 itr_setting; | 270 | u32 rx_itr_setting; |
271 | u32 tx_itr_setting; | ||
271 | u16 eitr_low; | 272 | u16 eitr_low; |
272 | u16 eitr_high; | 273 | u16 eitr_high; |
273 | 274 | ||
@@ -351,7 +352,8 @@ struct ixgbe_adapter { | |||
351 | struct ixgbe_hw_stats stats; | 352 | struct ixgbe_hw_stats stats; |
352 | 353 | ||
353 | /* Interrupt Throttle Rate */ | 354 | /* Interrupt Throttle Rate */ |
354 | u32 eitr_param; | 355 | u32 rx_eitr_param; |
356 | u32 tx_eitr_param; | ||
355 | 357 | ||
356 | unsigned long state; | 358 | unsigned long state; |
357 | u64 tx_busy; | 359 | u64 tx_busy; |
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c index cb7f0c3c6e16..56b12f3192f1 100644 --- a/drivers/net/ixgbe/ixgbe_82598.c +++ b/drivers/net/ixgbe/ixgbe_82598.c | |||
@@ -322,14 +322,16 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw) | |||
322 | break; | 322 | break; |
323 | case IXGBE_DEV_ID_82598AF_DUAL_PORT: | 323 | case IXGBE_DEV_ID_82598AF_DUAL_PORT: |
324 | case IXGBE_DEV_ID_82598AF_SINGLE_PORT: | 324 | case IXGBE_DEV_ID_82598AF_SINGLE_PORT: |
325 | case IXGBE_DEV_ID_82598EB_CX4: | ||
326 | case IXGBE_DEV_ID_82598_CX4_DUAL_PORT: | ||
327 | case IXGBE_DEV_ID_82598_DA_DUAL_PORT: | 325 | case IXGBE_DEV_ID_82598_DA_DUAL_PORT: |
328 | case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM: | 326 | case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM: |
329 | case IXGBE_DEV_ID_82598EB_XF_LR: | 327 | case IXGBE_DEV_ID_82598EB_XF_LR: |
330 | case IXGBE_DEV_ID_82598EB_SFP_LOM: | 328 | case IXGBE_DEV_ID_82598EB_SFP_LOM: |
331 | media_type = ixgbe_media_type_fiber; | 329 | media_type = ixgbe_media_type_fiber; |
332 | break; | 330 | break; |
331 | case IXGBE_DEV_ID_82598EB_CX4: | ||
332 | case IXGBE_DEV_ID_82598_CX4_DUAL_PORT: | ||
333 | media_type = ixgbe_media_type_cx4; | ||
334 | break; | ||
333 | case IXGBE_DEV_ID_82598AT: | 335 | case IXGBE_DEV_ID_82598AT: |
334 | case IXGBE_DEV_ID_82598AT2: | 336 | case IXGBE_DEV_ID_82598AT2: |
335 | media_type = ixgbe_media_type_copper; | 337 | media_type = ixgbe_media_type_copper; |
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c index 61af47e75aa1..2ec58dcdb82b 100644 --- a/drivers/net/ixgbe/ixgbe_82599.c +++ b/drivers/net/ixgbe/ixgbe_82599.c | |||
@@ -337,6 +337,9 @@ static enum ixgbe_media_type ixgbe_get_media_type_82599(struct ixgbe_hw *hw) | |||
337 | case IXGBE_DEV_ID_82599_SFP: | 337 | case IXGBE_DEV_ID_82599_SFP: |
338 | media_type = ixgbe_media_type_fiber; | 338 | media_type = ixgbe_media_type_fiber; |
339 | break; | 339 | break; |
340 | case IXGBE_DEV_ID_82599_CX4: | ||
341 | media_type = ixgbe_media_type_cx4; | ||
342 | break; | ||
340 | default: | 343 | default: |
341 | media_type = ixgbe_media_type_unknown; | 344 | media_type = ixgbe_media_type_unknown; |
342 | break; | 345 | break; |
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c index 026e94a99849..53b0a6680254 100644 --- a/drivers/net/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ixgbe/ixgbe_ethtool.c | |||
@@ -1929,7 +1929,7 @@ static int ixgbe_get_coalesce(struct net_device *netdev, | |||
1929 | ec->tx_max_coalesced_frames_irq = adapter->tx_ring[0].work_limit; | 1929 | ec->tx_max_coalesced_frames_irq = adapter->tx_ring[0].work_limit; |
1930 | 1930 | ||
1931 | /* only valid if in constant ITR mode */ | 1931 | /* only valid if in constant ITR mode */ |
1932 | switch (adapter->itr_setting) { | 1932 | switch (adapter->rx_itr_setting) { |
1933 | case 0: | 1933 | case 0: |
1934 | /* throttling disabled */ | 1934 | /* throttling disabled */ |
1935 | ec->rx_coalesce_usecs = 0; | 1935 | ec->rx_coalesce_usecs = 0; |
@@ -1940,9 +1940,25 @@ static int ixgbe_get_coalesce(struct net_device *netdev, | |||
1940 | break; | 1940 | break; |
1941 | default: | 1941 | default: |
1942 | /* fixed interrupt rate mode */ | 1942 | /* fixed interrupt rate mode */ |
1943 | ec->rx_coalesce_usecs = 1000000/adapter->eitr_param; | 1943 | ec->rx_coalesce_usecs = 1000000/adapter->rx_eitr_param; |
1944 | break; | 1944 | break; |
1945 | } | 1945 | } |
1946 | |||
1947 | /* only valid if in constant ITR mode */ | ||
1948 | switch (adapter->tx_itr_setting) { | ||
1949 | case 0: | ||
1950 | /* throttling disabled */ | ||
1951 | ec->tx_coalesce_usecs = 0; | ||
1952 | break; | ||
1953 | case 1: | ||
1954 | /* dynamic ITR mode */ | ||
1955 | ec->tx_coalesce_usecs = 1; | ||
1956 | break; | ||
1957 | default: | ||
1958 | ec->tx_coalesce_usecs = 1000000/adapter->tx_eitr_param; | ||
1959 | break; | ||
1960 | } | ||
1961 | |||
1946 | return 0; | 1962 | return 0; |
1947 | } | 1963 | } |
1948 | 1964 | ||
@@ -1953,6 +1969,14 @@ static int ixgbe_set_coalesce(struct net_device *netdev, | |||
1953 | struct ixgbe_q_vector *q_vector; | 1969 | struct ixgbe_q_vector *q_vector; |
1954 | int i; | 1970 | int i; |
1955 | 1971 | ||
1972 | /* | ||
1973 | * don't accept tx specific changes if we've got mixed RxTx vectors | ||
1974 | * test and jump out here if needed before changing the rx numbers | ||
1975 | */ | ||
1976 | if ((1000000/ec->tx_coalesce_usecs) != adapter->tx_eitr_param && | ||
1977 | adapter->q_vector[0]->txr_count && adapter->q_vector[0]->rxr_count) | ||
1978 | return -EINVAL; | ||
1979 | |||
1956 | if (ec->tx_max_coalesced_frames_irq) | 1980 | if (ec->tx_max_coalesced_frames_irq) |
1957 | adapter->tx_ring[0].work_limit = ec->tx_max_coalesced_frames_irq; | 1981 | adapter->tx_ring[0].work_limit = ec->tx_max_coalesced_frames_irq; |
1958 | 1982 | ||
@@ -1963,26 +1987,49 @@ static int ixgbe_set_coalesce(struct net_device *netdev, | |||
1963 | return -EINVAL; | 1987 | return -EINVAL; |
1964 | 1988 | ||
1965 | /* store the value in ints/second */ | 1989 | /* store the value in ints/second */ |
1966 | adapter->eitr_param = 1000000/ec->rx_coalesce_usecs; | 1990 | adapter->rx_eitr_param = 1000000/ec->rx_coalesce_usecs; |
1967 | 1991 | ||
1968 | /* static value of interrupt rate */ | 1992 | /* static value of interrupt rate */ |
1969 | adapter->itr_setting = adapter->eitr_param; | 1993 | adapter->rx_itr_setting = adapter->rx_eitr_param; |
1970 | /* clear the lower bit as its used for dynamic state */ | 1994 | /* clear the lower bit as its used for dynamic state */ |
1971 | adapter->itr_setting &= ~1; | 1995 | adapter->rx_itr_setting &= ~1; |
1972 | } else if (ec->rx_coalesce_usecs == 1) { | 1996 | } else if (ec->rx_coalesce_usecs == 1) { |
1973 | /* 1 means dynamic mode */ | 1997 | /* 1 means dynamic mode */ |
1974 | adapter->eitr_param = 20000; | 1998 | adapter->rx_eitr_param = 20000; |
1975 | adapter->itr_setting = 1; | 1999 | adapter->rx_itr_setting = 1; |
1976 | } else { | 2000 | } else { |
1977 | /* | 2001 | /* |
1978 | * any other value means disable eitr, which is best | 2002 | * any other value means disable eitr, which is best |
1979 | * served by setting the interrupt rate very high | 2003 | * served by setting the interrupt rate very high |
1980 | */ | 2004 | */ |
1981 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) | 2005 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) |
1982 | adapter->eitr_param = IXGBE_MAX_RSC_INT_RATE; | 2006 | adapter->rx_eitr_param = IXGBE_MAX_RSC_INT_RATE; |
1983 | else | 2007 | else |
1984 | adapter->eitr_param = IXGBE_MAX_INT_RATE; | 2008 | adapter->rx_eitr_param = IXGBE_MAX_INT_RATE; |
1985 | adapter->itr_setting = 0; | 2009 | adapter->rx_itr_setting = 0; |
2010 | } | ||
2011 | |||
2012 | if (ec->tx_coalesce_usecs > 1) { | ||
2013 | /* check the limits */ | ||
2014 | if ((1000000/ec->tx_coalesce_usecs > IXGBE_MAX_INT_RATE) || | ||
2015 | (1000000/ec->tx_coalesce_usecs < IXGBE_MIN_INT_RATE)) | ||
2016 | return -EINVAL; | ||
2017 | |||
2018 | /* store the value in ints/second */ | ||
2019 | adapter->tx_eitr_param = 1000000/ec->tx_coalesce_usecs; | ||
2020 | |||
2021 | /* static value of interrupt rate */ | ||
2022 | adapter->tx_itr_setting = adapter->tx_eitr_param; | ||
2023 | |||
2024 | /* clear the lower bit as its used for dynamic state */ | ||
2025 | adapter->tx_itr_setting &= ~1; | ||
2026 | } else if (ec->tx_coalesce_usecs == 1) { | ||
2027 | /* 1 means dynamic mode */ | ||
2028 | adapter->tx_eitr_param = 10000; | ||
2029 | adapter->tx_itr_setting = 1; | ||
2030 | } else { | ||
2031 | adapter->tx_eitr_param = IXGBE_MAX_INT_RATE; | ||
2032 | adapter->tx_itr_setting = 0; | ||
1986 | } | 2033 | } |
1987 | 2034 | ||
1988 | /* MSI/MSIx Interrupt Mode */ | 2035 | /* MSI/MSIx Interrupt Mode */ |
@@ -1992,17 +2039,17 @@ static int ixgbe_set_coalesce(struct net_device *netdev, | |||
1992 | for (i = 0; i < num_vectors; i++) { | 2039 | for (i = 0; i < num_vectors; i++) { |
1993 | q_vector = adapter->q_vector[i]; | 2040 | q_vector = adapter->q_vector[i]; |
1994 | if (q_vector->txr_count && !q_vector->rxr_count) | 2041 | if (q_vector->txr_count && !q_vector->rxr_count) |
1995 | /* tx vector gets half the rate */ | 2042 | /* tx only */ |
1996 | q_vector->eitr = (adapter->eitr_param >> 1); | 2043 | q_vector->eitr = adapter->tx_eitr_param; |
1997 | else | 2044 | else |
1998 | /* rx only or mixed */ | 2045 | /* rx only or mixed */ |
1999 | q_vector->eitr = adapter->eitr_param; | 2046 | q_vector->eitr = adapter->rx_eitr_param; |
2000 | ixgbe_write_eitr(q_vector); | 2047 | ixgbe_write_eitr(q_vector); |
2001 | } | 2048 | } |
2002 | /* Legacy Interrupt Mode */ | 2049 | /* Legacy Interrupt Mode */ |
2003 | } else { | 2050 | } else { |
2004 | q_vector = adapter->q_vector[0]; | 2051 | q_vector = adapter->q_vector[0]; |
2005 | q_vector->eitr = adapter->eitr_param; | 2052 | q_vector->eitr = adapter->rx_eitr_param; |
2006 | ixgbe_write_eitr(q_vector); | 2053 | ixgbe_write_eitr(q_vector); |
2007 | } | 2054 | } |
2008 | 2055 | ||
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 45bf8b9716e3..c407bd9de0dd 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -97,6 +97,8 @@ static struct pci_device_id ixgbe_pci_tbl[] = { | |||
97 | board_82599 }, | 97 | board_82599 }, |
98 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP), | 98 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP), |
99 | board_82599 }, | 99 | board_82599 }, |
100 | {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_CX4), | ||
101 | board_82599 }, | ||
100 | 102 | ||
101 | /* required last entry */ | 103 | /* required last entry */ |
102 | {0, } | 104 | {0, } |
@@ -924,12 +926,12 @@ static void ixgbe_configure_msix(struct ixgbe_adapter *adapter) | |||
924 | r_idx + 1); | 926 | r_idx + 1); |
925 | } | 927 | } |
926 | 928 | ||
927 | /* if this is a tx only vector halve the interrupt rate */ | ||
928 | if (q_vector->txr_count && !q_vector->rxr_count) | 929 | if (q_vector->txr_count && !q_vector->rxr_count) |
929 | q_vector->eitr = (adapter->eitr_param >> 1); | 930 | /* tx only */ |
931 | q_vector->eitr = adapter->tx_eitr_param; | ||
930 | else if (q_vector->rxr_count) | 932 | else if (q_vector->rxr_count) |
931 | /* rx only */ | 933 | /* rx or mixed */ |
932 | q_vector->eitr = adapter->eitr_param; | 934 | q_vector->eitr = adapter->rx_eitr_param; |
933 | 935 | ||
934 | ixgbe_write_eitr(q_vector); | 936 | ixgbe_write_eitr(q_vector); |
935 | } | 937 | } |
@@ -1357,7 +1359,7 @@ static int ixgbe_clean_rxonly(struct napi_struct *napi, int budget) | |||
1357 | /* If all Rx work done, exit the polling mode */ | 1359 | /* If all Rx work done, exit the polling mode */ |
1358 | if (work_done < budget) { | 1360 | if (work_done < budget) { |
1359 | napi_complete(napi); | 1361 | napi_complete(napi); |
1360 | if (adapter->itr_setting & 1) | 1362 | if (adapter->rx_itr_setting & 1) |
1361 | ixgbe_set_itr_msix(q_vector); | 1363 | ixgbe_set_itr_msix(q_vector); |
1362 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) | 1364 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
1363 | ixgbe_irq_enable_queues(adapter, | 1365 | ixgbe_irq_enable_queues(adapter, |
@@ -1418,7 +1420,7 @@ static int ixgbe_clean_rxtx_many(struct napi_struct *napi, int budget) | |||
1418 | /* If all Rx work done, exit the polling mode */ | 1420 | /* If all Rx work done, exit the polling mode */ |
1419 | if (work_done < budget) { | 1421 | if (work_done < budget) { |
1420 | napi_complete(napi); | 1422 | napi_complete(napi); |
1421 | if (adapter->itr_setting & 1) | 1423 | if (adapter->rx_itr_setting & 1) |
1422 | ixgbe_set_itr_msix(q_vector); | 1424 | ixgbe_set_itr_msix(q_vector); |
1423 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) | 1425 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
1424 | ixgbe_irq_enable_queues(adapter, | 1426 | ixgbe_irq_enable_queues(adapter, |
@@ -1456,10 +1458,10 @@ static int ixgbe_clean_txonly(struct napi_struct *napi, int budget) | |||
1456 | if (!ixgbe_clean_tx_irq(q_vector, tx_ring)) | 1458 | if (!ixgbe_clean_tx_irq(q_vector, tx_ring)) |
1457 | work_done = budget; | 1459 | work_done = budget; |
1458 | 1460 | ||
1459 | /* If all Rx work done, exit the polling mode */ | 1461 | /* If all Tx work done, exit the polling mode */ |
1460 | if (work_done < budget) { | 1462 | if (work_done < budget) { |
1461 | napi_complete(napi); | 1463 | napi_complete(napi); |
1462 | if (adapter->itr_setting & 1) | 1464 | if (adapter->tx_itr_setting & 1) |
1463 | ixgbe_set_itr_msix(q_vector); | 1465 | ixgbe_set_itr_msix(q_vector); |
1464 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) | 1466 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
1465 | ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx)); | 1467 | ixgbe_irq_enable_queues(adapter, ((u64)1 << q_vector->v_idx)); |
@@ -1846,7 +1848,7 @@ static void ixgbe_configure_msi_and_legacy(struct ixgbe_adapter *adapter) | |||
1846 | struct ixgbe_hw *hw = &adapter->hw; | 1848 | struct ixgbe_hw *hw = &adapter->hw; |
1847 | 1849 | ||
1848 | IXGBE_WRITE_REG(hw, IXGBE_EITR(0), | 1850 | IXGBE_WRITE_REG(hw, IXGBE_EITR(0), |
1849 | EITR_INTS_PER_SEC_TO_REG(adapter->eitr_param)); | 1851 | EITR_INTS_PER_SEC_TO_REG(adapter->rx_eitr_param)); |
1850 | 1852 | ||
1851 | ixgbe_set_ivar(adapter, 0, 0, 0); | 1853 | ixgbe_set_ivar(adapter, 0, 0, 0); |
1852 | ixgbe_set_ivar(adapter, 1, 0, 0); | 1854 | ixgbe_set_ivar(adapter, 1, 0, 0); |
@@ -1968,6 +1970,50 @@ static u32 ixgbe_setup_mrqc(struct ixgbe_adapter *adapter) | |||
1968 | } | 1970 | } |
1969 | 1971 | ||
1970 | /** | 1972 | /** |
1973 | * ixgbe_configure_rscctl - enable RSC for the indicated ring | ||
1974 | * @adapter: address of board private structure | ||
1975 | * @index: index of ring to set | ||
1976 | * @rx_buf_len: rx buffer length | ||
1977 | **/ | ||
1978 | static void ixgbe_configure_rscctl(struct ixgbe_adapter *adapter, int index, | ||
1979 | int rx_buf_len) | ||
1980 | { | ||
1981 | struct ixgbe_ring *rx_ring; | ||
1982 | struct ixgbe_hw *hw = &adapter->hw; | ||
1983 | int j; | ||
1984 | u32 rscctrl; | ||
1985 | |||
1986 | rx_ring = &adapter->rx_ring[index]; | ||
1987 | j = rx_ring->reg_idx; | ||
1988 | rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j)); | ||
1989 | rscctrl |= IXGBE_RSCCTL_RSCEN; | ||
1990 | /* | ||
1991 | * we must limit the number of descriptors so that the | ||
1992 | * total size of max desc * buf_len is not greater | ||
1993 | * than 65535 | ||
1994 | */ | ||
1995 | if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) { | ||
1996 | #if (MAX_SKB_FRAGS > 16) | ||
1997 | rscctrl |= IXGBE_RSCCTL_MAXDESC_16; | ||
1998 | #elif (MAX_SKB_FRAGS > 8) | ||
1999 | rscctrl |= IXGBE_RSCCTL_MAXDESC_8; | ||
2000 | #elif (MAX_SKB_FRAGS > 4) | ||
2001 | rscctrl |= IXGBE_RSCCTL_MAXDESC_4; | ||
2002 | #else | ||
2003 | rscctrl |= IXGBE_RSCCTL_MAXDESC_1; | ||
2004 | #endif | ||
2005 | } else { | ||
2006 | if (rx_buf_len < IXGBE_RXBUFFER_4096) | ||
2007 | rscctrl |= IXGBE_RSCCTL_MAXDESC_16; | ||
2008 | else if (rx_buf_len < IXGBE_RXBUFFER_8192) | ||
2009 | rscctrl |= IXGBE_RSCCTL_MAXDESC_8; | ||
2010 | else | ||
2011 | rscctrl |= IXGBE_RSCCTL_MAXDESC_4; | ||
2012 | } | ||
2013 | IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(j), rscctrl); | ||
2014 | } | ||
2015 | |||
2016 | /** | ||
1971 | * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset | 2017 | * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset |
1972 | * @adapter: board private structure | 2018 | * @adapter: board private structure |
1973 | * | 2019 | * |
@@ -1988,7 +2034,6 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | |||
1988 | u32 fctrl, hlreg0; | 2034 | u32 fctrl, hlreg0; |
1989 | u32 reta = 0, mrqc = 0; | 2035 | u32 reta = 0, mrqc = 0; |
1990 | u32 rdrxctl; | 2036 | u32 rdrxctl; |
1991 | u32 rscctrl; | ||
1992 | int rx_buf_len; | 2037 | int rx_buf_len; |
1993 | 2038 | ||
1994 | /* Decide whether to use packet split mode or not */ | 2039 | /* Decide whether to use packet split mode or not */ |
@@ -2055,6 +2100,8 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | |||
2055 | 2100 | ||
2056 | if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) | 2101 | if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) |
2057 | rx_ring->flags |= IXGBE_RING_RX_PS_ENABLED; | 2102 | rx_ring->flags |= IXGBE_RING_RX_PS_ENABLED; |
2103 | else | ||
2104 | rx_ring->flags &= ~IXGBE_RING_RX_PS_ENABLED; | ||
2058 | 2105 | ||
2059 | #ifdef IXGBE_FCOE | 2106 | #ifdef IXGBE_FCOE |
2060 | if (netdev->features & NETIF_F_FCOE_MTU) { | 2107 | if (netdev->features & NETIF_F_FCOE_MTU) { |
@@ -2144,36 +2191,9 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | |||
2144 | 2191 | ||
2145 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { | 2192 | if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { |
2146 | /* Enable 82599 HW-RSC */ | 2193 | /* Enable 82599 HW-RSC */ |
2147 | for (i = 0; i < adapter->num_rx_queues; i++) { | 2194 | for (i = 0; i < adapter->num_rx_queues; i++) |
2148 | rx_ring = &adapter->rx_ring[i]; | 2195 | ixgbe_configure_rscctl(adapter, i, rx_buf_len); |
2149 | j = rx_ring->reg_idx; | 2196 | |
2150 | rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j)); | ||
2151 | rscctrl |= IXGBE_RSCCTL_RSCEN; | ||
2152 | /* | ||
2153 | * we must limit the number of descriptors so that the | ||
2154 | * total size of max desc * buf_len is not greater | ||
2155 | * than 65535 | ||
2156 | */ | ||
2157 | if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) { | ||
2158 | #if (MAX_SKB_FRAGS > 16) | ||
2159 | rscctrl |= IXGBE_RSCCTL_MAXDESC_16; | ||
2160 | #elif (MAX_SKB_FRAGS > 8) | ||
2161 | rscctrl |= IXGBE_RSCCTL_MAXDESC_8; | ||
2162 | #elif (MAX_SKB_FRAGS > 4) | ||
2163 | rscctrl |= IXGBE_RSCCTL_MAXDESC_4; | ||
2164 | #else | ||
2165 | rscctrl |= IXGBE_RSCCTL_MAXDESC_1; | ||
2166 | #endif | ||
2167 | } else { | ||
2168 | if (rx_buf_len < IXGBE_RXBUFFER_4096) | ||
2169 | rscctrl |= IXGBE_RSCCTL_MAXDESC_16; | ||
2170 | else if (rx_buf_len < IXGBE_RXBUFFER_8192) | ||
2171 | rscctrl |= IXGBE_RSCCTL_MAXDESC_8; | ||
2172 | else | ||
2173 | rscctrl |= IXGBE_RSCCTL_MAXDESC_4; | ||
2174 | } | ||
2175 | IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(j), rscctrl); | ||
2176 | } | ||
2177 | /* Disable RSC for ACK packets */ | 2197 | /* Disable RSC for ACK packets */ |
2178 | IXGBE_WRITE_REG(hw, IXGBE_RSCDBU, | 2198 | IXGBE_WRITE_REG(hw, IXGBE_RSCDBU, |
2179 | (IXGBE_RSCDBU_RSCACKDIS | IXGBE_READ_REG(hw, IXGBE_RSCDBU))); | 2199 | (IXGBE_RSCDBU_RSCACKDIS | IXGBE_READ_REG(hw, IXGBE_RSCDBU))); |
@@ -2922,6 +2942,8 @@ void ixgbe_down(struct ixgbe_adapter *adapter) | |||
2922 | 2942 | ||
2923 | ixgbe_napi_disable_all(adapter); | 2943 | ixgbe_napi_disable_all(adapter); |
2924 | 2944 | ||
2945 | clear_bit(__IXGBE_SFP_MODULE_NOT_FOUND, &adapter->state); | ||
2946 | del_timer_sync(&adapter->sfp_timer); | ||
2925 | del_timer_sync(&adapter->watchdog_timer); | 2947 | del_timer_sync(&adapter->watchdog_timer); |
2926 | cancel_work_sync(&adapter->watchdog_task); | 2948 | cancel_work_sync(&adapter->watchdog_task); |
2927 | 2949 | ||
@@ -2985,7 +3007,7 @@ static int ixgbe_poll(struct napi_struct *napi, int budget) | |||
2985 | /* If budget not fully consumed, exit the polling mode */ | 3007 | /* If budget not fully consumed, exit the polling mode */ |
2986 | if (work_done < budget) { | 3008 | if (work_done < budget) { |
2987 | napi_complete(napi); | 3009 | napi_complete(napi); |
2988 | if (adapter->itr_setting & 1) | 3010 | if (adapter->rx_itr_setting & 1) |
2989 | ixgbe_set_itr(adapter); | 3011 | ixgbe_set_itr(adapter); |
2990 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) | 3012 | if (!test_bit(__IXGBE_DOWN, &adapter->state)) |
2991 | ixgbe_irq_enable_queues(adapter, IXGBE_EIMS_RTX_QUEUE); | 3013 | ixgbe_irq_enable_queues(adapter, IXGBE_EIMS_RTX_QUEUE); |
@@ -3595,7 +3617,10 @@ static int ixgbe_alloc_q_vectors(struct ixgbe_adapter *adapter) | |||
3595 | if (!q_vector) | 3617 | if (!q_vector) |
3596 | goto err_out; | 3618 | goto err_out; |
3597 | q_vector->adapter = adapter; | 3619 | q_vector->adapter = adapter; |
3598 | q_vector->eitr = adapter->eitr_param; | 3620 | if (q_vector->txr_count && !q_vector->rxr_count) |
3621 | q_vector->eitr = adapter->tx_eitr_param; | ||
3622 | else | ||
3623 | q_vector->eitr = adapter->rx_eitr_param; | ||
3599 | q_vector->v_idx = q_idx; | 3624 | q_vector->v_idx = q_idx; |
3600 | netif_napi_add(adapter->netdev, &q_vector->napi, (*poll), 64); | 3625 | netif_napi_add(adapter->netdev, &q_vector->napi, (*poll), 64); |
3601 | adapter->q_vector[q_idx] = q_vector; | 3626 | adapter->q_vector[q_idx] = q_vector; |
@@ -3864,8 +3889,10 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) | |||
3864 | hw->fc.disable_fc_autoneg = false; | 3889 | hw->fc.disable_fc_autoneg = false; |
3865 | 3890 | ||
3866 | /* enable itr by default in dynamic mode */ | 3891 | /* enable itr by default in dynamic mode */ |
3867 | adapter->itr_setting = 1; | 3892 | adapter->rx_itr_setting = 1; |
3868 | adapter->eitr_param = 20000; | 3893 | adapter->rx_eitr_param = 20000; |
3894 | adapter->tx_itr_setting = 1; | ||
3895 | adapter->tx_eitr_param = 10000; | ||
3869 | 3896 | ||
3870 | /* set defaults for eitr in MegaBytes */ | 3897 | /* set defaults for eitr in MegaBytes */ |
3871 | adapter->eitr_low = 10; | 3898 | adapter->eitr_low = 10; |
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h index 8ba90eec1dc9..8761d7899f7d 100644 --- a/drivers/net/ixgbe/ixgbe_type.h +++ b/drivers/net/ixgbe/ixgbe_type.h | |||
@@ -49,6 +49,7 @@ | |||
49 | #define IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM 0x10E1 | 49 | #define IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM 0x10E1 |
50 | #define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4 | 50 | #define IXGBE_DEV_ID_82598EB_XF_LR 0x10F4 |
51 | #define IXGBE_DEV_ID_82599_KX4 0x10F7 | 51 | #define IXGBE_DEV_ID_82599_KX4 0x10F7 |
52 | #define IXGBE_DEV_ID_82599_CX4 0x10F9 | ||
52 | #define IXGBE_DEV_ID_82599_SFP 0x10FB | 53 | #define IXGBE_DEV_ID_82599_SFP 0x10FB |
53 | #define IXGBE_DEV_ID_82599_XAUI_LOM 0x10FC | 54 | #define IXGBE_DEV_ID_82599_XAUI_LOM 0x10FC |
54 | 55 | ||
@@ -2143,6 +2144,7 @@ enum ixgbe_media_type { | |||
2143 | ixgbe_media_type_fiber, | 2144 | ixgbe_media_type_fiber, |
2144 | ixgbe_media_type_copper, | 2145 | ixgbe_media_type_copper, |
2145 | ixgbe_media_type_backplane, | 2146 | ixgbe_media_type_backplane, |
2147 | ixgbe_media_type_cx4, | ||
2146 | ixgbe_media_type_virtual | 2148 | ixgbe_media_type_virtual |
2147 | }; | 2149 | }; |
2148 | 2150 | ||
diff --git a/drivers/net/mlx4/catas.c b/drivers/net/mlx4/catas.c index aa9674b7f19c..f599294fa8ab 100644 --- a/drivers/net/mlx4/catas.c +++ b/drivers/net/mlx4/catas.c | |||
@@ -96,12 +96,17 @@ static void catas_reset(struct work_struct *work) | |||
96 | spin_unlock_irq(&catas_lock); | 96 | spin_unlock_irq(&catas_lock); |
97 | 97 | ||
98 | list_for_each_entry_safe(priv, tmppriv, &tlist, catas_err.list) { | 98 | list_for_each_entry_safe(priv, tmppriv, &tlist, catas_err.list) { |
99 | struct pci_dev *pdev = priv->dev.pdev; | ||
100 | |||
99 | ret = mlx4_restart_one(priv->dev.pdev); | 101 | ret = mlx4_restart_one(priv->dev.pdev); |
100 | dev = &priv->dev; | 102 | /* 'priv' now is not valid */ |
101 | if (ret) | 103 | if (ret) |
102 | mlx4_err(dev, "Reset failed (%d)\n", ret); | 104 | printk(KERN_ERR "mlx4 %s: Reset failed (%d)\n", |
103 | else | 105 | pci_name(pdev), ret); |
106 | else { | ||
107 | dev = pci_get_drvdata(pdev); | ||
104 | mlx4_dbg(dev, "Reset succeeded\n"); | 108 | mlx4_dbg(dev, "Reset succeeded\n"); |
109 | } | ||
105 | } | 110 | } |
106 | } | 111 | } |
107 | 112 | ||
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index f7bdde111dfc..b5aa974827e5 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -1469,6 +1469,7 @@ netxen_nic_resume(struct pci_dev *pdev) | |||
1469 | } | 1469 | } |
1470 | 1470 | ||
1471 | netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY); | 1471 | netxen_schedule_work(adapter, netxen_fw_poll_work, FW_POLL_DELAY); |
1472 | return 0; | ||
1472 | 1473 | ||
1473 | err_out_detach: | 1474 | err_out_detach: |
1474 | netxen_nic_detach(adapter); | 1475 | netxen_nic_detach(adapter); |
@@ -1903,12 +1904,13 @@ static void netxen_tx_timeout_task(struct work_struct *work) | |||
1903 | 1904 | ||
1904 | netif_wake_queue(adapter->netdev); | 1905 | netif_wake_queue(adapter->netdev); |
1905 | 1906 | ||
1906 | goto done; | 1907 | clear_bit(__NX_RESETTING, &adapter->state); |
1907 | 1908 | ||
1908 | } else { | 1909 | } else { |
1910 | clear_bit(__NX_RESETTING, &adapter->state); | ||
1909 | if (!netxen_nic_reset_context(adapter)) { | 1911 | if (!netxen_nic_reset_context(adapter)) { |
1910 | adapter->netdev->trans_start = jiffies; | 1912 | adapter->netdev->trans_start = jiffies; |
1911 | goto done; | 1913 | return; |
1912 | } | 1914 | } |
1913 | 1915 | ||
1914 | /* context reset failed, fall through for fw reset */ | 1916 | /* context reset failed, fall through for fw reset */ |
@@ -1916,8 +1918,6 @@ static void netxen_tx_timeout_task(struct work_struct *work) | |||
1916 | 1918 | ||
1917 | request_reset: | 1919 | request_reset: |
1918 | adapter->need_fw_reset = 1; | 1920 | adapter->need_fw_reset = 1; |
1919 | done: | ||
1920 | clear_bit(__NX_RESETTING, &adapter->state); | ||
1921 | } | 1921 | } |
1922 | 1922 | ||
1923 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) | 1923 | struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 90a94d215831..474876c879cb 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -340,12 +340,11 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) | |||
340 | base = &virt[hw_info[i].offset & (req.Size-1)]; | 340 | base = &virt[hw_info[i].offset & (req.Size-1)]; |
341 | if ((readb(base+0) == hw_info[i].a0) && | 341 | if ((readb(base+0) == hw_info[i].a0) && |
342 | (readb(base+2) == hw_info[i].a1) && | 342 | (readb(base+2) == hw_info[i].a1) && |
343 | (readb(base+4) == hw_info[i].a2)) | 343 | (readb(base+4) == hw_info[i].a2)) { |
344 | break; | 344 | for (j = 0; j < 6; j++) |
345 | } | 345 | dev->dev_addr[j] = readb(base + (j<<1)); |
346 | if (i < NR_INFO) { | 346 | break; |
347 | for (j = 0; j < 6; j++) | 347 | } |
348 | dev->dev_addr[j] = readb(base + (j<<1)); | ||
349 | } | 348 | } |
350 | 349 | ||
351 | iounmap(virt); | 350 | iounmap(virt); |
@@ -1750,11 +1749,11 @@ static struct pcmcia_device_id pcnet_ids[] = { | |||
1750 | PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078), | 1749 | PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078), |
1751 | /* too generic! */ | 1750 | /* too generic! */ |
1752 | /* PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100 Ethernet Card", 0x281f1c5d, 0x11b0ffc0), */ | 1751 | /* PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100 Ethernet Card", 0x281f1c5d, 0x11b0ffc0), */ |
1753 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), | 1752 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "cis/PCMLM28.cis"), |
1754 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), | 1753 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "cis/PCMLM28.cis"), |
1755 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), | 1754 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"), |
1756 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"), | 1755 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"), |
1757 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"), | 1756 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"), |
1758 | PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), | 1757 | PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), |
1759 | PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), | 1758 | PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), |
1760 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "DP83903.cis"), | 1759 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "DP83903.cis"), |
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c index e0f9219a0aea..cc394d073755 100644 --- a/drivers/net/pppol2tp.c +++ b/drivers/net/pppol2tp.c | |||
@@ -229,7 +229,7 @@ static void pppol2tp_tunnel_free(struct pppol2tp_tunnel *tunnel); | |||
229 | static atomic_t pppol2tp_tunnel_count; | 229 | static atomic_t pppol2tp_tunnel_count; |
230 | static atomic_t pppol2tp_session_count; | 230 | static atomic_t pppol2tp_session_count; |
231 | static struct ppp_channel_ops pppol2tp_chan_ops = { pppol2tp_xmit , NULL }; | 231 | static struct ppp_channel_ops pppol2tp_chan_ops = { pppol2tp_xmit , NULL }; |
232 | static struct proto_ops pppol2tp_ops; | 232 | static const struct proto_ops pppol2tp_ops; |
233 | 233 | ||
234 | /* per-net private data for this module */ | 234 | /* per-net private data for this module */ |
235 | static int pppol2tp_net_id; | 235 | static int pppol2tp_net_id; |
@@ -2574,7 +2574,7 @@ static const struct file_operations pppol2tp_proc_fops = { | |||
2574 | * Init and cleanup | 2574 | * Init and cleanup |
2575 | *****************************************************************************/ | 2575 | *****************************************************************************/ |
2576 | 2576 | ||
2577 | static struct proto_ops pppol2tp_ops = { | 2577 | static const struct proto_ops pppol2tp_ops = { |
2578 | .family = AF_PPPOX, | 2578 | .family = AF_PPPOX, |
2579 | .owner = THIS_MODULE, | 2579 | .owner = THIS_MODULE, |
2580 | .release = pppol2tp_release, | 2580 | .release = pppol2tp_release, |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 00bc65a0aac9..68d256b9638c 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -65,8 +65,8 @@ | |||
65 | #define RX_DEF_PENDING RX_MAX_PENDING | 65 | #define RX_DEF_PENDING RX_MAX_PENDING |
66 | 66 | ||
67 | /* This is the worst case number of transmit list elements for a single skb: | 67 | /* This is the worst case number of transmit list elements for a single skb: |
68 | VLAN + TSO + CKSUM + Data + skb_frags * DMA */ | 68 | VLAN:GSO + CKSUM + Data + skb_frags * DMA */ |
69 | #define MAX_SKB_TX_LE (4 + (sizeof(dma_addr_t)/sizeof(u32))*MAX_SKB_FRAGS) | 69 | #define MAX_SKB_TX_LE (2 + (sizeof(dma_addr_t)/sizeof(u32))*(MAX_SKB_FRAGS+1)) |
70 | #define TX_MIN_PENDING (MAX_SKB_TX_LE+1) | 70 | #define TX_MIN_PENDING (MAX_SKB_TX_LE+1) |
71 | #define TX_MAX_PENDING 4096 | 71 | #define TX_MAX_PENDING 4096 |
72 | #define TX_DEF_PENDING 127 | 72 | #define TX_DEF_PENDING 127 |
@@ -1497,7 +1497,6 @@ static int sky2_up(struct net_device *dev) | |||
1497 | if (ramsize > 0) { | 1497 | if (ramsize > 0) { |
1498 | u32 rxspace; | 1498 | u32 rxspace; |
1499 | 1499 | ||
1500 | hw->flags |= SKY2_HW_RAM_BUFFER; | ||
1501 | pr_debug(PFX "%s: ram buffer %dK\n", dev->name, ramsize); | 1500 | pr_debug(PFX "%s: ram buffer %dK\n", dev->name, ramsize); |
1502 | if (ramsize < 16) | 1501 | if (ramsize < 16) |
1503 | rxspace = ramsize / 2; | 1502 | rxspace = ramsize / 2; |
@@ -1567,11 +1566,13 @@ static unsigned tx_le_req(const struct sk_buff *skb) | |||
1567 | { | 1566 | { |
1568 | unsigned count; | 1567 | unsigned count; |
1569 | 1568 | ||
1570 | count = sizeof(dma_addr_t) / sizeof(u32); | 1569 | count = (skb_shinfo(skb)->nr_frags + 1) |
1571 | count += skb_shinfo(skb)->nr_frags * count; | 1570 | * (sizeof(dma_addr_t) / sizeof(u32)); |
1572 | 1571 | ||
1573 | if (skb_is_gso(skb)) | 1572 | if (skb_is_gso(skb)) |
1574 | ++count; | 1573 | ++count; |
1574 | else if (sizeof(dma_addr_t) == sizeof(u32)) | ||
1575 | ++count; /* possible vlan */ | ||
1575 | 1576 | ||
1576 | if (skb->ip_summed == CHECKSUM_PARTIAL) | 1577 | if (skb->ip_summed == CHECKSUM_PARTIAL) |
1577 | ++count; | 1578 | ++count; |
@@ -2924,6 +2925,9 @@ static int __devinit sky2_init(struct sky2_hw *hw) | |||
2924 | ++hw->ports; | 2925 | ++hw->ports; |
2925 | } | 2926 | } |
2926 | 2927 | ||
2928 | if (sky2_read8(hw, B2_E_0)) | ||
2929 | hw->flags |= SKY2_HW_RAM_BUFFER; | ||
2930 | |||
2927 | return 0; | 2931 | return 0; |
2928 | } | 2932 | } |
2929 | 2933 | ||
@@ -4548,16 +4552,18 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
4548 | if (hw->ports > 1) { | 4552 | if (hw->ports > 1) { |
4549 | struct net_device *dev1; | 4553 | struct net_device *dev1; |
4550 | 4554 | ||
4555 | err = -ENOMEM; | ||
4551 | dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default); | 4556 | dev1 = sky2_init_netdev(hw, 1, using_dac, wol_default); |
4552 | if (!dev1) | 4557 | if (dev1 && (err = register_netdev(dev1)) == 0) |
4553 | dev_warn(&pdev->dev, "allocation for second device failed\n"); | 4558 | sky2_show_addr(dev1); |
4554 | else if ((err = register_netdev(dev1))) { | 4559 | else { |
4555 | dev_warn(&pdev->dev, | 4560 | dev_warn(&pdev->dev, |
4556 | "register of second port failed (%d)\n", err); | 4561 | "register of second port failed (%d)\n", err); |
4557 | hw->dev[1] = NULL; | 4562 | hw->dev[1] = NULL; |
4558 | free_netdev(dev1); | 4563 | hw->ports = 1; |
4559 | } else | 4564 | if (dev1) |
4560 | sky2_show_addr(dev1); | 4565 | free_netdev(dev1); |
4566 | } | ||
4561 | } | 4567 | } |
4562 | 4568 | ||
4563 | setup_timer(&hw->watchdog_timer, sky2_watchdog, (unsigned long) hw); | 4569 | setup_timer(&hw->watchdog_timer, sky2_watchdog, (unsigned long) hw); |
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h index 57a159fac99f..9c8c6ed4a3cd 100644 --- a/drivers/net/smc91x.h +++ b/drivers/net/smc91x.h | |||
@@ -83,34 +83,6 @@ static inline void SMC_outw(u16 val, void __iomem *ioaddr, int reg) | |||
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | #elif defined(CONFIG_BLACKFIN) | ||
87 | |||
88 | #define SMC_IRQ_FLAGS IRQF_TRIGGER_HIGH | ||
89 | #define RPC_LSA_DEFAULT RPC_LED_100_10 | ||
90 | #define RPC_LSB_DEFAULT RPC_LED_TX_RX | ||
91 | |||
92 | #define SMC_CAN_USE_8BIT 0 | ||
93 | #define SMC_CAN_USE_16BIT 1 | ||
94 | # if defined(CONFIG_BF561) | ||
95 | #define SMC_CAN_USE_32BIT 1 | ||
96 | # else | ||
97 | #define SMC_CAN_USE_32BIT 0 | ||
98 | # endif | ||
99 | #define SMC_IO_SHIFT 0 | ||
100 | #define SMC_NOWAIT 1 | ||
101 | #define SMC_USE_BFIN_DMA 0 | ||
102 | |||
103 | #define SMC_inw(a, r) readw((a) + (r)) | ||
104 | #define SMC_outw(v, a, r) writew(v, (a) + (r)) | ||
105 | #define SMC_insw(a, r, p, l) readsw((a) + (r), p, l) | ||
106 | #define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l) | ||
107 | # if SMC_CAN_USE_32BIT | ||
108 | #define SMC_inl(a, r) readl((a) + (r)) | ||
109 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) | ||
110 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) | ||
111 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) | ||
112 | # endif | ||
113 | |||
114 | #elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6) | 86 | #elif defined(CONFIG_REDWOOD_5) || defined(CONFIG_REDWOOD_6) |
115 | 87 | ||
116 | /* We can only do 16-bit reads and writes in the static memory space. */ | 88 | /* We can only do 16-bit reads and writes in the static memory space. */ |
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c index f1e5e4542c2a..bc74db0d12f3 100644 --- a/drivers/net/sunvnet.c +++ b/drivers/net/sunvnet.c | |||
@@ -1016,7 +1016,6 @@ static const struct net_device_ops vnet_ops = { | |||
1016 | .ndo_open = vnet_open, | 1016 | .ndo_open = vnet_open, |
1017 | .ndo_stop = vnet_close, | 1017 | .ndo_stop = vnet_close, |
1018 | .ndo_set_multicast_list = vnet_set_rx_mode, | 1018 | .ndo_set_multicast_list = vnet_set_rx_mode, |
1019 | .ndo_change_mtu = eth_change_mtu, | ||
1020 | .ndo_set_mac_address = vnet_set_mac_addr, | 1019 | .ndo_set_mac_address = vnet_set_mac_addr, |
1021 | .ndo_validate_addr = eth_validate_addr, | 1020 | .ndo_validate_addr = eth_validate_addr, |
1022 | .ndo_tx_timeout = vnet_tx_timeout, | 1021 | .ndo_tx_timeout = vnet_tx_timeout, |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 3f5d28851aa2..e091756166a3 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -946,8 +946,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
946 | char *name; | 946 | char *name; |
947 | unsigned long flags = 0; | 947 | unsigned long flags = 0; |
948 | 948 | ||
949 | err = -EINVAL; | ||
950 | |||
951 | if (!capable(CAP_NET_ADMIN)) | 949 | if (!capable(CAP_NET_ADMIN)) |
952 | return -EPERM; | 950 | return -EPERM; |
953 | err = security_tun_dev_create(); | 951 | err = security_tun_dev_create(); |
@@ -964,7 +962,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
964 | flags |= TUN_TAP_DEV; | 962 | flags |= TUN_TAP_DEV; |
965 | name = "tap%d"; | 963 | name = "tap%d"; |
966 | } else | 964 | } else |
967 | goto failed; | 965 | return -EINVAL; |
968 | 966 | ||
969 | if (*ifr->ifr_name) | 967 | if (*ifr->ifr_name) |
970 | name = ifr->ifr_name; | 968 | name = ifr->ifr_name; |
diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c index 97e54d9d03ce..33d5c579c5ad 100644 --- a/drivers/net/usb/cdc-phonet.c +++ b/drivers/net/usb/cdc-phonet.c | |||
@@ -264,7 +264,6 @@ static int usbpn_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
264 | switch (cmd) { | 264 | switch (cmd) { |
265 | case SIOCPNGAUTOCONF: | 265 | case SIOCPNGAUTOCONF: |
266 | req->ifr_phonet_autoconf.device = PN_DEV_PC; | 266 | req->ifr_phonet_autoconf.device = PN_DEV_PC; |
267 | printk(KERN_CRIT"device is PN_DEV_PC\n"); | ||
268 | return 0; | 267 | return 0; |
269 | } | 268 | } |
270 | return -ENOIOCTLCMD; | 269 | return -ENOIOCTLCMD; |
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index e2a39b9be96e..e391ef969c28 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
@@ -263,6 +263,7 @@ static int kaweth_control(struct kaweth_device *kaweth, | |||
263 | int timeout) | 263 | int timeout) |
264 | { | 264 | { |
265 | struct usb_ctrlrequest *dr; | 265 | struct usb_ctrlrequest *dr; |
266 | int retval; | ||
266 | 267 | ||
267 | dbg("kaweth_control()"); | 268 | dbg("kaweth_control()"); |
268 | 269 | ||
@@ -278,18 +279,21 @@ static int kaweth_control(struct kaweth_device *kaweth, | |||
278 | return -ENOMEM; | 279 | return -ENOMEM; |
279 | } | 280 | } |
280 | 281 | ||
281 | dr->bRequestType= requesttype; | 282 | dr->bRequestType = requesttype; |
282 | dr->bRequest = request; | 283 | dr->bRequest = request; |
283 | dr->wValue = cpu_to_le16(value); | 284 | dr->wValue = cpu_to_le16(value); |
284 | dr->wIndex = cpu_to_le16(index); | 285 | dr->wIndex = cpu_to_le16(index); |
285 | dr->wLength = cpu_to_le16(size); | 286 | dr->wLength = cpu_to_le16(size); |
286 | 287 | ||
287 | return kaweth_internal_control_msg(kaweth->dev, | 288 | retval = kaweth_internal_control_msg(kaweth->dev, |
288 | pipe, | 289 | pipe, |
289 | dr, | 290 | dr, |
290 | data, | 291 | data, |
291 | size, | 292 | size, |
292 | timeout); | 293 | timeout); |
294 | |||
295 | kfree(dr); | ||
296 | return retval; | ||
293 | } | 297 | } |
294 | 298 | ||
295 | /**************************************************************** | 299 | /**************************************************************** |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 938fb3530a7a..c6c922247d05 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
@@ -1227,7 +1227,7 @@ static const struct driver_info smsc95xx_info = { | |||
1227 | .rx_fixup = smsc95xx_rx_fixup, | 1227 | .rx_fixup = smsc95xx_rx_fixup, |
1228 | .tx_fixup = smsc95xx_tx_fixup, | 1228 | .tx_fixup = smsc95xx_tx_fixup, |
1229 | .status = smsc95xx_status, | 1229 | .status = smsc95xx_status, |
1230 | .flags = FLAG_ETHER, | 1230 | .flags = FLAG_ETHER | FLAG_SEND_ZLP, |
1231 | }; | 1231 | }; |
1232 | 1232 | ||
1233 | static const struct usb_device_id products[] = { | 1233 | static const struct usb_device_id products[] = { |
@@ -1237,10 +1237,75 @@ static const struct usb_device_id products[] = { | |||
1237 | .driver_info = (unsigned long) &smsc95xx_info, | 1237 | .driver_info = (unsigned long) &smsc95xx_info, |
1238 | }, | 1238 | }, |
1239 | { | 1239 | { |
1240 | /* SMSC9505 USB Ethernet Device */ | ||
1241 | USB_DEVICE(0x0424, 0x9505), | ||
1242 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1243 | }, | ||
1244 | { | ||
1245 | /* SMSC9500A USB Ethernet Device */ | ||
1246 | USB_DEVICE(0x0424, 0x9E00), | ||
1247 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1248 | }, | ||
1249 | { | ||
1250 | /* SMSC9505A USB Ethernet Device */ | ||
1251 | USB_DEVICE(0x0424, 0x9E01), | ||
1252 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1253 | }, | ||
1254 | { | ||
1240 | /* SMSC9512/9514 USB Hub & Ethernet Device */ | 1255 | /* SMSC9512/9514 USB Hub & Ethernet Device */ |
1241 | USB_DEVICE(0x0424, 0xec00), | 1256 | USB_DEVICE(0x0424, 0xec00), |
1242 | .driver_info = (unsigned long) &smsc95xx_info, | 1257 | .driver_info = (unsigned long) &smsc95xx_info, |
1243 | }, | 1258 | }, |
1259 | { | ||
1260 | /* SMSC9500 USB Ethernet Device (SAL10) */ | ||
1261 | USB_DEVICE(0x0424, 0x9900), | ||
1262 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1263 | }, | ||
1264 | { | ||
1265 | /* SMSC9505 USB Ethernet Device (SAL10) */ | ||
1266 | USB_DEVICE(0x0424, 0x9901), | ||
1267 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1268 | }, | ||
1269 | { | ||
1270 | /* SMSC9500A USB Ethernet Device (SAL10) */ | ||
1271 | USB_DEVICE(0x0424, 0x9902), | ||
1272 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1273 | }, | ||
1274 | { | ||
1275 | /* SMSC9505A USB Ethernet Device (SAL10) */ | ||
1276 | USB_DEVICE(0x0424, 0x9903), | ||
1277 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1278 | }, | ||
1279 | { | ||
1280 | /* SMSC9512/9514 USB Hub & Ethernet Device (SAL10) */ | ||
1281 | USB_DEVICE(0x0424, 0x9904), | ||
1282 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1283 | }, | ||
1284 | { | ||
1285 | /* SMSC9500A USB Ethernet Device (HAL) */ | ||
1286 | USB_DEVICE(0x0424, 0x9905), | ||
1287 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1288 | }, | ||
1289 | { | ||
1290 | /* SMSC9505A USB Ethernet Device (HAL) */ | ||
1291 | USB_DEVICE(0x0424, 0x9906), | ||
1292 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1293 | }, | ||
1294 | { | ||
1295 | /* SMSC9500 USB Ethernet Device (Alternate ID) */ | ||
1296 | USB_DEVICE(0x0424, 0x9907), | ||
1297 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1298 | }, | ||
1299 | { | ||
1300 | /* SMSC9500A USB Ethernet Device (Alternate ID) */ | ||
1301 | USB_DEVICE(0x0424, 0x9908), | ||
1302 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1303 | }, | ||
1304 | { | ||
1305 | /* SMSC9512/9514 USB Hub & Ethernet Device (Alternate ID) */ | ||
1306 | USB_DEVICE(0x0424, 0x9909), | ||
1307 | .driver_info = (unsigned long) &smsc95xx_info, | ||
1308 | }, | ||
1244 | { }, /* END */ | 1309 | { }, /* END */ |
1245 | }; | 1310 | }; |
1246 | MODULE_DEVICE_TABLE(usb, products); | 1311 | MODULE_DEVICE_TABLE(usb, products); |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 24b36f795151..ca5ca5ae061d 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -1049,7 +1049,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, | |||
1049 | * NOTE: strictly conforming cdc-ether devices should expect | 1049 | * NOTE: strictly conforming cdc-ether devices should expect |
1050 | * the ZLP here, but ignore the one-byte packet. | 1050 | * the ZLP here, but ignore the one-byte packet. |
1051 | */ | 1051 | */ |
1052 | if ((length % dev->maxpacket) == 0) { | 1052 | if (!(info->flags & FLAG_SEND_ZLP) && (length % dev->maxpacket) == 0) { |
1053 | urb->transfer_buffer_length++; | 1053 | urb->transfer_buffer_length++; |
1054 | if (skb_tailroom(skb)) { | 1054 | if (skb_tailroom(skb)) { |
1055 | skb->data[skb->len] = 0; | 1055 | skb->data[skb->len] = 0; |
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 6c0ea214a82e..9b907a36bb8c 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c | |||
@@ -4367,6 +4367,8 @@ static int b43_wireless_core_init(struct b43_wldev *dev) | |||
4367 | 4367 | ||
4368 | ieee80211_wake_queues(dev->wl->hw); | 4368 | ieee80211_wake_queues(dev->wl->hw); |
4369 | 4369 | ||
4370 | ieee80211_wake_queues(dev->wl->hw); | ||
4371 | |||
4370 | b43_set_status(dev, B43_STAT_INITIALIZED); | 4372 | b43_set_status(dev, B43_STAT_INITIALIZED); |
4371 | 4373 | ||
4372 | out: | 4374 | out: |
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c index d9169b47ac42..27298b19d5bd 100644 --- a/drivers/net/wireless/wl12xx/wl1271_main.c +++ b/drivers/net/wireless/wl12xx/wl1271_main.c | |||
@@ -644,11 +644,10 @@ static int wl1271_op_config_interface(struct ieee80211_hw *hw, | |||
644 | { | 644 | { |
645 | struct wl1271 *wl = hw->priv; | 645 | struct wl1271 *wl = hw->priv; |
646 | struct sk_buff *beacon; | 646 | struct sk_buff *beacon; |
647 | DECLARE_MAC_BUF(mac); | ||
648 | int ret; | 647 | int ret; |
649 | 648 | ||
650 | wl1271_debug(DEBUG_MAC80211, "mac80211 config_interface bssid %s", | 649 | wl1271_debug(DEBUG_MAC80211, "mac80211 config_interface bssid %pM", |
651 | print_mac(mac, conf->bssid)); | 650 | conf->bssid); |
652 | wl1271_dump_ascii(DEBUG_MAC80211, "ssid: ", conf->ssid, | 651 | wl1271_dump_ascii(DEBUG_MAC80211, "ssid: ", conf->ssid, |
653 | conf->ssid_len); | 652 | conf->ssid_len); |
654 | 653 | ||
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index dc22782633a5..83a044dbd1d7 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c | |||
@@ -134,18 +134,15 @@ static void xemaclite_enable_interrupts(struct net_local *drvdata) | |||
134 | } | 134 | } |
135 | 135 | ||
136 | /* Enable the Rx interrupts for the first buffer */ | 136 | /* Enable the Rx interrupts for the first buffer */ |
137 | reg_data = in_be32(drvdata->base_addr + XEL_RSR_OFFSET); | ||
138 | out_be32(drvdata->base_addr + XEL_RSR_OFFSET, | 137 | out_be32(drvdata->base_addr + XEL_RSR_OFFSET, |
139 | reg_data | XEL_RSR_RECV_IE_MASK); | 138 | XEL_RSR_RECV_IE_MASK); |
140 | 139 | ||
141 | /* Enable the Rx interrupts for the second Buffer if | 140 | /* Enable the Rx interrupts for the second Buffer if |
142 | * configured in HW */ | 141 | * configured in HW */ |
143 | if (drvdata->rx_ping_pong != 0) { | 142 | if (drvdata->rx_ping_pong != 0) { |
144 | reg_data = in_be32(drvdata->base_addr + XEL_BUFFER_OFFSET + | ||
145 | XEL_RSR_OFFSET); | ||
146 | out_be32(drvdata->base_addr + XEL_BUFFER_OFFSET + | 143 | out_be32(drvdata->base_addr + XEL_BUFFER_OFFSET + |
147 | XEL_RSR_OFFSET, | 144 | XEL_RSR_OFFSET, |
148 | reg_data | XEL_RSR_RECV_IE_MASK); | 145 | XEL_RSR_RECV_IE_MASK); |
149 | } | 146 | } |
150 | 147 | ||
151 | /* Enable the Global Interrupt Enable */ | 148 | /* Enable the Global Interrupt Enable */ |
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 79c9c5f5cdba..ed4648b556c7 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c | |||
@@ -868,11 +868,11 @@ static struct pcmcia_device_id serial_ids[] = { | |||
868 | PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), | 868 | PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), |
869 | PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), | 869 | PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), |
870 | PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d), | 870 | PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d), |
871 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), | 871 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "cis/PCMLM28.cis"), |
872 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), | 872 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "cis/PCMLM28.cis"), |
873 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), | 873 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "cis/PCMLM28.cis"), |
874 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"), | 874 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "cis/PCMLM28.cis"), |
875 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"), | 875 | PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "cis/PCMLM28.cis"), |
876 | PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), | 876 | PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), |
877 | PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), | 877 | PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), |
878 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "cis/3CCFEM556.cis"), | 878 | PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "cis/3CCFEM556.cis"), |
@@ -883,10 +883,10 @@ static struct pcmcia_device_id serial_ids[] = { | |||
883 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */ | 883 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0x0710, "SW_7xx_SER.cis"), /* Sierra Wireless AC710/AC750 GPRS Network Adapter R1 */ |
884 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */ | 884 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0192, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- pre update */ |
885 | PCMCIA_DEVICE_CIS_MANF_CARD(0x013f, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- post update */ | 885 | PCMCIA_DEVICE_CIS_MANF_CARD(0x013f, 0xa555, "SW_555_SER.cis"), /* Sierra Aircard 555 CDMA 1xrtt Modem -- post update */ |
886 | PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"), | 886 | PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "cis/MT5634ZLX.cis"), |
887 | PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), | 887 | PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), |
888 | PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), | 888 | PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), |
889 | PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"), | 889 | PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "cis/RS-COM-2P.cis"), |
890 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"), | 890 | PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "GLOBETROTTER.cis"), |
891 | PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100 1.00.",0x19ca78af,0xf964f42b), | 891 | PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100 1.00.",0x19ca78af,0xf964f42b), |
892 | PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100",0x19ca78af,0x71d98e83), | 892 | PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.","SERIAL CARD: SL100",0x19ca78af,0x71d98e83), |
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 975ecddbce30..5e4b8655b57c 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig | |||
@@ -121,8 +121,6 @@ source "drivers/staging/serqt_usb2/Kconfig" | |||
121 | 121 | ||
122 | source "drivers/staging/vt6655/Kconfig" | 122 | source "drivers/staging/vt6655/Kconfig" |
123 | 123 | ||
124 | source "drivers/staging/cpc-usb/Kconfig" | ||
125 | |||
126 | source "drivers/staging/pata_rdc/Kconfig" | 124 | source "drivers/staging/pata_rdc/Kconfig" |
127 | 125 | ||
128 | source "drivers/staging/udlfb/Kconfig" | 126 | source "drivers/staging/udlfb/Kconfig" |
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 2241ae1b21ee..ede1599e7e66 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile | |||
@@ -42,6 +42,5 @@ obj-$(CONFIG_LINE6_USB) += line6/ | |||
42 | obj-$(CONFIG_USB_SERIAL_QUATECH2) += serqt_usb2/ | 42 | obj-$(CONFIG_USB_SERIAL_QUATECH2) += serqt_usb2/ |
43 | obj-$(CONFIG_OCTEON_ETHERNET) += octeon/ | 43 | obj-$(CONFIG_OCTEON_ETHERNET) += octeon/ |
44 | obj-$(CONFIG_VT6655) += vt6655/ | 44 | obj-$(CONFIG_VT6655) += vt6655/ |
45 | obj-$(CONFIG_USB_CPC) += cpc-usb/ | ||
46 | obj-$(CONFIG_RDC_17F3101X) += pata_rdc/ | 45 | obj-$(CONFIG_RDC_17F3101X) += pata_rdc/ |
47 | obj-$(CONFIG_FB_UDL) += udlfb/ | 46 | obj-$(CONFIG_FB_UDL) += udlfb/ |
diff --git a/drivers/staging/cpc-usb/Kconfig b/drivers/staging/cpc-usb/Kconfig deleted file mode 100644 index 2be0bc9c39d0..000000000000 --- a/drivers/staging/cpc-usb/Kconfig +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | config USB_CPC | ||
2 | tristate "CPC CAN USB driver" | ||
3 | depends on USB && PROC_FS | ||
4 | default n | ||
diff --git a/drivers/staging/cpc-usb/Makefile b/drivers/staging/cpc-usb/Makefile deleted file mode 100644 index 3f83170a8fab..000000000000 --- a/drivers/staging/cpc-usb/Makefile +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | obj-$(CONFIG_USB_CPC) += cpc-usb.o | ||
2 | |||
3 | cpc-usb-y := cpc-usb_drv.o sja2m16c_2.o | ||
diff --git a/drivers/staging/cpc-usb/TODO b/drivers/staging/cpc-usb/TODO deleted file mode 100644 index 000e8bbc6188..000000000000 --- a/drivers/staging/cpc-usb/TODO +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | Things to do for this driver to get merged into the main portion of the | ||
2 | kernel: | ||
3 | - checkpatch cleanups | ||
4 | - sparse clean | ||
5 | - remove proc code | ||
6 | - tie into CAN socket interfaces if possible | ||
7 | - figure out sane userspace api | ||
8 | |||
9 | Send patches to Greg Kroah-Hartman <greg@kroah.com> | ||
diff --git a/drivers/staging/cpc-usb/cpc-usb_drv.c b/drivers/staging/cpc-usb/cpc-usb_drv.c deleted file mode 100644 index 9bf3f98c6825..000000000000 --- a/drivers/staging/cpc-usb/cpc-usb_drv.c +++ /dev/null | |||
@@ -1,1185 +0,0 @@ | |||
1 | /* | ||
2 | * CPC-USB CAN Interface Kernel Driver | ||
3 | * | ||
4 | * Copyright (C) 2004-2009 EMS Dr. Thomas Wuensche | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published | ||
8 | * by the Free Software Foundation; version 2 of the License. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include <linux/vmalloc.h> | ||
24 | #include <linux/module.h> | ||
25 | #include <linux/poll.h> | ||
26 | #include <linux/smp_lock.h> | ||
27 | #include <linux/completion.h> | ||
28 | #include <asm/uaccess.h> | ||
29 | #include <linux/usb.h> | ||
30 | |||
31 | #include <linux/version.h> | ||
32 | |||
33 | #include <linux/proc_fs.h> | ||
34 | |||
35 | #include "cpc.h" | ||
36 | |||
37 | #include "cpc_int.h" | ||
38 | #include "cpcusb.h" | ||
39 | |||
40 | #include "sja2m16c.h" | ||
41 | |||
42 | /* Version Information */ | ||
43 | #define DRIVER_AUTHOR "Sebastian Haas <haas@ems-wuensche.com>" | ||
44 | #define DRIVER_DESC "CPC-USB Driver for Linux Kernel 2.6" | ||
45 | #define DRIVER_VERSION CPC_DRIVER_VERSION | ||
46 | |||
47 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
48 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
49 | MODULE_VERSION(DRIVER_VERSION); | ||
50 | MODULE_LICENSE("GPL v2"); | ||
51 | |||
52 | /* Define these values to match your devices */ | ||
53 | #define USB_CPCUSB_VENDOR_ID 0x12D6 | ||
54 | |||
55 | #define USB_CPCUSB_M16C_PRODUCT_ID 0x0888 | ||
56 | #define USB_CPCUSB_LPC2119_PRODUCT_ID 0x0444 | ||
57 | |||
58 | #define CPC_USB_PROC_DIR CPC_PROC_DIR "cpc-usb" | ||
59 | |||
60 | static struct proc_dir_entry *procDir; | ||
61 | static struct proc_dir_entry *procEntry; | ||
62 | |||
63 | /* Module parameters */ | ||
64 | static int debug; | ||
65 | module_param(debug, int, S_IRUGO); | ||
66 | |||
67 | /* table of devices that work with this driver */ | ||
68 | static struct usb_device_id cpcusb_table[] = { | ||
69 | {USB_DEVICE(USB_CPCUSB_VENDOR_ID, USB_CPCUSB_M16C_PRODUCT_ID)}, | ||
70 | {USB_DEVICE(USB_CPCUSB_VENDOR_ID, USB_CPCUSB_LPC2119_PRODUCT_ID)}, | ||
71 | {} /* Terminating entry */ | ||
72 | }; | ||
73 | |||
74 | MODULE_DEVICE_TABLE(usb, cpcusb_table); | ||
75 | |||
76 | /* use to prevent kernel panic if driver is unloaded | ||
77 | * while a programm has still open the device | ||
78 | */ | ||
79 | DECLARE_WAIT_QUEUE_HEAD(rmmodWq); | ||
80 | atomic_t useCount; | ||
81 | |||
82 | static CPC_USB_T *CPCUSB_Table[CPC_USB_CARD_CNT] = { 0 }; | ||
83 | static unsigned int CPCUsbCnt; | ||
84 | |||
85 | /* prevent races between open() and disconnect() */ | ||
86 | static DECLARE_MUTEX(disconnect_sem); | ||
87 | |||
88 | /* local function prototypes */ | ||
89 | static ssize_t cpcusb_read(struct file *file, char *buffer, size_t count, | ||
90 | loff_t *ppos); | ||
91 | static ssize_t cpcusb_write(struct file *file, const char *buffer, | ||
92 | size_t count, loff_t *ppos); | ||
93 | static unsigned int cpcusb_poll(struct file *file, poll_table * wait); | ||
94 | static int cpcusb_open(struct inode *inode, struct file *file); | ||
95 | static int cpcusb_release(struct inode *inode, struct file *file); | ||
96 | |||
97 | static int cpcusb_probe(struct usb_interface *interface, | ||
98 | const struct usb_device_id *id); | ||
99 | static void cpcusb_disconnect(struct usb_interface *interface); | ||
100 | |||
101 | static void cpcusb_read_bulk_callback(struct urb *urb); | ||
102 | static void cpcusb_write_bulk_callback(struct urb *urb); | ||
103 | static void cpcusb_read_interrupt_callback(struct urb *urb); | ||
104 | |||
105 | static int cpcusb_setup_intrep(CPC_USB_T *card); | ||
106 | |||
107 | static struct file_operations cpcusb_fops = { | ||
108 | /* | ||
109 | * The owner field is part of the module-locking | ||
110 | * mechanism. The idea is that the kernel knows | ||
111 | * which module to increment the use-counter of | ||
112 | * BEFORE it calls the device's open() function. | ||
113 | * This also means that the kernel can decrement | ||
114 | * the use-counter again before calling release() | ||
115 | * or should the open() function fail. | ||
116 | */ | ||
117 | .owner = THIS_MODULE, | ||
118 | |||
119 | .read = cpcusb_read, | ||
120 | .write = cpcusb_write, | ||
121 | .poll = cpcusb_poll, | ||
122 | .open = cpcusb_open, | ||
123 | .release = cpcusb_release, | ||
124 | }; | ||
125 | |||
126 | /* | ||
127 | * usb class driver info in order to get a minor number from the usb core, | ||
128 | * and to have the device registered with devfs and the driver core | ||
129 | */ | ||
130 | static struct usb_class_driver cpcusb_class = { | ||
131 | .name = "usb/cpc_usb%d", | ||
132 | .fops = &cpcusb_fops, | ||
133 | .minor_base = CPC_USB_BASE_MNR, | ||
134 | }; | ||
135 | |||
136 | /* usb specific object needed to register this driver with the usb subsystem */ | ||
137 | static struct usb_driver cpcusb_driver = { | ||
138 | .name = "cpc-usb", | ||
139 | .probe = cpcusb_probe, | ||
140 | .disconnect = cpcusb_disconnect, | ||
141 | .id_table = cpcusb_table, | ||
142 | }; | ||
143 | |||
144 | static int cpcusb_create_info_output(char *buf) | ||
145 | { | ||
146 | int i = 0, j; | ||
147 | |||
148 | for (j = 0; j < CPC_USB_CARD_CNT; j++) { | ||
149 | if (CPCUSB_Table[j]) { | ||
150 | CPC_USB_T *card = CPCUSB_Table[j]; | ||
151 | CPC_CHAN_T *chan = card->chan; | ||
152 | |||
153 | /* MINOR CHANNELNO BUSNO SLOTNO */ | ||
154 | i += sprintf(&buf[i], "%d %s\n", chan->minor, | ||
155 | card->serialNumber); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | return i; | ||
160 | } | ||
161 | |||
162 | static int cpcusb_proc_read_info(char *page, char **start, off_t off, | ||
163 | int count, int *eof, void *data) | ||
164 | { | ||
165 | int len = cpcusb_create_info_output(page); | ||
166 | |||
167 | if (len <= off + count) | ||
168 | *eof = 1; | ||
169 | *start = page + off; | ||
170 | len -= off; | ||
171 | if (len > count) | ||
172 | len = count; | ||
173 | if (len < 0) | ||
174 | len = 0; | ||
175 | |||
176 | return len; | ||
177 | } | ||
178 | |||
179 | /* | ||
180 | * Remove CPC-USB and cleanup | ||
181 | */ | ||
182 | static inline void cpcusb_delete(CPC_USB_T *card) | ||
183 | { | ||
184 | if (card) { | ||
185 | if (card->chan) { | ||
186 | if (card->chan->buf) | ||
187 | vfree(card->chan->buf); | ||
188 | |||
189 | if (card->chan->CPCWait_q) | ||
190 | kfree(card->chan->CPCWait_q); | ||
191 | |||
192 | kfree(card->chan); | ||
193 | } | ||
194 | |||
195 | CPCUSB_Table[card->idx] = NULL; | ||
196 | kfree(card); | ||
197 | } | ||
198 | } | ||
199 | |||
200 | /* | ||
201 | * setup the interrupt IN endpoint of a specific CPC-USB device | ||
202 | */ | ||
203 | static int cpcusb_setup_intrep(CPC_USB_T *card) | ||
204 | { | ||
205 | int retval = 0; | ||
206 | struct usb_endpoint_descriptor *ep; | ||
207 | |||
208 | ep = &card->interface->altsetting[0].endpoint[card->num_intr_in].desc; | ||
209 | |||
210 | card->intr_in_buffer[0] = 0; | ||
211 | card->free_slots = 15; /* initial size */ | ||
212 | |||
213 | /* setup the urb */ | ||
214 | usb_fill_int_urb(card->intr_in_urb, card->udev, | ||
215 | usb_rcvintpipe(card->udev, card->num_intr_in), | ||
216 | card->intr_in_buffer, | ||
217 | sizeof(card->intr_in_buffer), | ||
218 | cpcusb_read_interrupt_callback, | ||
219 | card, | ||
220 | ep->bInterval); | ||
221 | |||
222 | card->intr_in_urb->status = 0; /* needed! */ | ||
223 | |||
224 | /* submit the urb */ | ||
225 | retval = usb_submit_urb(card->intr_in_urb, GFP_KERNEL); | ||
226 | |||
227 | if (retval) | ||
228 | err("%s - failed submitting intr urb, error %d", __func__, | ||
229 | retval); | ||
230 | |||
231 | return retval; | ||
232 | } | ||
233 | |||
234 | static int cpcusb_open(struct inode *inode, struct file *file) | ||
235 | { | ||
236 | CPC_USB_T *card = NULL; | ||
237 | struct usb_interface *interface; | ||
238 | int subminor; | ||
239 | int j, retval = 0; | ||
240 | |||
241 | subminor = iminor(inode); | ||
242 | |||
243 | /* prevent disconnects */ | ||
244 | down(&disconnect_sem); | ||
245 | |||
246 | interface = usb_find_interface(&cpcusb_driver, subminor); | ||
247 | if (!interface) { | ||
248 | err("%s - error, can't find device for minor %d", | ||
249 | __func__, subminor); | ||
250 | retval = CPC_ERR_NO_INTERFACE_PRESENT; | ||
251 | goto exit_no_device; | ||
252 | } | ||
253 | |||
254 | card = usb_get_intfdata(interface); | ||
255 | if (!card) { | ||
256 | retval = CPC_ERR_NO_INTERFACE_PRESENT; | ||
257 | goto exit_no_device; | ||
258 | } | ||
259 | |||
260 | /* lock this device */ | ||
261 | down(&card->sem); | ||
262 | |||
263 | /* increment our usage count for the driver */ | ||
264 | if (card->open) { | ||
265 | dbg("device already opened"); | ||
266 | retval = CPC_ERR_CHANNEL_ALREADY_OPEN; | ||
267 | goto exit_on_error; | ||
268 | } | ||
269 | |||
270 | /* save our object in the file's private structure */ | ||
271 | file->private_data = card; | ||
272 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
273 | usb_fill_bulk_urb(card->urbs[j].urb, card->udev, | ||
274 | usb_rcvbulkpipe(card->udev, card->num_bulk_in), | ||
275 | card->urbs[j].buffer, card->urbs[j].size, | ||
276 | cpcusb_read_bulk_callback, card); | ||
277 | |||
278 | retval = usb_submit_urb(card->urbs[j].urb, GFP_KERNEL); | ||
279 | |||
280 | if (retval) { | ||
281 | err("%s - failed submitting read urb, error %d", | ||
282 | __func__, retval); | ||
283 | retval = CPC_ERR_TRANSMISSION_FAILED; | ||
284 | goto exit_on_error; | ||
285 | } | ||
286 | } | ||
287 | |||
288 | info("%s - %d URB's submitted", __func__, j); | ||
289 | |||
290 | ResetBuffer(card->chan); | ||
291 | |||
292 | cpcusb_setup_intrep(card); | ||
293 | card->open = 1; | ||
294 | |||
295 | atomic_inc(&useCount); | ||
296 | |||
297 | exit_on_error: | ||
298 | /* unlock this device */ | ||
299 | up(&card->sem); | ||
300 | |||
301 | exit_no_device: | ||
302 | up(&disconnect_sem); | ||
303 | |||
304 | return retval; | ||
305 | } | ||
306 | |||
307 | static unsigned int cpcusb_poll(struct file *file, poll_table * wait) | ||
308 | { | ||
309 | CPC_USB_T *card = (CPC_USB_T *) file->private_data; | ||
310 | unsigned int retval = 0; | ||
311 | |||
312 | if (!card) { | ||
313 | err("%s - device object lost", __func__); | ||
314 | return -EIO; | ||
315 | } | ||
316 | |||
317 | poll_wait(file, card->chan->CPCWait_q, wait); | ||
318 | |||
319 | if (IsBufferNotEmpty(card->chan) || !(card->present)) | ||
320 | retval |= (POLLIN | POLLRDNORM); | ||
321 | |||
322 | if (card->free_slots) | ||
323 | retval |= (POLLOUT | POLLWRNORM); | ||
324 | |||
325 | return retval; | ||
326 | } | ||
327 | |||
328 | static int cpcusb_release(struct inode *inode, struct file *file) | ||
329 | { | ||
330 | CPC_USB_T *card = (CPC_USB_T *) file->private_data; | ||
331 | int j, retval = 0; | ||
332 | |||
333 | if (card == NULL) { | ||
334 | dbg("%s - object is NULL", __func__); | ||
335 | return CPC_ERR_NO_INTERFACE_PRESENT; | ||
336 | } | ||
337 | |||
338 | /* lock our device */ | ||
339 | down(&card->sem); | ||
340 | |||
341 | if (!card->open) { | ||
342 | dbg("%s - device not opened", __func__); | ||
343 | retval = CPC_ERR_NO_INTERFACE_PRESENT; | ||
344 | goto exit_not_opened; | ||
345 | } | ||
346 | |||
347 | /* if device wasn't unplugged kill all urbs */ | ||
348 | if (card->present) { | ||
349 | /* kill read urbs */ | ||
350 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
351 | usb_kill_urb(card->urbs[j].urb); | ||
352 | } | ||
353 | |||
354 | /* kill irq urb */ | ||
355 | usb_kill_urb(card->intr_in_urb); | ||
356 | |||
357 | /* kill write urbs */ | ||
358 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
359 | if (atomic_read(&card->wrUrbs[j].busy)) { | ||
360 | usb_kill_urb(card->wrUrbs[j].urb); | ||
361 | wait_for_completion(&card->wrUrbs[j].finished); | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | |||
366 | atomic_dec(&useCount); | ||
367 | |||
368 | /* last process detached */ | ||
369 | if (atomic_read(&useCount) == 0) { | ||
370 | wake_up(&rmmodWq); | ||
371 | } | ||
372 | |||
373 | if (!card->present && card->open) { | ||
374 | /* the device was unplugged before the file was released */ | ||
375 | up(&card->sem); | ||
376 | cpcusb_delete(card); | ||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | card->open = 0; | ||
381 | |||
382 | exit_not_opened: | ||
383 | up(&card->sem); | ||
384 | |||
385 | return 0; | ||
386 | } | ||
387 | |||
388 | static ssize_t cpcusb_read(struct file *file, char *buffer, size_t count, | ||
389 | loff_t *ppos) | ||
390 | { | ||
391 | CPC_USB_T *card = (CPC_USB_T *) file->private_data; | ||
392 | CPC_CHAN_T *chan; | ||
393 | int retval = 0; | ||
394 | |||
395 | if (count < sizeof(CPC_MSG_T)) | ||
396 | return CPC_ERR_UNKNOWN; | ||
397 | |||
398 | /* check if can read from the given address */ | ||
399 | if (!access_ok(VERIFY_WRITE, buffer, count)) | ||
400 | return CPC_ERR_UNKNOWN; | ||
401 | |||
402 | /* lock this object */ | ||
403 | down(&card->sem); | ||
404 | |||
405 | /* verify that the device wasn't unplugged */ | ||
406 | if (!card->present) { | ||
407 | up(&card->sem); | ||
408 | return CPC_ERR_NO_INTERFACE_PRESENT; | ||
409 | } | ||
410 | |||
411 | if (IsBufferEmpty(card->chan)) { | ||
412 | retval = 0; | ||
413 | } else { | ||
414 | chan = card->chan; | ||
415 | |||
416 | #if 0 | ||
417 | /* convert LPC2119 params back to SJA1000 params */ | ||
418 | if (card->deviceRevision >= 0x0200 | ||
419 | && chan->buf[chan->oidx].type == CPC_MSG_T_CAN_PRMS) { | ||
420 | LPC2119_TO_SJA1000_Params(&chan->buf[chan->oidx]); | ||
421 | } | ||
422 | #endif | ||
423 | |||
424 | if (copy_to_user(buffer, &chan->buf[chan->oidx], count) != 0) { | ||
425 | retval = CPC_ERR_IO_TRANSFER; | ||
426 | } else { | ||
427 | chan->oidx = (chan->oidx + 1) % CPC_MSG_BUF_CNT; | ||
428 | chan->WnR = 1; | ||
429 | retval = sizeof(CPC_MSG_T); | ||
430 | } | ||
431 | } | ||
432 | /* spin_unlock_irqrestore(&card->slock, flags); */ | ||
433 | |||
434 | /* unlock the device */ | ||
435 | up(&card->sem); | ||
436 | |||
437 | return retval; | ||
438 | } | ||
439 | |||
440 | #define SHIFT 1 | ||
441 | static inline void cpcusb_align_buffer_alignment(unsigned char *buf) | ||
442 | { | ||
443 | /* CPC-USB uploads packed bytes. */ | ||
444 | CPC_MSG_T *cpc = (CPC_MSG_T *) buf; | ||
445 | unsigned int i; | ||
446 | |||
447 | for (i = 0; i < cpc->length + (2 * sizeof(unsigned long)); i++) { | ||
448 | ((unsigned char *) &cpc->msgid)[1 + i] = | ||
449 | ((unsigned char *) &cpc->msgid)[1 + SHIFT + i]; | ||
450 | } | ||
451 | } | ||
452 | |||
453 | static int cpc_get_buffer_count(CPC_CHAN_T *chan) | ||
454 | { | ||
455 | /* check the buffer parameters */ | ||
456 | if (chan->iidx == chan->oidx) | ||
457 | return !chan->WnR ? CPC_MSG_BUF_CNT : 0; | ||
458 | else if (chan->iidx >= chan->oidx) | ||
459 | return (chan->iidx - chan->oidx) % CPC_MSG_BUF_CNT; | ||
460 | |||
461 | return (chan->iidx + CPC_MSG_BUF_CNT - chan->oidx) % CPC_MSG_BUF_CNT; | ||
462 | } | ||
463 | |||
464 | static ssize_t cpcusb_write(struct file *file, const char *buffer, | ||
465 | size_t count, loff_t *ppos) | ||
466 | { | ||
467 | CPC_USB_T *card = (CPC_USB_T *) file->private_data; | ||
468 | CPC_USB_WRITE_URB_T *wrUrb = NULL; | ||
469 | |||
470 | ssize_t bytes_written = 0; | ||
471 | int retval = 0; | ||
472 | int j; | ||
473 | |||
474 | unsigned char *obuf = NULL; | ||
475 | unsigned char type = 0; | ||
476 | CPC_MSG_T *info = NULL; | ||
477 | |||
478 | dbg("%s - entered minor %d, count = %zu, present = %d", | ||
479 | __func__, card->minor, count, card->present); | ||
480 | |||
481 | if (count > sizeof(CPC_MSG_T)) | ||
482 | return CPC_ERR_UNKNOWN; | ||
483 | |||
484 | /* check if can read from the given address */ | ||
485 | if (!access_ok(VERIFY_READ, buffer, count)) | ||
486 | return CPC_ERR_UNKNOWN; | ||
487 | |||
488 | /* lock this object */ | ||
489 | down(&card->sem); | ||
490 | |||
491 | /* verify that the device wasn't unplugged */ | ||
492 | if (!card->present) { | ||
493 | retval = CPC_ERR_NO_INTERFACE_PRESENT; | ||
494 | goto exit; | ||
495 | } | ||
496 | |||
497 | /* verify that we actually have some data to write */ | ||
498 | if (count == 0) { | ||
499 | dbg("%s - write request of 0 bytes", __func__); | ||
500 | goto exit; | ||
501 | } | ||
502 | |||
503 | if (card->free_slots <= 5) { | ||
504 | info = (CPC_MSG_T *) buffer; | ||
505 | |||
506 | if (info->type != CPC_CMD_T_CLEAR_CMD_QUEUE | ||
507 | || card->free_slots <= 0) { | ||
508 | dbg("%s - send buffer full please try again %d", | ||
509 | __func__, card->free_slots); | ||
510 | retval = CPC_ERR_CAN_NO_TRANSMIT_BUF; | ||
511 | goto exit; | ||
512 | } | ||
513 | } | ||
514 | |||
515 | /* Find a free write urb */ | ||
516 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
517 | if (!atomic_read(&card->wrUrbs[j].busy)) { | ||
518 | wrUrb = &card->wrUrbs[j]; /* remember found URB */ | ||
519 | atomic_set(&wrUrb->busy, 1); /* lock this URB */ | ||
520 | init_completion(&wrUrb->finished); /* init completion */ | ||
521 | dbg("WR URB no. %d started", j); | ||
522 | break; | ||
523 | } | ||
524 | } | ||
525 | |||
526 | /* don't found write urb say error */ | ||
527 | if (!wrUrb) { | ||
528 | dbg("%s - no free send urb available", __func__); | ||
529 | retval = CPC_ERR_CAN_NO_TRANSMIT_BUF; | ||
530 | goto exit; | ||
531 | } | ||
532 | dbg("URB write req"); | ||
533 | |||
534 | obuf = (unsigned char *) wrUrb->urb->transfer_buffer; | ||
535 | |||
536 | /* copy the data from userspace into our transfer buffer; | ||
537 | * this is the only copy required. | ||
538 | */ | ||
539 | if (copy_from_user(&obuf[4], buffer, count) != 0) { | ||
540 | atomic_set(&wrUrb->busy, 0); /* release urb */ | ||
541 | retval = CPC_ERR_IO_TRANSFER; | ||
542 | goto exit; | ||
543 | } | ||
544 | |||
545 | /* check if it is a DRIVER information message, so we can | ||
546 | * response to that message and not the USB | ||
547 | */ | ||
548 | info = (CPC_MSG_T *) &obuf[4]; | ||
549 | |||
550 | bytes_written = 11 + info->length; | ||
551 | if (bytes_written >= wrUrb->size) { | ||
552 | retval = CPC_ERR_IO_TRANSFER; | ||
553 | goto exit; | ||
554 | } | ||
555 | |||
556 | switch (info->type) { | ||
557 | case CPC_CMD_T_CLEAR_MSG_QUEUE: | ||
558 | ResetBuffer(card->chan); | ||
559 | break; | ||
560 | |||
561 | case CPC_CMD_T_INQ_MSG_QUEUE_CNT: | ||
562 | retval = cpc_get_buffer_count(card->chan); | ||
563 | atomic_set(&wrUrb->busy, 0); | ||
564 | |||
565 | goto exit; | ||
566 | |||
567 | case CPC_CMD_T_INQ_INFO: | ||
568 | if (info->msg.info.source == CPC_INFOMSG_T_DRIVER) { | ||
569 | /* release urb cause we'll use it for driver | ||
570 | * information | ||
571 | */ | ||
572 | atomic_set(&wrUrb->busy, 0); | ||
573 | if (IsBufferFull(card->chan)) { | ||
574 | retval = CPC_ERR_IO_TRANSFER; | ||
575 | goto exit; | ||
576 | } | ||
577 | |||
578 | /* it is a driver information request message and we have | ||
579 | * free rx slots to store the response | ||
580 | */ | ||
581 | type = info->msg.info.type; | ||
582 | info = &card->chan->buf[card->chan->iidx]; | ||
583 | |||
584 | info->type = CPC_MSG_T_INFO; | ||
585 | info->msg.info.source = CPC_INFOMSG_T_DRIVER; | ||
586 | info->msg.info.type = type; | ||
587 | |||
588 | switch (type) { | ||
589 | case CPC_INFOMSG_T_VERSION: | ||
590 | info->length = strlen(CPC_DRIVER_VERSION) + 2; | ||
591 | sprintf(info->msg.info.msg, "%s\n", | ||
592 | CPC_DRIVER_VERSION); | ||
593 | break; | ||
594 | |||
595 | case CPC_INFOMSG_T_SERIAL: | ||
596 | info->length = strlen(CPC_DRIVER_SERIAL) + 2; | ||
597 | sprintf(info->msg.info.msg, "%s\n", | ||
598 | CPC_DRIVER_SERIAL); | ||
599 | break; | ||
600 | |||
601 | default: | ||
602 | info->length = 2; | ||
603 | info->msg.info.type = | ||
604 | CPC_INFOMSG_T_UNKNOWN_TYPE; | ||
605 | } | ||
606 | |||
607 | card->chan->WnR = 0; | ||
608 | card->chan->iidx = | ||
609 | (card->chan->iidx + 1) % CPC_MSG_BUF_CNT; | ||
610 | |||
611 | retval = info->length; | ||
612 | goto exit; | ||
613 | } | ||
614 | break; | ||
615 | case CPC_CMD_T_CAN_PRMS: | ||
616 | /* Check the controller type. If it's the new CPC-USB, make sure if these are SJA1000 params */ | ||
617 | if (info->msg.canparams.cc_type != SJA1000 | ||
618 | && info->msg.canparams.cc_type != M16C_BASIC | ||
619 | && (card->productId == USB_CPCUSB_LPC2119_PRODUCT_ID | ||
620 | && info->msg.canparams.cc_type != SJA1000)) { | ||
621 | /* don't forget to release the urb */ | ||
622 | atomic_set(&wrUrb->busy, 0); | ||
623 | retval = CPC_ERR_WRONG_CONTROLLER_TYPE; | ||
624 | goto exit; | ||
625 | } | ||
626 | break; | ||
627 | } | ||
628 | |||
629 | /* just convert the params if it is an old CPC-USB with M16C controller */ | ||
630 | if (card->productId == USB_CPCUSB_M16C_PRODUCT_ID) { | ||
631 | /* if it is a parameter message convert it from SJA1000 controller | ||
632 | * settings to M16C Basic controller settings | ||
633 | */ | ||
634 | SJA1000_TO_M16C_BASIC_Params((CPC_MSG_T *) &obuf[4]); | ||
635 | } | ||
636 | |||
637 | /* don't forget the byte alignment */ | ||
638 | cpcusb_align_buffer_alignment(&obuf[4]); | ||
639 | |||
640 | /* setup a the 4 byte header */ | ||
641 | obuf[0] = obuf[1] = obuf[2] = obuf[3] = 0; | ||
642 | |||
643 | /* this urb was already set up, except for this write size */ | ||
644 | wrUrb->urb->transfer_buffer_length = bytes_written + 4; | ||
645 | |||
646 | /* send the data out the bulk port */ | ||
647 | /* a character device write uses GFP_KERNEL, | ||
648 | unless a spinlock is held */ | ||
649 | retval = usb_submit_urb(wrUrb->urb, GFP_KERNEL); | ||
650 | if (retval) { | ||
651 | atomic_set(&wrUrb->busy, 0); /* release urb */ | ||
652 | err("%s - failed submitting write urb, error %d", | ||
653 | __func__, retval); | ||
654 | } else { | ||
655 | retval = bytes_written; | ||
656 | } | ||
657 | |||
658 | exit: | ||
659 | /* unlock the device */ | ||
660 | up(&card->sem); | ||
661 | |||
662 | dbg("%s - leaved", __func__); | ||
663 | |||
664 | return retval; | ||
665 | } | ||
666 | |||
667 | /* | ||
668 | * callback for interrupt IN urb | ||
669 | */ | ||
670 | static void cpcusb_read_interrupt_callback(struct urb *urb) | ||
671 | { | ||
672 | CPC_USB_T *card = (CPC_USB_T *) urb->context; | ||
673 | int retval; | ||
674 | unsigned long flags; | ||
675 | |||
676 | spin_lock_irqsave(&card->slock, flags); | ||
677 | |||
678 | if (!card->present) { | ||
679 | spin_unlock_irqrestore(&card->slock, flags); | ||
680 | info("%s - no such device", __func__); | ||
681 | return; | ||
682 | } | ||
683 | |||
684 | switch (urb->status) { | ||
685 | case 0: /* success */ | ||
686 | card->free_slots = card->intr_in_buffer[1]; | ||
687 | break; | ||
688 | case -ECONNRESET: | ||
689 | case -ENOENT: | ||
690 | case -ESHUTDOWN: | ||
691 | /* urb was killed */ | ||
692 | spin_unlock_irqrestore(&card->slock, flags); | ||
693 | dbg("%s - intr urb killed", __func__); | ||
694 | return; | ||
695 | default: | ||
696 | info("%s - nonzero urb status %d", __func__, urb->status); | ||
697 | break; | ||
698 | } | ||
699 | |||
700 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
701 | if (retval) { | ||
702 | err("%s - failed resubmitting intr urb, error %d", | ||
703 | __func__, retval); | ||
704 | } | ||
705 | |||
706 | spin_unlock_irqrestore(&card->slock, flags); | ||
707 | wake_up_interruptible(card->chan->CPCWait_q); | ||
708 | |||
709 | return; | ||
710 | } | ||
711 | |||
712 | #define UN_SHIFT 1 | ||
713 | #define CPCMSG_HEADER_LEN_FIRMWARE 11 | ||
714 | static inline int cpcusb_unalign_and_copy_buffy(unsigned char *out, | ||
715 | unsigned char *in) | ||
716 | { | ||
717 | unsigned int i, j; | ||
718 | |||
719 | for (i = 0; i < 3; i++) | ||
720 | out[i] = in[i]; | ||
721 | |||
722 | for (j = 0; j < (in[1] + (CPCMSG_HEADER_LEN_FIRMWARE - 3)); j++) | ||
723 | out[j + i + UN_SHIFT] = in[j + i]; | ||
724 | |||
725 | return i + j; | ||
726 | } | ||
727 | |||
728 | /* | ||
729 | * callback for bulk IN urb | ||
730 | */ | ||
731 | static void cpcusb_read_bulk_callback(struct urb *urb) | ||
732 | { | ||
733 | CPC_USB_T *card = (CPC_USB_T *) urb->context; | ||
734 | CPC_CHAN_T *chan; | ||
735 | unsigned char *ibuf = urb->transfer_buffer; | ||
736 | int retval, msgCnt, start, again = 0; | ||
737 | unsigned long flags; | ||
738 | |||
739 | if (!card) { | ||
740 | err("%s - device object lost", __func__); | ||
741 | return; | ||
742 | } | ||
743 | |||
744 | spin_lock_irqsave(&card->slock, flags); | ||
745 | |||
746 | if (!card->present) { | ||
747 | spin_unlock_irqrestore(&card->slock, flags); | ||
748 | info("%s - no such device", __func__); | ||
749 | return; | ||
750 | } | ||
751 | |||
752 | switch (urb->status) { | ||
753 | case 0: /* success */ | ||
754 | break; | ||
755 | case -ECONNRESET: | ||
756 | case -ENOENT: | ||
757 | case -ESHUTDOWN: | ||
758 | /* urb was killed */ | ||
759 | spin_unlock_irqrestore(&card->slock, flags); | ||
760 | dbg("%s - read urb killed", __func__); | ||
761 | return; | ||
762 | default: | ||
763 | info("%s - nonzero urb status %d", __func__, urb->status); | ||
764 | break; | ||
765 | } | ||
766 | |||
767 | if (urb->actual_length) { | ||
768 | msgCnt = ibuf[0] & ~0x80; | ||
769 | again = ibuf[0] & 0x80; | ||
770 | |||
771 | /* we have a 4 byte header */ | ||
772 | start = 4; | ||
773 | chan = card->chan; | ||
774 | while (msgCnt) { | ||
775 | if (!(IsBufferFull(card->chan))) { | ||
776 | start += | ||
777 | cpcusb_unalign_and_copy_buffy((unsigned char *) | ||
778 | &chan->buf[chan->iidx], &ibuf[start]); | ||
779 | |||
780 | if (start > urb->transfer_buffer_length) { | ||
781 | err("%d > %d", start, urb->transfer_buffer_length); | ||
782 | break; | ||
783 | } | ||
784 | |||
785 | chan->WnR = 0; | ||
786 | chan->iidx = (chan->iidx + 1) % CPC_MSG_BUF_CNT; | ||
787 | msgCnt--; | ||
788 | } else { | ||
789 | break; | ||
790 | } | ||
791 | } | ||
792 | } | ||
793 | |||
794 | usb_fill_bulk_urb(urb, card->udev, | ||
795 | usb_rcvbulkpipe(card->udev, card->num_bulk_in), | ||
796 | urb->transfer_buffer, | ||
797 | urb->transfer_buffer_length, | ||
798 | cpcusb_read_bulk_callback, card); | ||
799 | |||
800 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
801 | |||
802 | if (retval) { | ||
803 | err("%s - failed resubmitting read urb, error %d", __func__, retval); | ||
804 | } | ||
805 | |||
806 | spin_unlock_irqrestore(&card->slock, flags); | ||
807 | |||
808 | wake_up_interruptible(card->chan->CPCWait_q); | ||
809 | } | ||
810 | |||
811 | /* | ||
812 | * callback for bulk IN urb | ||
813 | */ | ||
814 | static void cpcusb_write_bulk_callback(struct urb *urb) | ||
815 | { | ||
816 | CPC_USB_T *card = (CPC_USB_T *) urb->context; | ||
817 | unsigned long flags; | ||
818 | int j; | ||
819 | |||
820 | spin_lock_irqsave(&card->slock, flags); | ||
821 | |||
822 | /* find this urb */ | ||
823 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
824 | if (card->wrUrbs[j].urb == urb) { | ||
825 | dbg("URB found no. %d", j); | ||
826 | /* notify anyone waiting that the write has finished */ | ||
827 | complete(&card->wrUrbs[j].finished); | ||
828 | atomic_set(&card->wrUrbs[j].busy, 0); | ||
829 | break; | ||
830 | } | ||
831 | } | ||
832 | |||
833 | switch (urb->status) { | ||
834 | case 0: /* success */ | ||
835 | break; | ||
836 | case -ECONNRESET: | ||
837 | case -ENOENT: | ||
838 | case -ESHUTDOWN: | ||
839 | /* urb was killed */ | ||
840 | spin_unlock_irqrestore(&card->slock, flags); | ||
841 | dbg("%s - write urb no. %d killed", __func__, j); | ||
842 | return; | ||
843 | default: | ||
844 | info("%s - nonzero urb status %d", __func__, urb->status); | ||
845 | break; | ||
846 | } | ||
847 | |||
848 | spin_unlock_irqrestore(&card->slock, flags); | ||
849 | |||
850 | wake_up_interruptible(card->chan->CPCWait_q); | ||
851 | } | ||
852 | |||
853 | static inline int cpcusb_get_free_slot(void) | ||
854 | { | ||
855 | int i; | ||
856 | |||
857 | for (i = 0; i < CPC_USB_CARD_CNT; i++) { | ||
858 | if (!CPCUSB_Table[i]) | ||
859 | return i; | ||
860 | } | ||
861 | |||
862 | return -1; | ||
863 | } | ||
864 | |||
865 | /* | ||
866 | * probe function for new CPC-USB devices | ||
867 | */ | ||
868 | static int cpcusb_probe(struct usb_interface *interface, | ||
869 | const struct usb_device_id *id) | ||
870 | { | ||
871 | CPC_USB_T *card = NULL; | ||
872 | CPC_CHAN_T *chan = NULL; | ||
873 | |||
874 | struct usb_device *udev = interface_to_usbdev(interface); | ||
875 | struct usb_host_interface *iface_desc; | ||
876 | struct usb_endpoint_descriptor *endpoint; | ||
877 | |||
878 | int i, j, retval = -ENOMEM, slot; | ||
879 | |||
880 | slot = cpcusb_get_free_slot(); | ||
881 | if (slot < 0) { | ||
882 | info("No more devices supported"); | ||
883 | return -ENOMEM; | ||
884 | } | ||
885 | |||
886 | /* allocate memory for our device state and initialize it */ | ||
887 | card = kzalloc(sizeof(CPC_USB_T), GFP_KERNEL); | ||
888 | if (!card) { | ||
889 | err("Out of memory"); | ||
890 | return -ENOMEM; | ||
891 | } | ||
892 | CPCUSB_Table[slot] = card; | ||
893 | |||
894 | /* allocate and initialize the channel struct */ | ||
895 | card->chan = kmalloc(sizeof(CPC_CHAN_T), GFP_KERNEL); | ||
896 | if (!card->chan) { | ||
897 | kfree(card); | ||
898 | err("Out of memory"); | ||
899 | return -ENOMEM; | ||
900 | } | ||
901 | |||
902 | chan = card->chan; | ||
903 | memset(chan, 0, sizeof(CPC_CHAN_T)); | ||
904 | ResetBuffer(chan); | ||
905 | |||
906 | init_MUTEX(&card->sem); | ||
907 | spin_lock_init(&card->slock); | ||
908 | |||
909 | card->udev = udev; | ||
910 | card->interface = interface; | ||
911 | if (udev->descriptor.iSerialNumber) { | ||
912 | usb_string(udev, udev->descriptor.iSerialNumber, card->serialNumber, | ||
913 | 128); | ||
914 | info("Serial %s", card->serialNumber); | ||
915 | } | ||
916 | |||
917 | card->productId = udev->descriptor.idProduct; | ||
918 | info("Product %s", | ||
919 | card->productId == USB_CPCUSB_LPC2119_PRODUCT_ID ? | ||
920 | "CPC-USB/ARM7" : "CPC-USB/M16C"); | ||
921 | |||
922 | /* set up the endpoint information */ | ||
923 | /* check out the endpoints */ | ||
924 | /* use only the first bulk-in and bulk-out endpoints */ | ||
925 | iface_desc = &interface->altsetting[0]; | ||
926 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | ||
927 | endpoint = &iface_desc->endpoint[i].desc; | ||
928 | |||
929 | if (!card->num_intr_in && | ||
930 | (endpoint->bEndpointAddress & USB_DIR_IN) && | ||
931 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
932 | == USB_ENDPOINT_XFER_INT)) { | ||
933 | card->intr_in_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
934 | card->num_intr_in = 1; | ||
935 | |||
936 | if (!card->intr_in_urb) { | ||
937 | err("No free urbs available"); | ||
938 | goto error; | ||
939 | } | ||
940 | |||
941 | dbg("intr_in urb %d", card->num_intr_in); | ||
942 | } | ||
943 | |||
944 | if (!card->num_bulk_in && | ||
945 | (endpoint->bEndpointAddress & USB_DIR_IN) && | ||
946 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
947 | == USB_ENDPOINT_XFER_BULK)) { | ||
948 | card->num_bulk_in = 2; | ||
949 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
950 | card->urbs[j].size = endpoint->wMaxPacketSize; | ||
951 | card->urbs[j].urb = usb_alloc_urb(0, GFP_KERNEL); | ||
952 | if (!card->urbs[j].urb) { | ||
953 | err("No free urbs available"); | ||
954 | goto error; | ||
955 | } | ||
956 | card->urbs[j].buffer = | ||
957 | usb_buffer_alloc(udev, | ||
958 | card->urbs[j].size, | ||
959 | GFP_KERNEL, | ||
960 | &card->urbs[j].urb->transfer_dma); | ||
961 | if (!card->urbs[j].buffer) { | ||
962 | err("Couldn't allocate bulk_in_buffer"); | ||
963 | goto error; | ||
964 | } | ||
965 | } | ||
966 | info("%s - %d reading URB's allocated", | ||
967 | __func__, CPC_USB_URB_CNT); | ||
968 | } | ||
969 | |||
970 | if (!card->num_bulk_out && | ||
971 | !(endpoint->bEndpointAddress & USB_DIR_IN) && | ||
972 | ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) | ||
973 | == USB_ENDPOINT_XFER_BULK)) { | ||
974 | |||
975 | card->num_bulk_out = 2; | ||
976 | |||
977 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
978 | card->wrUrbs[j].size = | ||
979 | endpoint->wMaxPacketSize; | ||
980 | card->wrUrbs[j].urb = | ||
981 | usb_alloc_urb(0, GFP_KERNEL); | ||
982 | if (!card->wrUrbs[j].urb) { | ||
983 | err("No free urbs available"); | ||
984 | goto error; | ||
985 | } | ||
986 | card->wrUrbs[j].buffer = usb_buffer_alloc(udev, | ||
987 | card->wrUrbs[j].size, GFP_KERNEL, | ||
988 | &card->wrUrbs[j].urb->transfer_dma); | ||
989 | |||
990 | if (!card->wrUrbs[j].buffer) { | ||
991 | err("Couldn't allocate bulk_out_buffer"); | ||
992 | goto error; | ||
993 | } | ||
994 | |||
995 | usb_fill_bulk_urb(card->wrUrbs[j].urb, udev, | ||
996 | usb_sndbulkpipe(udev, endpoint->bEndpointAddress), | ||
997 | card->wrUrbs[j].buffer, | ||
998 | card->wrUrbs[j].size, | ||
999 | cpcusb_write_bulk_callback, | ||
1000 | card); | ||
1001 | } | ||
1002 | |||
1003 | info("%s - %d writing URB's allocated", __func__, CPC_USB_URB_CNT); | ||
1004 | } | ||
1005 | } | ||
1006 | |||
1007 | if (!(card->num_bulk_in && card->num_bulk_out)) { | ||
1008 | err("Couldn't find both bulk-in and bulk-out endpoints"); | ||
1009 | goto error; | ||
1010 | } | ||
1011 | |||
1012 | /* allow device read, write and ioctl */ | ||
1013 | card->present = 1; | ||
1014 | |||
1015 | /* we can register the device now, as it is ready */ | ||
1016 | usb_set_intfdata(interface, card); | ||
1017 | retval = usb_register_dev(interface, &cpcusb_class); | ||
1018 | |||
1019 | if (retval) { | ||
1020 | /* something prevented us from registering this driver */ | ||
1021 | err("Not able to get a minor for this device."); | ||
1022 | usb_set_intfdata(interface, NULL); | ||
1023 | goto error; | ||
1024 | } | ||
1025 | |||
1026 | card->chan->minor = card->minor = interface->minor; | ||
1027 | |||
1028 | chan->buf = vmalloc(sizeof(CPC_MSG_T) * CPC_MSG_BUF_CNT); | ||
1029 | if (chan->buf == NULL) { | ||
1030 | err("Out of memory"); | ||
1031 | retval = -ENOMEM; | ||
1032 | goto error; | ||
1033 | } | ||
1034 | info("Allocated memory for %d messages (%lu kbytes)", | ||
1035 | CPC_MSG_BUF_CNT, (long unsigned int)(sizeof(CPC_MSG_T) * CPC_MSG_BUF_CNT) / 1000); | ||
1036 | memset(chan->buf, 0, sizeof(CPC_MSG_T) * CPC_MSG_BUF_CNT); | ||
1037 | |||
1038 | ResetBuffer(chan); | ||
1039 | |||
1040 | card->chan->CPCWait_q = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL); | ||
1041 | if (!card->chan->CPCWait_q) { | ||
1042 | err("Out of memory"); | ||
1043 | retval = -ENOMEM; | ||
1044 | goto error; | ||
1045 | } | ||
1046 | init_waitqueue_head(card->chan->CPCWait_q); | ||
1047 | |||
1048 | CPCUSB_Table[slot] = card; | ||
1049 | card->idx = slot; | ||
1050 | CPCUsbCnt++; | ||
1051 | |||
1052 | /* let the user know what node this device is now attached to */ | ||
1053 | info("Device now attached to USB-%d", card->minor); | ||
1054 | return 0; | ||
1055 | |||
1056 | error: | ||
1057 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
1058 | if (card->urbs[j].buffer) { | ||
1059 | usb_buffer_free(card->udev, card->urbs[j].size, | ||
1060 | card->urbs[j].buffer, | ||
1061 | card->urbs[j].urb->transfer_dma); | ||
1062 | card->urbs[j].buffer = NULL; | ||
1063 | } | ||
1064 | if (card->urbs[j].urb) { | ||
1065 | usb_free_urb(card->urbs[j].urb); | ||
1066 | card->urbs[j].urb = NULL; | ||
1067 | } | ||
1068 | } | ||
1069 | |||
1070 | cpcusb_delete(card); | ||
1071 | return retval; | ||
1072 | } | ||
1073 | |||
1074 | /* | ||
1075 | * called by the usb core when the device is removed from the system | ||
1076 | */ | ||
1077 | static void cpcusb_disconnect(struct usb_interface *interface) | ||
1078 | { | ||
1079 | CPC_USB_T *card = NULL; | ||
1080 | int minor, j; | ||
1081 | |||
1082 | /* prevent races with open() */ | ||
1083 | down(&disconnect_sem); | ||
1084 | |||
1085 | card = usb_get_intfdata(interface); | ||
1086 | usb_set_intfdata(interface, NULL); | ||
1087 | |||
1088 | down(&card->sem); | ||
1089 | |||
1090 | /* prevent device read, write and ioctl */ | ||
1091 | card->present = 0; | ||
1092 | |||
1093 | minor = card->minor; | ||
1094 | |||
1095 | /* free all urbs and their buffers */ | ||
1096 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
1097 | /* terminate an ongoing write */ | ||
1098 | if (atomic_read(&card->wrUrbs[j].busy)) { | ||
1099 | usb_kill_urb(card->wrUrbs[j].urb); | ||
1100 | wait_for_completion(&card->wrUrbs[j].finished); | ||
1101 | } | ||
1102 | usb_buffer_free(card->udev, card->wrUrbs[j].size, | ||
1103 | card->wrUrbs[j].buffer, | ||
1104 | card->wrUrbs[j].urb->transfer_dma); | ||
1105 | usb_free_urb(card->wrUrbs[j].urb); | ||
1106 | } | ||
1107 | info("%d write URBs freed", CPC_USB_URB_CNT); | ||
1108 | |||
1109 | /* free all urbs and their buffers */ | ||
1110 | for (j = 0; j < CPC_USB_URB_CNT; j++) { | ||
1111 | usb_buffer_free(card->udev, card->urbs[j].size, | ||
1112 | card->urbs[j].buffer, | ||
1113 | card->urbs[j].urb->transfer_dma); | ||
1114 | usb_free_urb(card->urbs[j].urb); | ||
1115 | } | ||
1116 | info("%d read URBs freed", CPC_USB_URB_CNT); | ||
1117 | usb_free_urb(card->intr_in_urb); | ||
1118 | |||
1119 | /* give back our minor */ | ||
1120 | usb_deregister_dev(interface, &cpcusb_class); | ||
1121 | |||
1122 | up(&card->sem); | ||
1123 | |||
1124 | /* if the device is opened, cpcusb_release will clean this up */ | ||
1125 | if (!card->open) | ||
1126 | cpcusb_delete(card); | ||
1127 | else | ||
1128 | wake_up_interruptible(card->chan->CPCWait_q); | ||
1129 | |||
1130 | up(&disconnect_sem); | ||
1131 | |||
1132 | CPCUsbCnt--; | ||
1133 | info("USB-%d now disconnected", minor); | ||
1134 | } | ||
1135 | |||
1136 | static int __init CPCUsb_Init(void) | ||
1137 | { | ||
1138 | int result, i; | ||
1139 | |||
1140 | info(DRIVER_DESC " v" DRIVER_VERSION); | ||
1141 | info("Build on " __DATE__ " at " __TIME__); | ||
1142 | |||
1143 | for (i = 0; i < CPC_USB_CARD_CNT; i++) | ||
1144 | CPCUSB_Table[i] = 0; | ||
1145 | |||
1146 | /* register this driver with the USB subsystem */ | ||
1147 | result = usb_register(&cpcusb_driver); | ||
1148 | if (result) { | ||
1149 | err("usb_register failed. Error number %d", result); | ||
1150 | return result; | ||
1151 | } | ||
1152 | |||
1153 | procDir = proc_mkdir(CPC_USB_PROC_DIR, NULL); | ||
1154 | if (!procDir) { | ||
1155 | err("Could not create proc entry"); | ||
1156 | } else { | ||
1157 | procEntry = create_proc_read_entry("info", 0444, procDir, | ||
1158 | cpcusb_proc_read_info, | ||
1159 | NULL); | ||
1160 | if (!procEntry) { | ||
1161 | err("Could not create proc entry %s", CPC_USB_PROC_DIR "/info"); | ||
1162 | remove_proc_entry(CPC_USB_PROC_DIR, NULL); | ||
1163 | procDir = NULL; | ||
1164 | } | ||
1165 | } | ||
1166 | |||
1167 | return 0; | ||
1168 | } | ||
1169 | |||
1170 | static void __exit CPCUsb_Exit(void) | ||
1171 | { | ||
1172 | wait_event(rmmodWq, !atomic_read(&useCount)); | ||
1173 | |||
1174 | /* deregister this driver with the USB subsystem */ | ||
1175 | usb_deregister(&cpcusb_driver); | ||
1176 | |||
1177 | if (procDir) { | ||
1178 | if (procEntry) | ||
1179 | remove_proc_entry("info", procDir); | ||
1180 | remove_proc_entry(CPC_USB_PROC_DIR, NULL); | ||
1181 | } | ||
1182 | } | ||
1183 | |||
1184 | module_init(CPCUsb_Init); | ||
1185 | module_exit(CPCUsb_Exit); | ||
diff --git a/drivers/staging/cpc-usb/cpc.h b/drivers/staging/cpc-usb/cpc.h deleted file mode 100644 index ed8cb34d4763..000000000000 --- a/drivers/staging/cpc-usb/cpc.h +++ /dev/null | |||
@@ -1,440 +0,0 @@ | |||
1 | /* | ||
2 | * CPC CAN Interface Definitions | ||
3 | * | ||
4 | * Copyright (C) 2000-2008 EMS Dr. Thomas Wuensche | ||
5 | * | ||
6 | * This program is distributed in the hope that it will be useful, but | ||
7 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
9 | */ | ||
10 | #ifndef CPC_HEADER | ||
11 | #define CPC_HEADER | ||
12 | |||
13 | // the maximum length of the union members within a CPC_MSG | ||
14 | // this value can be defined by the customer, but has to be | ||
15 | // >= 64 bytes | ||
16 | // however, if not defined before, we set a length of 64 byte | ||
17 | #if !defined(CPC_MSG_LEN) || (CPC_MSG_LEN < 64) | ||
18 | #undef CPC_MSG_LEN | ||
19 | #define CPC_MSG_LEN 64 | ||
20 | #endif | ||
21 | |||
22 | // check the operating system used | ||
23 | #ifdef _WIN32 // running a Windows OS | ||
24 | |||
25 | // define basic types on Windows platforms | ||
26 | #ifdef _MSC_VER // Visual Studio | ||
27 | typedef unsigned __int8 u8; | ||
28 | typedef unsigned __int16 u16; | ||
29 | typedef unsigned __int32 u32; | ||
30 | #else // Borland Compiler | ||
31 | typedef unsigned char u8; | ||
32 | typedef unsigned short u16; | ||
33 | typedef unsigned int u32; | ||
34 | #endif | ||
35 | // on Windows OS we use a byte alignment of 1 | ||
36 | #pragma pack(push, 1) | ||
37 | |||
38 | // set the calling conventions for the library function calls | ||
39 | #define CALL_CONV __stdcall | ||
40 | #else | ||
41 | // Kernel headers already define this types | ||
42 | #ifndef __KERNEL__ | ||
43 | // define basic types | ||
44 | typedef unsigned char u8; | ||
45 | typedef unsigned short u16; | ||
46 | typedef unsigned int u32; | ||
47 | #endif | ||
48 | |||
49 | // Linux does not use this calling convention | ||
50 | #define CALL_CONV | ||
51 | #endif | ||
52 | |||
53 | // Transmission of events from CPC interfaces to PC can be individually | ||
54 | // controlled per event type. Default state is: don't transmit | ||
55 | // Control values are constructed by bit-or of Subject and Action | ||
56 | // and passed to CPC_Control() | ||
57 | |||
58 | // Control-Values for CPC_Control() Command Subject Selection | ||
59 | #define CONTR_CAN_Message 0x04 | ||
60 | #define CONTR_Busload 0x08 | ||
61 | #define CONTR_CAN_State 0x0C | ||
62 | #define CONTR_SendAck 0x10 | ||
63 | #define CONTR_Filter 0x14 | ||
64 | #define CONTR_CmdQueue 0x18 // reserved, do not use | ||
65 | #define CONTR_BusError 0x1C | ||
66 | |||
67 | // Control Command Actions | ||
68 | #define CONTR_CONT_OFF 0 | ||
69 | #define CONTR_CONT_ON 1 | ||
70 | #define CONTR_SING_ON 2 | ||
71 | // CONTR_SING_ON doesn't change CONTR_CONT_ON state, so it should be | ||
72 | // read as: transmit at least once | ||
73 | |||
74 | // defines for confirmed request | ||
75 | #define DO_NOT_CONFIRM 0 | ||
76 | #define DO_CONFIRM 1 | ||
77 | |||
78 | // event flags | ||
79 | #define EVENT_READ 0x01 | ||
80 | #define EVENT_WRITE 0x02 | ||
81 | |||
82 | // Messages from CPC to PC contain a message object type field. | ||
83 | // The following message types are sent by CPC and can be used in | ||
84 | // handlers, others should be ignored. | ||
85 | #define CPC_MSG_T_RESYNC 0 // Normally to be ignored | ||
86 | #define CPC_MSG_T_CAN 1 // CAN data frame | ||
87 | #define CPC_MSG_T_BUSLOAD 2 // Busload message | ||
88 | #define CPC_MSG_T_STRING 3 // Normally to be ignored | ||
89 | #define CPC_MSG_T_CONTI 4 // Normally to be ignored | ||
90 | #define CPC_MSG_T_MEM 7 // Normally not to be handled | ||
91 | #define CPC_MSG_T_RTR 8 // CAN remote frame | ||
92 | #define CPC_MSG_T_TXACK 9 // Send acknowledge | ||
93 | #define CPC_MSG_T_POWERUP 10 // Power-up message | ||
94 | #define CPC_MSG_T_CMD_NO 11 // Normally to be ignored | ||
95 | #define CPC_MSG_T_CAN_PRMS 12 // Actual CAN parameters | ||
96 | #define CPC_MSG_T_ABORTED 13 // Command aborted message | ||
97 | #define CPC_MSG_T_CANSTATE 14 // CAN state message | ||
98 | #define CPC_MSG_T_RESET 15 // used to reset CAN-Controller | ||
99 | #define CPC_MSG_T_XCAN 16 // XCAN data frame | ||
100 | #define CPC_MSG_T_XRTR 17 // XCAN remote frame | ||
101 | #define CPC_MSG_T_INFO 18 // information strings | ||
102 | #define CPC_MSG_T_CONTROL 19 // used for control of interface/driver behaviour | ||
103 | #define CPC_MSG_T_CONFIRM 20 // response type for confirmed requests | ||
104 | #define CPC_MSG_T_OVERRUN 21 // response type for overrun conditions | ||
105 | #define CPC_MSG_T_KEEPALIVE 22 // response type for keep alive conditions | ||
106 | #define CPC_MSG_T_CANERROR 23 // response type for bus error conditions | ||
107 | #define CPC_MSG_T_DISCONNECTED 24 // response type for a disconnected interface | ||
108 | #define CPC_MSG_T_ERR_COUNTER 25 // RX/TX error counter of CAN controller | ||
109 | |||
110 | #define CPC_MSG_T_FIRMWARE 100 // response type for USB firmware download | ||
111 | |||
112 | // Messages from the PC to the CPC interface contain a command field | ||
113 | // Most of the command types are wrapped by the library functions and have therefore | ||
114 | // normally not to be used. | ||
115 | // However, programmers who wish to circumvent the library and talk directly | ||
116 | // to the drivers (mainly Linux programmers) can use the following | ||
117 | // command types: | ||
118 | |||
119 | #define CPC_CMD_T_CAN 1 // CAN data frame | ||
120 | #define CPC_CMD_T_CONTROL 3 // used for control of interface/driver behaviour | ||
121 | #define CPC_CMD_T_CAN_PRMS 6 // set CAN parameters | ||
122 | #define CPC_CMD_T_CLEARBUF 8 // clears input queue; this is depricated, use CPC_CMD_T_CLEAR_MSG_QUEUE instead | ||
123 | #define CPC_CMD_T_INQ_CAN_PARMS 11 // inquire actual CAN parameters | ||
124 | #define CPC_CMD_T_FILTER_PRMS 12 // set filter parameter | ||
125 | #define CPC_CMD_T_RTR 13 // CAN remote frame | ||
126 | #define CPC_CMD_T_CANSTATE 14 // CAN state message | ||
127 | #define CPC_CMD_T_XCAN 15 // XCAN data frame | ||
128 | #define CPC_CMD_T_XRTR 16 // XCAN remote frame | ||
129 | #define CPC_CMD_T_RESET 17 // used to reset CAN-Controller | ||
130 | #define CPC_CMD_T_INQ_INFO 18 // miscellanous information strings | ||
131 | #define CPC_CMD_T_OPEN_CHAN 19 // open a channel | ||
132 | #define CPC_CMD_T_CLOSE_CHAN 20 // close a channel | ||
133 | #define CPC_CMD_T_CNTBUF 21 // this is depricated, use CPC_CMD_T_INQ_MSG_QUEUE_CNT instead | ||
134 | #define CPC_CMD_T_CAN_EXIT 200 // exit the CAN (disable interrupts; reset bootrate; reset output_cntr; mode = 1) | ||
135 | |||
136 | #define CPC_CMD_T_INQ_MSG_QUEUE_CNT CPC_CMD_T_CNTBUF // inquires the count of elements in the message queue | ||
137 | #define CPC_CMD_T_INQ_ERR_COUNTER 25 // request the CAN controllers error counter | ||
138 | #define CPC_CMD_T_CLEAR_MSG_QUEUE CPC_CMD_T_CLEARBUF // clear CPC_MSG queue | ||
139 | #define CPC_CMD_T_CLEAR_CMD_QUEUE 28 // clear CPC_CMD queue | ||
140 | #define CPC_CMD_T_FIRMWARE 100 // reserved, must not be used | ||
141 | #define CPC_CMD_T_USB_RESET 101 // reserved, must not be used | ||
142 | #define CPC_CMD_T_WAIT_NOTIFY 102 // reserved, must not be used | ||
143 | #define CPC_CMD_T_WAIT_SETUP 103 // reserved, must not be used | ||
144 | #define CPC_CMD_T_ABORT 255 // Normally not to be used | ||
145 | |||
146 | // definitions for CPC_MSG_T_INFO | ||
147 | // information sources | ||
148 | #define CPC_INFOMSG_T_UNKNOWN_SOURCE 0 | ||
149 | #define CPC_INFOMSG_T_INTERFACE 1 | ||
150 | #define CPC_INFOMSG_T_DRIVER 2 | ||
151 | #define CPC_INFOMSG_T_LIBRARY 3 | ||
152 | |||
153 | // information types | ||
154 | #define CPC_INFOMSG_T_UNKNOWN_TYPE 0 | ||
155 | #define CPC_INFOMSG_T_VERSION 1 | ||
156 | #define CPC_INFOMSG_T_SERIAL 2 | ||
157 | |||
158 | // definitions for controller types | ||
159 | #define PCA82C200 1 // Philips basic CAN controller, replaced by SJA1000 | ||
160 | #define SJA1000 2 // Philips basic CAN controller | ||
161 | #define AN82527 3 // Intel full CAN controller | ||
162 | #define M16C_BASIC 4 // M16C controller running in basic CAN (not full CAN) mode | ||
163 | |||
164 | // channel open error codes | ||
165 | #define CPC_ERR_NO_FREE_CHANNEL -1 // no more free space within the channel array | ||
166 | #define CPC_ERR_CHANNEL_ALREADY_OPEN -2 // the channel is already open | ||
167 | #define CPC_ERR_CHANNEL_NOT_ACTIVE -3 // access to a channel not active failed | ||
168 | #define CPC_ERR_NO_DRIVER_PRESENT -4 // no driver at the location searched by the library | ||
169 | #define CPC_ERR_NO_INIFILE_PRESENT -5 // the library could not find the inifile | ||
170 | #define CPC_ERR_WRONG_PARAMETERS -6 // wrong parameters in the inifile | ||
171 | #define CPC_ERR_NO_INTERFACE_PRESENT -7 // 1. The specified interface is not connected | ||
172 | // 2. The interface (mostly CPC-USB) was disconnected upon operation | ||
173 | #define CPC_ERR_NO_MATCHING_CHANNEL -8 // the driver couldn't find a matching channel | ||
174 | #define CPC_ERR_NO_BUFFER_AVAILABLE -9 // the driver couldn't allocate buffer for messages | ||
175 | #define CPC_ERR_NO_INTERRUPT -10 // the requested interrupt couldn't be claimed | ||
176 | #define CPC_ERR_NO_MATCHING_INTERFACE -11 // no interface type related to this channel was found | ||
177 | #define CPC_ERR_NO_RESOURCES -12 // the requested resources could not be claimed | ||
178 | #define CPC_ERR_SOCKET -13 // error concerning TCP sockets | ||
179 | |||
180 | // init error codes | ||
181 | #define CPC_ERR_WRONG_CONTROLLER_TYPE -14 // wrong CAN controller type within initialization | ||
182 | #define CPC_ERR_NO_RESET_MODE -15 // the controller could not be set into reset mode | ||
183 | #define CPC_ERR_NO_CAN_ACCESS -16 // the CAN controller could not be accessed | ||
184 | |||
185 | // transmit error codes | ||
186 | #define CPC_ERR_CAN_WRONG_ID -20 // the provided CAN id is too big | ||
187 | #define CPC_ERR_CAN_WRONG_LENGTH -21 // the provided CAN length is too long | ||
188 | #define CPC_ERR_CAN_NO_TRANSMIT_BUF -22 // the transmit buffer was occupied | ||
189 | #define CPC_ERR_CAN_TRANSMIT_TIMEOUT -23 // The message could not be sent within a | ||
190 | // specified time | ||
191 | |||
192 | // other error codes | ||
193 | #define CPC_ERR_SERVICE_NOT_SUPPORTED -30 // the requested service is not supported by the interface | ||
194 | #define CPC_ERR_IO_TRANSFER -31 // a transmission error down to the driver occurred | ||
195 | #define CPC_ERR_TRANSMISSION_FAILED -32 // a transmission error down to the interface occurred | ||
196 | #define CPC_ERR_TRANSMISSION_TIMEOUT -33 // a timeout occurred within transmission to the interface | ||
197 | #define CPC_ERR_OP_SYS_NOT_SUPPORTED -35 // the operating system is not supported | ||
198 | #define CPC_ERR_UNKNOWN -40 // an unknown error ocurred (mostly IOCTL errors) | ||
199 | |||
200 | #define CPC_ERR_LOADING_DLL -50 // the library 'cpcwin.dll' could not be loaded | ||
201 | #define CPC_ERR_ASSIGNING_FUNCTION -51 // the specified function could not be assigned | ||
202 | #define CPC_ERR_DLL_INITIALIZATION -52 // the DLL was not initialized correctly | ||
203 | #define CPC_ERR_MISSING_LICFILE -55 // the file containing the licenses does not exist | ||
204 | #define CPC_ERR_MISSING_LICENSE -56 // a required license was not found | ||
205 | |||
206 | // CAN state bit values. Ignore any bits not listed | ||
207 | #define CPC_CAN_STATE_BUSOFF 0x80 | ||
208 | #define CPC_CAN_STATE_ERROR 0x40 | ||
209 | |||
210 | // Mask to help ignore undefined bits | ||
211 | #define CPC_CAN_STATE_MASK 0xc0 | ||
212 | |||
213 | // CAN-Message representation in a CPC_MSG | ||
214 | // Message object type is CPC_MSG_T_CAN or CPC_MSG_T_RTR | ||
215 | // or CPC_MSG_T_XCAN or CPC_MSG_T_XRTR | ||
216 | typedef struct CPC_CAN_MSG { | ||
217 | u32 id; | ||
218 | u8 length; | ||
219 | u8 msg[8]; | ||
220 | } CPC_CAN_MSG_T; | ||
221 | |||
222 | |||
223 | // representation of the CAN parameters for the PCA82C200 controller | ||
224 | typedef struct CPC_PCA82C200_PARAMS { | ||
225 | u8 acc_code; // Acceptance-code for receive, Standard: 0 | ||
226 | u8 acc_mask; // Acceptance-mask for receive, Standard: 0xff (everything) | ||
227 | u8 btr0; // Bus-timing register 0 | ||
228 | u8 btr1; // Bus-timing register 1 | ||
229 | u8 outp_contr; // Output-control register | ||
230 | } CPC_PCA82C200_PARAMS_T; | ||
231 | |||
232 | // representation of the CAN parameters for the SJA1000 controller | ||
233 | typedef struct CPC_SJA1000_PARAMS { | ||
234 | u8 mode; // enables single or dual acceptance filtering | ||
235 | u8 acc_code0; // Acceptance-code for receive, Standard: 0 | ||
236 | u8 acc_code1; | ||
237 | u8 acc_code2; | ||
238 | u8 acc_code3; | ||
239 | u8 acc_mask0; // Acceptance-mask for receive, Standard: 0xff (everything) | ||
240 | u8 acc_mask1; | ||
241 | u8 acc_mask2; | ||
242 | u8 acc_mask3; | ||
243 | u8 btr0; // Bus-timing register 0 | ||
244 | u8 btr1; // Bus-timing register 1 | ||
245 | u8 outp_contr; // Output-control register | ||
246 | } CPC_SJA1000_PARAMS_T; | ||
247 | |||
248 | // representation of the CAN parameters for the M16C controller | ||
249 | // in basic CAN mode (means no full CAN) | ||
250 | typedef struct CPC_M16C_BASIC_PARAMS { | ||
251 | u8 con0; | ||
252 | u8 con1; | ||
253 | u8 ctlr0; | ||
254 | u8 ctlr1; | ||
255 | u8 clk; | ||
256 | u8 acc_std_code0; | ||
257 | u8 acc_std_code1; | ||
258 | u8 acc_ext_code0; | ||
259 | u8 acc_ext_code1; | ||
260 | u8 acc_ext_code2; | ||
261 | u8 acc_ext_code3; | ||
262 | u8 acc_std_mask0; | ||
263 | u8 acc_std_mask1; | ||
264 | u8 acc_ext_mask0; | ||
265 | u8 acc_ext_mask1; | ||
266 | u8 acc_ext_mask2; | ||
267 | u8 acc_ext_mask3; | ||
268 | } CPC_M16C_BASIC_PARAMS_T; | ||
269 | |||
270 | // CAN params message representation | ||
271 | typedef struct CPC_CAN_PARAMS { | ||
272 | u8 cc_type; // represents the controller type | ||
273 | union { | ||
274 | CPC_M16C_BASIC_PARAMS_T m16c_basic; | ||
275 | CPC_SJA1000_PARAMS_T sja1000; | ||
276 | CPC_PCA82C200_PARAMS_T pca82c200; | ||
277 | } cc_params; | ||
278 | } CPC_CAN_PARAMS_T; | ||
279 | |||
280 | // the following structures are slightly different for Windows and Linux | ||
281 | // To be able to use the 'Select' mechanism with Linux the application | ||
282 | // needs to know the devices file desciptor. | ||
283 | // This mechanism is not implemented within Windows and the file descriptor | ||
284 | // is therefore not needed | ||
285 | #ifdef _WIN32 | ||
286 | |||
287 | // CAN init params message representation | ||
288 | typedef struct CPC_INIT_PARAMS { | ||
289 | CPC_CAN_PARAMS_T canparams; | ||
290 | } CPC_INIT_PARAMS_T; | ||
291 | |||
292 | #else// Linux | ||
293 | |||
294 | // CHAN init params representation | ||
295 | typedef struct CPC_CHAN_PARAMS { | ||
296 | int fd; | ||
297 | } CPC_CHAN_PARAMS_T; | ||
298 | |||
299 | // CAN init params message representation | ||
300 | typedef struct CPC_INIT_PARAMS { | ||
301 | CPC_CHAN_PARAMS_T chanparams; | ||
302 | CPC_CAN_PARAMS_T canparams; | ||
303 | } CPC_INIT_PARAMS_T; | ||
304 | |||
305 | #endif | ||
306 | |||
307 | // structure for confirmed message handling | ||
308 | typedef struct CPC_CONFIRM { | ||
309 | u8 result; // error code | ||
310 | } CPC_CONFIRM_T; | ||
311 | |||
312 | // structure for information requests | ||
313 | typedef struct CPC_INFO { | ||
314 | u8 source; // interface, driver or library | ||
315 | u8 type; // version or serial number | ||
316 | char msg[CPC_MSG_LEN - 2]; // string holding the requested information | ||
317 | } CPC_INFO_T; | ||
318 | |||
319 | // OVERRUN /////////////////////////////////////// | ||
320 | // In general two types of overrun may occur. | ||
321 | // A hardware overrun, where the CAN controller | ||
322 | // lost a message, because the interrupt was | ||
323 | // not handled before the next messgae comes in. | ||
324 | // Or a software overrun, where i.e. a received | ||
325 | // message could not be stored in the CPC_MSG | ||
326 | // buffer. | ||
327 | |||
328 | // After a software overrun has occurred | ||
329 | // we wait until we have CPC_OVR_GAP slots | ||
330 | // free in the CPC_MSG buffer. | ||
331 | #define CPC_OVR_GAP 10 | ||
332 | |||
333 | // Two types of software overrun may occur. | ||
334 | // A received CAN message or a CAN state event | ||
335 | // can cause an overrun. | ||
336 | // Note: A CPC_CMD which would normally store | ||
337 | // its result immediately in the CPC_MSG | ||
338 | // queue may fail, because the message queue is full. | ||
339 | // This will not generate an overrun message, but | ||
340 | // will halt command execution, until this command | ||
341 | // is able to store its message in the message queue. | ||
342 | #define CPC_OVR_EVENT_CAN 0x01 | ||
343 | #define CPC_OVR_EVENT_CANSTATE 0x02 | ||
344 | #define CPC_OVR_EVENT_BUSERROR 0x04 | ||
345 | |||
346 | // If the CAN controller lost a message | ||
347 | // we indicate it with the highest bit | ||
348 | // set in the count field. | ||
349 | #define CPC_OVR_HW 0x80 | ||
350 | |||
351 | // structure for overrun conditions | ||
352 | typedef struct { | ||
353 | u8 event; | ||
354 | u8 count; | ||
355 | } CPC_OVERRUN_T; | ||
356 | |||
357 | // CAN errors //////////////////////////////////// | ||
358 | // Each CAN controller type has different | ||
359 | // registers to record errors. | ||
360 | // Therefor a structure containing the specific | ||
361 | // errors is set up for each controller here | ||
362 | |||
363 | // SJA1000 error structure | ||
364 | // see the SJA1000 datasheet for detailed | ||
365 | // explanation of the registers | ||
366 | typedef struct CPC_SJA1000_CAN_ERROR { | ||
367 | u8 ecc; // error capture code register | ||
368 | u8 rxerr; // RX error counter register | ||
369 | u8 txerr; // TX error counter register | ||
370 | } CPC_SJA1000_CAN_ERROR_T; | ||
371 | |||
372 | // M16C error structure | ||
373 | // see the M16C datasheet for detailed | ||
374 | // explanation of the registers | ||
375 | typedef struct CPC_M16C_CAN_ERROR { | ||
376 | u8 tbd; // to be defined | ||
377 | } CPC_M16C_CAN_ERROR_T; | ||
378 | |||
379 | // structure for CAN error conditions | ||
380 | #define CPC_CAN_ECODE_ERRFRAME 0x01 | ||
381 | typedef struct CPC_CAN_ERROR { | ||
382 | u8 ecode; | ||
383 | struct { | ||
384 | u8 cc_type; // CAN controller type | ||
385 | union { | ||
386 | CPC_SJA1000_CAN_ERROR_T sja1000; | ||
387 | CPC_M16C_CAN_ERROR_T m16c; | ||
388 | } regs; | ||
389 | } cc; | ||
390 | } CPC_CAN_ERROR_T; | ||
391 | |||
392 | // Structure containing RX/TX error counter. | ||
393 | // This structure is used to request the | ||
394 | // values of the CAN controllers TX and RX | ||
395 | // error counter. | ||
396 | typedef struct CPC_CAN_ERR_COUNTER { | ||
397 | u8 rx; | ||
398 | u8 tx; | ||
399 | } CPC_CAN_ERR_COUNTER_T; | ||
400 | |||
401 | // If this flag is set, transmissions from PC to CPC are protected against loss | ||
402 | #define CPC_SECURE_TO_CPC 0x01 | ||
403 | |||
404 | // If this flag is set, transmissions from CPC to PC are protected against loss | ||
405 | #define CPC_SECURE_TO_PC 0x02 | ||
406 | |||
407 | // If this flag is set, the CAN-transmit buffer is checked to be free before sending a message | ||
408 | #define CPC_SECURE_SEND 0x04 | ||
409 | |||
410 | // If this flag is set, the transmission complete flag is checked | ||
411 | // after sending a message | ||
412 | // THIS IS CURRENTLY ONLY IMPLEMENTED IN THE PASSIVE INTERFACE DRIVERS | ||
413 | #define CPC_SECURE_TRANSMIT 0x08 | ||
414 | |||
415 | // main message type used between library and application | ||
416 | typedef struct CPC_MSG { | ||
417 | u8 type; // type of message | ||
418 | u8 length; // length of data within union 'msg' | ||
419 | u8 msgid; // confirmation handle | ||
420 | u32 ts_sec; // timestamp in seconds | ||
421 | u32 ts_nsec; // timestamp in nano seconds | ||
422 | union { | ||
423 | u8 generic[CPC_MSG_LEN]; | ||
424 | CPC_CAN_MSG_T canmsg; | ||
425 | CPC_CAN_PARAMS_T canparams; | ||
426 | CPC_CONFIRM_T confirmation; | ||
427 | CPC_INFO_T info; | ||
428 | CPC_OVERRUN_T overrun; | ||
429 | CPC_CAN_ERROR_T error; | ||
430 | CPC_CAN_ERR_COUNTER_T err_counter; | ||
431 | u8 busload; | ||
432 | u8 canstate; | ||
433 | } msg; | ||
434 | } CPC_MSG_T; | ||
435 | |||
436 | #ifdef _WIN32 | ||
437 | #pragma pack(pop) // reset the byte alignment | ||
438 | #endif | ||
439 | |||
440 | #endif // CPC_HEADER | ||
diff --git a/drivers/staging/cpc-usb/cpc_int.h b/drivers/staging/cpc-usb/cpc_int.h deleted file mode 100644 index a0d60c080819..000000000000 --- a/drivers/staging/cpc-usb/cpc_int.h +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | /* | ||
2 | * CPCLIB | ||
3 | * | ||
4 | * Copyright (C) 2000-2008 EMS Dr. Thomas Wuensche | ||
5 | * | ||
6 | * This program is distributed in the hope that it will be useful, but | ||
7 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
9 | * | ||
10 | */ | ||
11 | #ifndef CPC_INT_H | ||
12 | #define CPC_INT_H | ||
13 | |||
14 | #include <linux/wait.h> | ||
15 | |||
16 | #define CPC_MSG_BUF_CNT 1500 | ||
17 | |||
18 | #define CPC_PROC_DIR "driver/" | ||
19 | |||
20 | #undef dbg | ||
21 | #undef err | ||
22 | #undef info | ||
23 | |||
24 | /* Use our own dbg macro */ | ||
25 | #define dbg(format, arg...) do { if (debug) printk( KERN_INFO format "\n" , ## arg); } while (0) | ||
26 | #define err(format, arg...) do { printk( KERN_INFO "ERROR " format "\n" , ## arg); } while (0) | ||
27 | #define info(format, arg...) do { printk( KERN_INFO format "\n" , ## arg); } while (0) | ||
28 | |||
29 | /* Macros help using of our buffers */ | ||
30 | #define IsBufferFull(x) (!(x)->WnR) && ((x)->iidx == (x)->oidx) | ||
31 | #define IsBufferEmpty(x) ((x)->WnR) && ((x)->iidx == (x)->oidx) | ||
32 | #define IsBufferNotEmpty(x) (!(x)->WnR) || ((x)->iidx != (x)->oidx) | ||
33 | #define ResetBuffer(x) do { (x)->oidx = (x)->iidx=0; (x)->WnR = 1; } while(0); | ||
34 | |||
35 | #define CPC_BufWriteAllowed ((chan->oidx != chan->iidx) || chan->WnR) | ||
36 | |||
37 | typedef void (*chan_write_byte_t) (void *chan, unsigned int reg, | ||
38 | unsigned char val); | ||
39 | typedef unsigned char (*chan_read_byte_t) (void *chan, unsigned int reg); | ||
40 | |||
41 | typedef struct CPC_CHAN { | ||
42 | void __iomem * canBase; // base address of SJA1000 | ||
43 | chan_read_byte_t read_byte; // CAN controller read access routine | ||
44 | chan_write_byte_t write_byte; // CAN controller write access routine | ||
45 | CPC_MSG_T *buf; // buffer for CPC msg | ||
46 | unsigned int iidx; | ||
47 | unsigned int oidx; | ||
48 | unsigned int WnR; | ||
49 | unsigned int minor; | ||
50 | unsigned int locked; | ||
51 | unsigned int irqDisabled; | ||
52 | |||
53 | unsigned char cpcCtrlCANMessage; | ||
54 | unsigned char cpcCtrlCANState; | ||
55 | unsigned char cpcCtrlBUSState; | ||
56 | |||
57 | unsigned char controllerType; | ||
58 | |||
59 | unsigned long ovrTimeSec; | ||
60 | unsigned long ovrTimeNSec; | ||
61 | unsigned long ovrLockedBuffer; | ||
62 | CPC_OVERRUN_T ovr; | ||
63 | |||
64 | /* for debugging only */ | ||
65 | unsigned int handledIrqs; | ||
66 | unsigned int lostMessages; | ||
67 | |||
68 | unsigned int sentStdCan; | ||
69 | unsigned int sentExtCan; | ||
70 | unsigned int sentStdRtr; | ||
71 | unsigned int sentExtRtr; | ||
72 | |||
73 | unsigned int recvStdCan; | ||
74 | unsigned int recvExtCan; | ||
75 | unsigned int recvStdRtr; | ||
76 | unsigned int recvExtRtr; | ||
77 | |||
78 | wait_queue_head_t *CPCWait_q; | ||
79 | |||
80 | void *private; | ||
81 | } CPC_CHAN_T; | ||
82 | |||
83 | #endif | ||
diff --git a/drivers/staging/cpc-usb/cpcusb.h b/drivers/staging/cpc-usb/cpcusb.h deleted file mode 100644 index e5273ddd9e0a..000000000000 --- a/drivers/staging/cpc-usb/cpcusb.h +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | /* Header for CPC-USB Driver ******************** | ||
2 | * Copyright 1999, 2000, 2001 | ||
3 | * | ||
4 | * Company: EMS Dr. Thomas Wuensche | ||
5 | * Sonnenhang 3 | ||
6 | * 85304 Ilmmuenster | ||
7 | * Phone: +49-8441-490260 | ||
8 | * Fax: +49-8441-81860 | ||
9 | * email: support@ems-wuensche.com | ||
10 | * WWW: www.ems-wuensche.com | ||
11 | */ | ||
12 | |||
13 | #ifndef CPCUSB_H | ||
14 | #define CPCUSB_H | ||
15 | |||
16 | #undef err | ||
17 | #undef dbg | ||
18 | #undef info | ||
19 | |||
20 | /* Use our own dbg macro */ | ||
21 | #define dbg(format, arg...) do { if (debug) printk(KERN_INFO "CPC-USB: " format "\n" , ## arg); } while (0) | ||
22 | #define info(format, arg...) do { printk(KERN_INFO "CPC-USB: " format "\n" , ## arg); } while (0) | ||
23 | #define err(format, arg...) do { printk(KERN_INFO "CPC-USB(ERROR): " format "\n" , ## arg); } while (0) | ||
24 | |||
25 | #define CPC_USB_CARD_CNT 4 | ||
26 | |||
27 | typedef struct CPC_USB_READ_URB { | ||
28 | unsigned char *buffer; /* the buffer to send data */ | ||
29 | size_t size; /* the size of the send buffer */ | ||
30 | struct urb *urb; /* the urb used to send data */ | ||
31 | } CPC_USB_READ_URB_T; | ||
32 | |||
33 | typedef struct CPC_USB_WRITE_URB { | ||
34 | unsigned char *buffer; /* the buffer to send data */ | ||
35 | size_t size; /* the size of the send buffer */ | ||
36 | struct urb *urb; /* the urb used to send data */ | ||
37 | atomic_t busy; /* true if write urb is busy */ | ||
38 | struct completion finished; /* wait for the write to finish */ | ||
39 | } CPC_USB_WRITE_URB_T; | ||
40 | |||
41 | #define CPC_USB_URB_CNT 10 | ||
42 | |||
43 | typedef struct CPC_USB { | ||
44 | struct usb_device *udev; /* save off the usb device pointer */ | ||
45 | struct usb_interface *interface; /* the interface for this device */ | ||
46 | unsigned char minor; /* the starting minor number for this device */ | ||
47 | unsigned char num_ports; /* the number of ports this device has */ | ||
48 | int num_intr_in; /* number of interrupt in endpoints we have */ | ||
49 | int num_bulk_in; /* number of bulk in endpoints we have */ | ||
50 | int num_bulk_out; /* number of bulk out endpoints we have */ | ||
51 | |||
52 | CPC_USB_READ_URB_T urbs[CPC_USB_URB_CNT]; | ||
53 | |||
54 | unsigned char intr_in_buffer[4]; /* interrupt transfer buffer */ | ||
55 | struct urb *intr_in_urb; /* interrupt transfer urb */ | ||
56 | |||
57 | CPC_USB_WRITE_URB_T wrUrbs[CPC_USB_URB_CNT]; | ||
58 | |||
59 | int open; /* if the port is open or not */ | ||
60 | int present; /* if the device is not disconnected */ | ||
61 | struct semaphore sem; /* locks this structure */ | ||
62 | |||
63 | int free_slots; /* free send slots of CPC-USB */ | ||
64 | int idx; | ||
65 | |||
66 | spinlock_t slock; | ||
67 | |||
68 | char serialNumber[128]; /* serial number */ | ||
69 | int productId; /* product id to differ between M16C and LPC2119 */ | ||
70 | CPC_CHAN_T *chan; | ||
71 | } CPC_USB_T; | ||
72 | |||
73 | #define CPCTable CPCUSB_Table | ||
74 | |||
75 | #define CPC_DRIVER_VERSION "0.724" | ||
76 | #define CPC_DRIVER_SERIAL "not applicable" | ||
77 | |||
78 | #define OBUF_SIZE 255 // 4096 | ||
79 | |||
80 | /* read timeouts -- RD_NAK_TIMEOUT * RD_EXPIRE = Number of seconds */ | ||
81 | #define RD_NAK_TIMEOUT (10*HZ) /* Default number of X seconds to wait */ | ||
82 | #define RD_EXPIRE 12 /* Number of attempts to wait X seconds */ | ||
83 | |||
84 | #define CPC_USB_BASE_MNR 0 /* CPC-USB start at minor 0 */ | ||
85 | |||
86 | #endif | ||
diff --git a/drivers/staging/cpc-usb/sja2m16c.h b/drivers/staging/cpc-usb/sja2m16c.h deleted file mode 100644 index 654bd3fc91dc..000000000000 --- a/drivers/staging/cpc-usb/sja2m16c.h +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | #ifndef _SJA2M16C_H | ||
2 | #define _SJA2M16C_H | ||
3 | |||
4 | #include "cpc.h" | ||
5 | |||
6 | #define BAUDRATE_TOLERANCE_PERCENT 1 | ||
7 | #define SAMPLEPOINT_TOLERANCE_PERCENT 5 | ||
8 | #define SAMPLEPOINT_UPPER_LIMIT 88 | ||
9 | |||
10 | /* M16C parameters */ | ||
11 | struct FIELD_C0CONR { | ||
12 | unsigned int brp:4; | ||
13 | unsigned int sam:1; | ||
14 | unsigned int pr:3; | ||
15 | unsigned int dummy:8; | ||
16 | }; | ||
17 | struct FIELD_C1CONR { | ||
18 | unsigned int ph1:3; | ||
19 | unsigned int ph2:3; | ||
20 | unsigned int sjw:2; | ||
21 | unsigned int dummy:8; | ||
22 | }; | ||
23 | typedef union C0CONR { | ||
24 | unsigned char c0con; | ||
25 | struct FIELD_C0CONR bc0con; | ||
26 | } C0CONR_T; | ||
27 | typedef union C1CONR { | ||
28 | unsigned char c1con; | ||
29 | struct FIELD_C1CONR bc1con; | ||
30 | } C1CONR_T; | ||
31 | |||
32 | #define SJA_TSEG1 ((pParams->btr1 & 0x0f)+1) | ||
33 | #define SJA_TSEG2 (((pParams->btr1 & 0x70)>>4)+1) | ||
34 | #define SJA_BRP ((pParams->btr0 & 0x3f)+1) | ||
35 | #define SJA_SJW ((pParams->btr0 & 0xc0)>>6) | ||
36 | #define SJA_SAM ((pParams->btr1 & 0x80)>>7) | ||
37 | int baudrate_m16c(int clk, int brp, int pr, int ph1, int ph2); | ||
38 | int samplepoint_m16c(int brp, int pr, int ph1, int ph2); | ||
39 | int SJA1000_TO_M16C_BASIC_Params(CPC_MSG_T *pMsg); | ||
40 | |||
41 | #endif | ||
diff --git a/drivers/staging/cpc-usb/sja2m16c_2.c b/drivers/staging/cpc-usb/sja2m16c_2.c deleted file mode 100644 index bf0230fb7780..000000000000 --- a/drivers/staging/cpc-usb/sja2m16c_2.c +++ /dev/null | |||
@@ -1,452 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | * | ||
3 | * Copyright (c) 2003,2004 by EMS Dr. Thomas Wuensche | ||
4 | * | ||
5 | * - All rights reserved - | ||
6 | * | ||
7 | * This code is provided "as is" without warranty of any kind, either | ||
8 | * expressed or implied, including but not limited to the liability | ||
9 | * concerning the freedom from material defects, the fitness for parti- | ||
10 | * cular purposes or the freedom of proprietary rights of third parties. | ||
11 | * | ||
12 | ***************************************************************************** | ||
13 | * Module name.: cpcusb | ||
14 | ***************************************************************************** | ||
15 | * Include file: cpc.h | ||
16 | ***************************************************************************** | ||
17 | * Project.....: Windows Driver Development Kit | ||
18 | * Filename....: sja2m16c.cpp | ||
19 | * Authors.....: (GU) Gerhard Uttenthaler | ||
20 | * (CS) Christian Schoett | ||
21 | ***************************************************************************** | ||
22 | * Short descr.: converts baudrate between SJA1000 and M16C | ||
23 | ***************************************************************************** | ||
24 | * Description.: handles the baudrate conversion from SJA1000 parameters to | ||
25 | * M16C parameters | ||
26 | ***************************************************************************** | ||
27 | * Address : EMS Dr. Thomas Wuensche | ||
28 | * Sonnenhang 3 | ||
29 | * D-85304 Ilmmuenster | ||
30 | * Tel. : +49-8441-490260 | ||
31 | * Fax. : +49-8441-81860 | ||
32 | * email: support@ems-wuensche.com | ||
33 | ***************************************************************************** | ||
34 | * History | ||
35 | ***************************************************************************** | ||
36 | * Version Date Auth Remark | ||
37 | * | ||
38 | * 01.00 ?? GU - initial release | ||
39 | * 01.10 ?????????? CS - adapted to fit into the USB Windows driver | ||
40 | * 02.00 18.08.2004 GU - improved the baudrate calculating algorithm | ||
41 | * - implemented acceptance filtering | ||
42 | * 02.10 10.09.2004 CS - adapted to fit into the USB Windows driver | ||
43 | ***************************************************************************** | ||
44 | * ToDo's | ||
45 | ***************************************************************************** | ||
46 | */ | ||
47 | |||
48 | /****************************************************************************/ | ||
49 | /* I N C L U D E S | ||
50 | */ | ||
51 | #include <linux/kernel.h> | ||
52 | #include <linux/errno.h> | ||
53 | #include <linux/init.h> | ||
54 | #include <linux/slab.h> | ||
55 | #include <linux/vmalloc.h> | ||
56 | #include <linux/module.h> | ||
57 | #include <linux/poll.h> | ||
58 | #include <linux/smp_lock.h> | ||
59 | #include <linux/completion.h> | ||
60 | #include <asm/uaccess.h> | ||
61 | #include <linux/usb.h> | ||
62 | |||
63 | #include "cpc.h" | ||
64 | #include "cpc_int.h" | ||
65 | #include "cpcusb.h" | ||
66 | |||
67 | #include "sja2m16c.h" | ||
68 | |||
69 | /*********************************************************************/ | ||
70 | int baudrate_m16c(int clk, int brp, int pr, int ph1, int ph2) | ||
71 | { | ||
72 | return (16000000 / (1 << clk)) / 2 / (brp + 1) / (1 + pr + 1 + | ||
73 | ph1 + 1 + ph2 + | ||
74 | 1); | ||
75 | } | ||
76 | |||
77 | |||
78 | /*********************************************************************/ | ||
79 | int samplepoint_m16c(int brp, int pr, int ph1, int ph2) | ||
80 | { | ||
81 | return (100 * (1 + pr + 1 + ph1 + 1)) / (1 + pr + 1 + ph1 + 1 + | ||
82 | ph2 + 1); | ||
83 | } | ||
84 | |||
85 | |||
86 | /**************************************************************************** | ||
87 | * Function.....: SJA1000_TO_M16C_BASIC_Params | ||
88 | * | ||
89 | * Task.........: This routine converts SJA1000 CAN btr parameters into M16C | ||
90 | * parameters based on the sample point and the error. In | ||
91 | * addition it converts the acceptance filter parameters to | ||
92 | * suit the M16C parameters | ||
93 | * | ||
94 | * Parameters...: None | ||
95 | * | ||
96 | * Return values: None | ||
97 | * | ||
98 | * Comments.....: | ||
99 | ***************************************************************************** | ||
100 | * History | ||
101 | ***************************************************************************** | ||
102 | * 19.01.2005 CS - modifed the conversion of SJA1000 filter params into | ||
103 | * M16C params. Due to compatibility reasons with the | ||
104 | * older 82C200 CAN controller the SJA1000 | ||
105 | ****************************************************************************/ | ||
106 | int SJA1000_TO_M16C_BASIC_Params(CPC_MSG_T * in) | ||
107 | { | ||
108 | int sjaBaudrate; | ||
109 | int sjaSamplepoint; | ||
110 | int *baudrate_error; // BRP[0..15], PR[0..7], PH1[0..7], PH2[0..7] | ||
111 | int *samplepoint_error; // BRP[0..15], PR[0..7], PH1[0..7], PH2[0..7] | ||
112 | int baudrate_error_merk; | ||
113 | int clk, brp, pr, ph1, ph2; | ||
114 | int clk_merk, brp_merk, pr_merk, ph1_merk, ph2_merk; | ||
115 | int index; | ||
116 | unsigned char acc_code0, acc_code1, acc_code2, acc_code3; | ||
117 | unsigned char acc_mask0, acc_mask1, acc_mask2, acc_mask3; | ||
118 | CPC_MSG_T * out; | ||
119 | C0CONR_T c0con; | ||
120 | C1CONR_T c1con; | ||
121 | int tmpAccCode; | ||
122 | int tmpAccMask; | ||
123 | |||
124 | // we have to convert the parameters into M16C parameters | ||
125 | CPC_SJA1000_PARAMS_T * pParams; | ||
126 | |||
127 | // check if the type is CAN parameters and if we have to convert the given params | ||
128 | if (in->type != CPC_CMD_T_CAN_PRMS | ||
129 | || in->msg.canparams.cc_type != SJA1000) | ||
130 | return 0; | ||
131 | pParams = | ||
132 | (CPC_SJA1000_PARAMS_T *) & in->msg.canparams.cc_params.sja1000; | ||
133 | acc_code0 = pParams->acc_code0; | ||
134 | acc_code1 = pParams->acc_code1; | ||
135 | acc_code2 = pParams->acc_code2; | ||
136 | acc_code3 = pParams->acc_code3; | ||
137 | acc_mask0 = pParams->acc_mask0; | ||
138 | acc_mask1 = pParams->acc_mask1; | ||
139 | acc_mask2 = pParams->acc_mask2; | ||
140 | acc_mask3 = pParams->acc_mask3; | ||
141 | |||
142 | #ifdef _DEBUG_OUTPUT_CAN_PARAMS | ||
143 | info("acc_code0: %2.2Xh\n", acc_code0); | ||
144 | info("acc_code1: %2.2Xh\n", acc_code1); | ||
145 | info("acc_code2: %2.2Xh\n", acc_code2); | ||
146 | info("acc_code3: %2.2Xh\n", acc_code3); | ||
147 | info("acc_mask0: %2.2Xh\n", acc_mask0); | ||
148 | info("acc_mask1: %2.2Xh\n", acc_mask1); | ||
149 | info("acc_mask2: %2.2Xh\n", acc_mask2); | ||
150 | info("acc_mask3: %2.2Xh\n", acc_mask3); | ||
151 | |||
152 | #endif /* */ | ||
153 | if (! | ||
154 | (baudrate_error = | ||
155 | (int *) vmalloc(sizeof(int) * 16 * 8 * 8 * 8 * 5))) { | ||
156 | err("Could not allocate memory\n"); | ||
157 | return -3; | ||
158 | } | ||
159 | if (! | ||
160 | (samplepoint_error = | ||
161 | (int *) vmalloc(sizeof(int) * 16 * 8 * 8 * 8 * 5))) { | ||
162 | err("Could not allocate memory\n"); | ||
163 | vfree(baudrate_error); | ||
164 | return -3; | ||
165 | } | ||
166 | memset(baudrate_error, 0xff, sizeof(baudrate_error)); | ||
167 | memset(samplepoint_error, 0xff, sizeof(baudrate_error)); | ||
168 | sjaBaudrate = | ||
169 | 16000000 / 2 / SJA_BRP / (1 + SJA_TSEG1 + SJA_TSEG2); | ||
170 | sjaSamplepoint = | ||
171 | 100 * (1 + SJA_TSEG1) / (1 + SJA_TSEG1 + SJA_TSEG2); | ||
172 | if (sjaBaudrate == 0) { | ||
173 | vfree(baudrate_error); | ||
174 | vfree(samplepoint_error); | ||
175 | return -2; | ||
176 | } | ||
177 | |||
178 | #ifdef _DEBUG_OUTPUT_CAN_PARAMS | ||
179 | info("\nStarting SJA CAN params\n"); | ||
180 | info("-------------------------\n"); | ||
181 | info("TS1 : %2.2Xh TS2 : %2.2Xh\n", SJA_TSEG1, SJA_TSEG2); | ||
182 | info("BTR0 : %2.2Xh BTR1: %2.2Xh\n", pParams->btr0, | ||
183 | pParams->btr1); | ||
184 | info("Baudrate: %d.%dkBaud\n", sjaBaudrate / 1000, | ||
185 | sjaBaudrate % 1000); | ||
186 | info("Sample P: 0.%d\n", sjaSamplepoint); | ||
187 | info("\n"); | ||
188 | |||
189 | #endif /* */ | ||
190 | c0con.bc0con.sam = SJA_SAM; | ||
191 | c1con.bc1con.sjw = SJA_SJW; | ||
192 | |||
193 | // calculate errors for all baudrates | ||
194 | index = 0; | ||
195 | for (clk = 0; clk < 5; clk++) { | ||
196 | for (brp = 0; brp < 16; brp++) { | ||
197 | for (pr = 0; pr < 8; pr++) { | ||
198 | for (ph1 = 0; ph1 < 8; ph1++) { | ||
199 | for (ph2 = 0; ph2 < 8; ph2++) { | ||
200 | baudrate_error[index] = | ||
201 | 100 * | ||
202 | abs(baudrate_m16c | ||
203 | (clk, brp, pr, ph1, | ||
204 | ph2) - | ||
205 | sjaBaudrate) / | ||
206 | sjaBaudrate; | ||
207 | samplepoint_error[index] = | ||
208 | abs(samplepoint_m16c | ||
209 | (brp, pr, ph1, | ||
210 | ph2) - | ||
211 | sjaSamplepoint); | ||
212 | |||
213 | #if 0 | ||
214 | info | ||
215 | ("Baudrate : %d kBaud\n", | ||
216 | baudrate_m16c(clk, | ||
217 | brp, pr, | ||
218 | ph1, | ||
219 | ph2)); | ||
220 | info | ||
221 | ("Baudrate Error: %d\n", | ||
222 | baudrate_error | ||
223 | [index]); | ||
224 | info | ||
225 | ("Sample P Error: %d\n", | ||
226 | samplepoint_error | ||
227 | [index]); | ||
228 | info | ||
229 | ("clk : %d\n", | ||
230 | clk); | ||
231 | |||
232 | #endif /* */ | ||
233 | index++; | ||
234 | } | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | |||
240 | // mark all baudrate_error entries which are outer limits | ||
241 | index = 0; | ||
242 | for (clk = 0; clk < 5; clk++) { | ||
243 | for (brp = 0; brp < 16; brp++) { | ||
244 | for (pr = 0; pr < 8; pr++) { | ||
245 | for (ph1 = 0; ph1 < 8; ph1++) { | ||
246 | for (ph2 = 0; ph2 < 8; ph2++) { | ||
247 | if ((baudrate_error[index] | ||
248 | > | ||
249 | BAUDRATE_TOLERANCE_PERCENT) | ||
250 | || | ||
251 | (samplepoint_error | ||
252 | [index] > | ||
253 | SAMPLEPOINT_TOLERANCE_PERCENT) | ||
254 | || | ||
255 | (samplepoint_m16c | ||
256 | (brp, pr, ph1, | ||
257 | ph2) > | ||
258 | SAMPLEPOINT_UPPER_LIMIT)) | ||
259 | { | ||
260 | baudrate_error | ||
261 | [index] = -1; | ||
262 | } else | ||
263 | if (((1 + pr + 1 + | ||
264 | ph1 + 1 + ph2 + | ||
265 | 1) < 8) | ||
266 | || | ||
267 | ((1 + pr + 1 + | ||
268 | ph1 + 1 + ph2 + | ||
269 | 1) > 25)) { | ||
270 | baudrate_error | ||
271 | [index] = -1; | ||
272 | } | ||
273 | |||
274 | #if 0 | ||
275 | else { | ||
276 | info | ||
277 | ("Baudrate : %d kBaud\n", | ||
278 | baudrate_m16c | ||
279 | (clk, brp, pr, | ||
280 | ph1, ph2)); | ||
281 | info | ||
282 | ("Baudrate Error: %d\n", | ||
283 | baudrate_error | ||
284 | [index]); | ||
285 | info | ||
286 | ("Sample P Error: %d\n", | ||
287 | samplepoint_error | ||
288 | [index]); | ||
289 | } | ||
290 | |||
291 | #endif /* */ | ||
292 | index++; | ||
293 | } | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | } | ||
298 | |||
299 | // find list of minimum of baudrate_error within unmarked entries | ||
300 | clk_merk = brp_merk = pr_merk = ph1_merk = ph2_merk = 0; | ||
301 | baudrate_error_merk = 100; | ||
302 | index = 0; | ||
303 | for (clk = 0; clk < 5; clk++) { | ||
304 | for (brp = 0; brp < 16; brp++) { | ||
305 | for (pr = 0; pr < 8; pr++) { | ||
306 | for (ph1 = 0; ph1 < 8; ph1++) { | ||
307 | for (ph2 = 0; ph2 < 8; ph2++) { | ||
308 | if (baudrate_error[index] | ||
309 | != -1) { | ||
310 | if (baudrate_error | ||
311 | [index] < | ||
312 | baudrate_error_merk) | ||
313 | { | ||
314 | baudrate_error_merk | ||
315 | = | ||
316 | baudrate_error | ||
317 | [index]; | ||
318 | brp_merk = | ||
319 | brp; | ||
320 | pr_merk = | ||
321 | pr; | ||
322 | ph1_merk = | ||
323 | ph1; | ||
324 | ph2_merk = | ||
325 | ph2; | ||
326 | clk_merk = | ||
327 | clk; | ||
328 | |||
329 | #if 0 | ||
330 | info | ||
331 | ("brp: %2.2Xh pr: %2.2Xh ph1: %2.2Xh ph2: %2.2Xh\n", | ||
332 | brp, | ||
333 | pr, | ||
334 | ph1, | ||
335 | ph2); | ||
336 | info | ||
337 | ("Baudrate : %d kBaud\n", | ||
338 | baudrate_m16c | ||
339 | (clk, | ||
340 | brp, | ||
341 | pr, | ||
342 | ph1, | ||
343 | ph2)); | ||
344 | info | ||
345 | ("Baudrate Error: %d\n", | ||
346 | baudrate_error | ||
347 | [index]); | ||
348 | info | ||
349 | ("Sample P Error: %d\n", | ||
350 | samplepoint_error | ||
351 | [index]); | ||
352 | |||
353 | #endif /* */ | ||
354 | } | ||
355 | } | ||
356 | index++; | ||
357 | } | ||
358 | } | ||
359 | } | ||
360 | } | ||
361 | } | ||
362 | if (baudrate_error_merk == 100) { | ||
363 | info("ERROR: Could not convert CAN init parameter\n"); | ||
364 | vfree(baudrate_error); | ||
365 | vfree(samplepoint_error); | ||
366 | return -1; | ||
367 | } | ||
368 | |||
369 | // setting m16c CAN parameter | ||
370 | c0con.bc0con.brp = brp_merk; | ||
371 | c0con.bc0con.pr = pr_merk; | ||
372 | c1con.bc1con.ph1 = ph1_merk; | ||
373 | c1con.bc1con.ph2 = ph2_merk; | ||
374 | |||
375 | #ifdef _DEBUG_OUTPUT_CAN_PARAMS | ||
376 | info("\nResulting M16C CAN params\n"); | ||
377 | info("-------------------------\n"); | ||
378 | info("clk : %2.2Xh\n", clk_merk); | ||
379 | info("ph1 : %2.2Xh ph2: %2.2Xh\n", c1con.bc1con.ph1 + 1, | ||
380 | c1con.bc1con.ph2 + 1); | ||
381 | info("pr : %2.2Xh brp: %2.2Xh\n", c0con.bc0con.pr + 1, | ||
382 | c0con.bc0con.brp + 1); | ||
383 | info("sjw : %2.2Xh sam: %2.2Xh\n", c1con.bc1con.sjw, | ||
384 | c0con.bc0con.sam); | ||
385 | info("co1 : %2.2Xh co0: %2.2Xh\n", c1con.c1con, c0con.c0con); | ||
386 | info("Baudrate: %d.%dBaud\n", | ||
387 | baudrate_m16c(clk_merk, c0con.bc0con.brp, c0con.bc0con.pr, | ||
388 | c1con.bc1con.ph1, c1con.bc1con.ph2) / 1000, | ||
389 | baudrate_m16c(clk_merk, c0con.bc0con.brp, c0con.bc0con.pr, | ||
390 | c1con.bc1con.ph1, c1con.bc1con.ph2) % 1000); | ||
391 | info("Sample P: 0.%d\n", | ||
392 | samplepoint_m16c(c0con.bc0con.brp, c0con.bc0con.pr, | ||
393 | c1con.bc1con.ph1, c1con.bc1con.ph2)); | ||
394 | info("\n"); | ||
395 | |||
396 | #endif /* */ | ||
397 | out = in; | ||
398 | out->type = 6; | ||
399 | out->length = sizeof(CPC_M16C_BASIC_PARAMS_T) + 1; | ||
400 | out->msg.canparams.cc_type = M16C_BASIC; | ||
401 | out->msg.canparams.cc_params.m16c_basic.con0 = c0con.c0con; | ||
402 | out->msg.canparams.cc_params.m16c_basic.con1 = c1con.c1con; | ||
403 | out->msg.canparams.cc_params.m16c_basic.ctlr0 = 0x4C; | ||
404 | out->msg.canparams.cc_params.m16c_basic.ctlr1 = 0x00; | ||
405 | out->msg.canparams.cc_params.m16c_basic.clk = clk_merk; | ||
406 | out->msg.canparams.cc_params.m16c_basic.acc_std_code0 = | ||
407 | acc_code0; | ||
408 | out->msg.canparams.cc_params.m16c_basic.acc_std_code1 = acc_code1; | ||
409 | |||
410 | // info("code0: 0x%2.2X, code1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_code0, out->msg.canparams.cc_params.m16c_basic.acc_std_code1); | ||
411 | tmpAccCode = (acc_code1 >> 5) + (acc_code0 << 3); | ||
412 | out->msg.canparams.cc_params.m16c_basic.acc_std_code0 = | ||
413 | (unsigned char) tmpAccCode; | ||
414 | out->msg.canparams.cc_params.m16c_basic.acc_std_code1 = | ||
415 | (unsigned char) (tmpAccCode >> 8); | ||
416 | |||
417 | // info("code0: 0x%2.2X, code1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_code0, out->msg.canparams.cc_params.m16c_basic.acc_std_code1); | ||
418 | out->msg.canparams.cc_params.m16c_basic.acc_std_mask0 = | ||
419 | ~acc_mask0; | ||
420 | out->msg.canparams.cc_params.m16c_basic.acc_std_mask1 = | ||
421 | ~acc_mask1; | ||
422 | |||
423 | // info("mask0: 0x%2.2X, mask1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_mask0, out->msg.canparams.cc_params.m16c_basic.acc_std_mask1); | ||
424 | tmpAccMask = ((acc_mask1) >> 5) + ((acc_mask0) << 3); | ||
425 | |||
426 | // info("tmpAccMask: 0x%4.4X\n", tmpAccMask); | ||
427 | out->msg.canparams.cc_params.m16c_basic.acc_std_mask0 = | ||
428 | (unsigned char) ~tmpAccMask; | ||
429 | out->msg.canparams.cc_params.m16c_basic.acc_std_mask1 = | ||
430 | (unsigned char) ~(tmpAccMask >> 8); | ||
431 | |||
432 | // info("mask0: 0x%2.2X, mask1: 0x%2.2X\n", out->msg.canparams.cc_params.m16c_basic.acc_std_mask0, out->msg.canparams.cc_params.m16c_basic.acc_std_mask1); | ||
433 | out->msg.canparams.cc_params.m16c_basic.acc_ext_code0 = | ||
434 | (unsigned char) tmpAccCode; | ||
435 | out->msg.canparams.cc_params.m16c_basic.acc_ext_code1 = | ||
436 | (unsigned char) (tmpAccCode >> 8); | ||
437 | out->msg.canparams.cc_params.m16c_basic.acc_ext_code2 = acc_code2; | ||
438 | out->msg.canparams.cc_params.m16c_basic.acc_ext_code3 = acc_code3; | ||
439 | out->msg.canparams.cc_params.m16c_basic.acc_ext_mask0 = | ||
440 | (unsigned char) ~tmpAccMask; | ||
441 | out->msg.canparams.cc_params.m16c_basic.acc_ext_mask1 = | ||
442 | (unsigned char) ~(tmpAccMask >> 8); | ||
443 | out->msg.canparams.cc_params.m16c_basic.acc_ext_mask2 = | ||
444 | ~acc_mask2; | ||
445 | out->msg.canparams.cc_params.m16c_basic.acc_ext_mask3 = | ||
446 | ~acc_mask3; | ||
447 | vfree(baudrate_error); | ||
448 | vfree(samplepoint_error); | ||
449 | return 0; | ||
450 | } | ||
451 | |||
452 | |||
diff --git a/firmware/Makefile b/firmware/Makefile index 878329cf4825..ffe2663d49f2 100644 --- a/firmware/Makefile +++ b/firmware/Makefile | |||
@@ -51,9 +51,10 @@ fw-shipped-$(CONFIG_DVB_TTUSB_BUDGET) += ttusb-budget/dspbootcode.bin | |||
51 | fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \ | 51 | fw-shipped-$(CONFIG_E100) += e100/d101m_ucode.bin e100/d101s_ucode.bin \ |
52 | e100/d102e_ucode.bin | 52 | e100/d102e_ucode.bin |
53 | fw-shipped-$(CONFIG_MYRI_SBUS) += myricom/lanai.bin | 53 | fw-shipped-$(CONFIG_MYRI_SBUS) += myricom/lanai.bin |
54 | fw-shipped-$(CONFIG_PCMCIA_PCNET) += cis/LA-PCM.cis | 54 | fw-shipped-$(CONFIG_PCMCIA_PCNET) += cis/LA-PCM.cis cis/PCMLM28.cis |
55 | fw-shipped-$(CONFIG_PCMCIA_3C589) += cis/3CXEM556.cis | 55 | fw-shipped-$(CONFIG_PCMCIA_3C589) += cis/3CXEM556.cis |
56 | fw-shipped-$(CONFIG_PCMCIA_3C574) += cis/3CCFEM556.cis | 56 | fw-shipped-$(CONFIG_PCMCIA_3C574) += cis/3CCFEM556.cis |
57 | fw-shipped-$(CONFIG_SERIAL_8250_CS) += cis/MT5634ZLX.cis cis/RS-COM-2P.cis | ||
57 | fw-shipped-$(CONFIG_PCMCIA_SMC91C92) += ositech/Xilinx7OD.bin | 58 | fw-shipped-$(CONFIG_PCMCIA_SMC91C92) += ositech/Xilinx7OD.bin |
58 | fw-shipped-$(CONFIG_SCSI_ADVANSYS) += advansys/mcode.bin advansys/38C1600.bin \ | 59 | fw-shipped-$(CONFIG_SCSI_ADVANSYS) += advansys/mcode.bin advansys/38C1600.bin \ |
59 | advansys/3550.bin advansys/38C0800.bin | 60 | advansys/3550.bin advansys/38C0800.bin |
diff --git a/firmware/WHENCE b/firmware/WHENCE index d9e3a94cb4df..82db5256a4e5 100644 --- a/firmware/WHENCE +++ b/firmware/WHENCE | |||
@@ -596,6 +596,7 @@ Found in hex form in kernel source. | |||
596 | Driver: PCMCIA_PCNET - NE2000 compatible PCMCIA adapter | 596 | Driver: PCMCIA_PCNET - NE2000 compatible PCMCIA adapter |
597 | 597 | ||
598 | File: cis/LA-PCM.cis | 598 | File: cis/LA-PCM.cis |
599 | cis/PCMLM28.cis | ||
599 | 600 | ||
600 | Licence: GPL | 601 | Licence: GPL |
601 | 602 | ||
@@ -623,6 +624,17 @@ Originally developed by the pcmcia-cs project | |||
623 | 624 | ||
624 | -------------------------------------------------------------------------- | 625 | -------------------------------------------------------------------------- |
625 | 626 | ||
627 | Driver: SERIAL_8250_CS - Serial PCMCIA adapter | ||
628 | |||
629 | File: cis/MT5634ZLX.cis | ||
630 | cis/RS-COM-2P.cis | ||
631 | |||
632 | Licence: GPL | ||
633 | |||
634 | Originally developed by the pcmcia-cs project | ||
635 | |||
636 | -------------------------------------------------------------------------- | ||
637 | |||
626 | Driver: PCMCIA_SMC91C92 - SMC 91Cxx PCMCIA | 638 | Driver: PCMCIA_SMC91C92 - SMC 91Cxx PCMCIA |
627 | 639 | ||
628 | File: ositech/Xilinx7OD.bin | 640 | File: ositech/Xilinx7OD.bin |
diff --git a/firmware/cis/MT5634ZLX.cis.ihex b/firmware/cis/MT5634ZLX.cis.ihex new file mode 100644 index 000000000000..72500b9d95d8 --- /dev/null +++ b/firmware/cis/MT5634ZLX.cis.ihex | |||
@@ -0,0 +1,11 @@ | |||
1 | :100000000101FF152204014D756C74695465636824 | ||
2 | :100010000050434D4349412035364B2044617461C3 | ||
3 | :10002000466178000000FF20040002010021020266 | ||
4 | :10003000001A05012780FF671B0FCF418B01550177 | ||
5 | :10004000550155AA60F80307281B08970108AA6004 | ||
6 | :10005000F802071B089F0108AA60E803071B08A70E | ||
7 | :0B0060000108AA60E802071400FF007E | ||
8 | :00000001FF | ||
9 | # | ||
10 | # Replacement CIS for Multitech MT5634ZLX modems | ||
11 | # | ||
diff --git a/firmware/cis/PCMLM28.cis.ihex b/firmware/cis/PCMLM28.cis.ihex new file mode 100644 index 000000000000..ffdfe8522ef5 --- /dev/null +++ b/firmware/cis/PCMLM28.cis.ihex | |||
@@ -0,0 +1,18 @@ | |||
1 | :1000000001030000FF151504014C494E4B53595391 | ||
2 | :100010000050434D4C4D3238000000FF2004430196 | ||
3 | :10002000ABC0210200001A05012FF803031B10E4E6 | ||
4 | :1000300001190155E06100031FF8020730FFFF1BA3 | ||
5 | :100040000BA50108E06120031FF802071B0BA601A6 | ||
6 | :1000500008E06140031FF802071B0BA70108E061DD | ||
7 | :1000600060031FF802071B0BA80108E06100031FD3 | ||
8 | :10007000E803071B0BA90108E06120031FE8030741 | ||
9 | :100080001B0BAA0108E06140031FE803071B0BAB31 | ||
10 | :100090000108E06160031FE803071B0BAC0108E0E7 | ||
11 | :1000A0006100031FE802071B0BAD0108E06120039C | ||
12 | :1000B0001FE802071B0BAE0108E06140031FE802C6 | ||
13 | :1000C000071B0BAF0108E06160031FE80207140083 | ||
14 | :0200D000FF002F | ||
15 | :00000001FF | ||
16 | # | ||
17 | # The on-card CIS says it is MFC-compliant, but it is not | ||
18 | # | ||
diff --git a/firmware/cis/RS-COM-2P.cis.ihex b/firmware/cis/RS-COM-2P.cis.ihex new file mode 100644 index 000000000000..0801ca5da80a --- /dev/null +++ b/firmware/cis/RS-COM-2P.cis.ihex | |||
@@ -0,0 +1,10 @@ | |||
1 | :1000000001030000FF1516040150434D4349410010 | ||
2 | :1000100052532D434F4D203250000000FF21020269 | ||
3 | :10002000011A0501030001011B0EC18118AA61E834 | ||
4 | :100030000307E8020730B89E1B0B820108AA615033 | ||
5 | :1000400002075802071B0B830108AA6160020768B8 | ||
6 | :0600500002071400FF008E | ||
7 | :00000001FF | ||
8 | # | ||
9 | # Replacement CIS for dual-serial-port IO card | ||
10 | # | ||
diff --git a/include/keys/rxrpc-type.h b/include/keys/rxrpc-type.h index 7609365577f1..5cb86c307f5d 100644 --- a/include/keys/rxrpc-type.h +++ b/include/keys/rxrpc-type.h | |||
@@ -21,4 +21,111 @@ extern struct key_type key_type_rxrpc; | |||
21 | 21 | ||
22 | extern struct key *rxrpc_get_null_key(const char *); | 22 | extern struct key *rxrpc_get_null_key(const char *); |
23 | 23 | ||
24 | /* | ||
25 | * RxRPC key for Kerberos IV (type-2 security) | ||
26 | */ | ||
27 | struct rxkad_key { | ||
28 | u32 vice_id; | ||
29 | u32 start; /* time at which ticket starts */ | ||
30 | u32 expiry; /* time at which ticket expires */ | ||
31 | u32 kvno; /* key version number */ | ||
32 | u8 primary_flag; /* T if key for primary cell for this user */ | ||
33 | u16 ticket_len; /* length of ticket[] */ | ||
34 | u8 session_key[8]; /* DES session key */ | ||
35 | u8 ticket[0]; /* the encrypted ticket */ | ||
36 | }; | ||
37 | |||
38 | /* | ||
39 | * Kerberos 5 principal | ||
40 | * name/name/name@realm | ||
41 | */ | ||
42 | struct krb5_principal { | ||
43 | u8 n_name_parts; /* N of parts of the name part of the principal */ | ||
44 | char **name_parts; /* parts of the name part of the principal */ | ||
45 | char *realm; /* parts of the realm part of the principal */ | ||
46 | }; | ||
47 | |||
48 | /* | ||
49 | * Kerberos 5 tagged data | ||
50 | */ | ||
51 | struct krb5_tagged_data { | ||
52 | /* for tag value, see /usr/include/krb5/krb5.h | ||
53 | * - KRB5_AUTHDATA_* for auth data | ||
54 | * - | ||
55 | */ | ||
56 | s32 tag; | ||
57 | u32 data_len; | ||
58 | u8 *data; | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * RxRPC key for Kerberos V (type-5 security) | ||
63 | */ | ||
64 | struct rxk5_key { | ||
65 | u64 authtime; /* time at which auth token generated */ | ||
66 | u64 starttime; /* time at which auth token starts */ | ||
67 | u64 endtime; /* time at which auth token expired */ | ||
68 | u64 renew_till; /* time to which auth token can be renewed */ | ||
69 | s32 is_skey; /* T if ticket is encrypted in another ticket's | ||
70 | * skey */ | ||
71 | s32 flags; /* mask of TKT_FLG_* bits (krb5/krb5.h) */ | ||
72 | struct krb5_principal client; /* client principal name */ | ||
73 | struct krb5_principal server; /* server principal name */ | ||
74 | u16 ticket_len; /* length of ticket */ | ||
75 | u16 ticket2_len; /* length of second ticket */ | ||
76 | u8 n_authdata; /* number of authorisation data elements */ | ||
77 | u8 n_addresses; /* number of addresses */ | ||
78 | struct krb5_tagged_data session; /* session data; tag is enctype */ | ||
79 | struct krb5_tagged_data *addresses; /* addresses */ | ||
80 | u8 *ticket; /* krb5 ticket */ | ||
81 | u8 *ticket2; /* second krb5 ticket, if related to ticket (via | ||
82 | * DUPLICATE-SKEY or ENC-TKT-IN-SKEY) */ | ||
83 | struct krb5_tagged_data *authdata; /* authorisation data */ | ||
84 | }; | ||
85 | |||
86 | /* | ||
87 | * list of tokens attached to an rxrpc key | ||
88 | */ | ||
89 | struct rxrpc_key_token { | ||
90 | u16 security_index; /* RxRPC header security index */ | ||
91 | struct rxrpc_key_token *next; /* the next token in the list */ | ||
92 | union { | ||
93 | struct rxkad_key *kad; | ||
94 | struct rxk5_key *k5; | ||
95 | }; | ||
96 | }; | ||
97 | |||
98 | /* | ||
99 | * structure of raw payloads passed to add_key() or instantiate key | ||
100 | */ | ||
101 | struct rxrpc_key_data_v1 { | ||
102 | u32 kif_version; /* 1 */ | ||
103 | u16 security_index; | ||
104 | u16 ticket_length; | ||
105 | u32 expiry; /* time_t */ | ||
106 | u32 kvno; | ||
107 | u8 session_key[8]; | ||
108 | u8 ticket[0]; | ||
109 | }; | ||
110 | |||
111 | /* | ||
112 | * AF_RXRPC key payload derived from XDR format | ||
113 | * - based on openafs-1.4.10/src/auth/afs_token.xg | ||
114 | */ | ||
115 | #define AFSTOKEN_LENGTH_MAX 16384 /* max payload size */ | ||
116 | #define AFSTOKEN_STRING_MAX 256 /* max small string length */ | ||
117 | #define AFSTOKEN_DATA_MAX 64 /* max small data length */ | ||
118 | #define AFSTOKEN_CELL_MAX 64 /* max cellname length */ | ||
119 | #define AFSTOKEN_MAX 8 /* max tokens per payload */ | ||
120 | #define AFSTOKEN_BDATALN_MAX 16384 /* max big data length */ | ||
121 | #define AFSTOKEN_RK_TIX_MAX 12000 /* max RxKAD ticket size */ | ||
122 | #define AFSTOKEN_GK_KEY_MAX 64 /* max GSSAPI key size */ | ||
123 | #define AFSTOKEN_GK_TOKEN_MAX 16384 /* max GSSAPI token size */ | ||
124 | #define AFSTOKEN_K5_COMPONENTS_MAX 16 /* max K5 components */ | ||
125 | #define AFSTOKEN_K5_NAME_MAX 128 /* max K5 name length */ | ||
126 | #define AFSTOKEN_K5_REALM_MAX 64 /* max K5 realm name length */ | ||
127 | #define AFSTOKEN_K5_TIX_MAX 16384 /* max K5 ticket size */ | ||
128 | #define AFSTOKEN_K5_ADDRESSES_MAX 16 /* max K5 addresses */ | ||
129 | #define AFSTOKEN_K5_AUTHDATA_MAX 16 /* max K5 pieces of auth data */ | ||
130 | |||
24 | #endif /* _KEYS_RXRPC_TYPE_H */ | 131 | #endif /* _KEYS_RXRPC_TYPE_H */ |
diff --git a/include/linux/igmp.h b/include/linux/igmp.h index 92fbd8cbd68f..fe158e0e20e6 100644 --- a/include/linux/igmp.h +++ b/include/linux/igmp.h | |||
@@ -233,6 +233,8 @@ extern void ip_mc_init_dev(struct in_device *); | |||
233 | extern void ip_mc_destroy_dev(struct in_device *); | 233 | extern void ip_mc_destroy_dev(struct in_device *); |
234 | extern void ip_mc_up(struct in_device *); | 234 | extern void ip_mc_up(struct in_device *); |
235 | extern void ip_mc_down(struct in_device *); | 235 | extern void ip_mc_down(struct in_device *); |
236 | extern void ip_mc_unmap(struct in_device *); | ||
237 | extern void ip_mc_remap(struct in_device *); | ||
236 | extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr); | 238 | extern void ip_mc_dec_group(struct in_device *in_dev, __be32 addr); |
237 | extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr); | 239 | extern void ip_mc_inc_group(struct in_device *in_dev, __be32 addr); |
238 | extern void ip_mc_rejoin_group(struct ip_mc_list *im); | 240 | extern void ip_mc_rejoin_group(struct ip_mc_list *im); |
diff --git a/include/linux/net.h b/include/linux/net.h index 4fc2ffd527f9..9040a10584f7 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -57,6 +57,7 @@ typedef enum { | |||
57 | #include <linux/random.h> | 57 | #include <linux/random.h> |
58 | #include <linux/wait.h> | 58 | #include <linux/wait.h> |
59 | #include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */ | 59 | #include <linux/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK */ |
60 | #include <linux/kmemcheck.h> | ||
60 | 61 | ||
61 | struct poll_table_struct; | 62 | struct poll_table_struct; |
62 | struct pipe_inode_info; | 63 | struct pipe_inode_info; |
@@ -127,7 +128,11 @@ enum sock_shutdown_cmd { | |||
127 | */ | 128 | */ |
128 | struct socket { | 129 | struct socket { |
129 | socket_state state; | 130 | socket_state state; |
131 | |||
132 | kmemcheck_bitfield_begin(type); | ||
130 | short type; | 133 | short type; |
134 | kmemcheck_bitfield_end(type); | ||
135 | |||
131 | unsigned long flags; | 136 | unsigned long flags; |
132 | /* | 137 | /* |
133 | * Please keep fasync_list & wait fields in the same cache line | 138 | * Please keep fasync_list & wait fields in the same cache line |
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 65ee1929b2b1..f46db6c7a734 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -1873,7 +1873,8 @@ extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct | |||
1873 | extern int dev_set_promiscuity(struct net_device *dev, int inc); | 1873 | extern int dev_set_promiscuity(struct net_device *dev, int inc); |
1874 | extern int dev_set_allmulti(struct net_device *dev, int inc); | 1874 | extern int dev_set_allmulti(struct net_device *dev, int inc); |
1875 | extern void netdev_state_change(struct net_device *dev); | 1875 | extern void netdev_state_change(struct net_device *dev); |
1876 | extern void netdev_bonding_change(struct net_device *dev); | 1876 | extern void netdev_bonding_change(struct net_device *dev, |
1877 | unsigned long event); | ||
1877 | extern void netdev_features_change(struct net_device *dev); | 1878 | extern void netdev_features_change(struct net_device *dev); |
1878 | /* Load a device via the kmod */ | 1879 | /* Load a device via the kmod */ |
1879 | extern void dev_load(struct net *net, const char *name); | 1880 | extern void dev_load(struct net *net, const char *name); |
diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 0fbecbbe8e9e..080f6ba9e73a 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h | |||
@@ -176,12 +176,16 @@ struct netlink_skb_parms | |||
176 | #define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds) | 176 | #define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds) |
177 | 177 | ||
178 | 178 | ||
179 | extern void netlink_table_grab(void); | ||
180 | extern void netlink_table_ungrab(void); | ||
181 | |||
179 | extern struct sock *netlink_kernel_create(struct net *net, | 182 | extern struct sock *netlink_kernel_create(struct net *net, |
180 | int unit,unsigned int groups, | 183 | int unit,unsigned int groups, |
181 | void (*input)(struct sk_buff *skb), | 184 | void (*input)(struct sk_buff *skb), |
182 | struct mutex *cb_mutex, | 185 | struct mutex *cb_mutex, |
183 | struct module *module); | 186 | struct module *module); |
184 | extern void netlink_kernel_release(struct sock *sk); | 187 | extern void netlink_kernel_release(struct sock *sk); |
188 | extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups); | ||
185 | extern int netlink_change_ngroups(struct sock *sk, unsigned int groups); | 189 | extern int netlink_change_ngroups(struct sock *sk, unsigned int groups); |
186 | extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group); | 190 | extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group); |
187 | extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err); | 191 | extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err); |
diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 81bc252dc8ac..44428d247dbe 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h | |||
@@ -199,6 +199,8 @@ static inline int notifier_to_errno(int ret) | |||
199 | #define NETDEV_FEAT_CHANGE 0x000B | 199 | #define NETDEV_FEAT_CHANGE 0x000B |
200 | #define NETDEV_BONDING_FAILOVER 0x000C | 200 | #define NETDEV_BONDING_FAILOVER 0x000C |
201 | #define NETDEV_PRE_UP 0x000D | 201 | #define NETDEV_PRE_UP 0x000D |
202 | #define NETDEV_BONDING_OLDTYPE 0x000E | ||
203 | #define NETDEV_BONDING_NEWTYPE 0x000F | ||
202 | 204 | ||
203 | #define SYS_DOWN 0x0001 /* Notify of system down */ | 205 | #define SYS_DOWN 0x0001 /* Notify of system down */ |
204 | #define SYS_RESTART SYS_DOWN | 206 | #define SYS_RESTART SYS_DOWN |
diff --git a/include/linux/rxrpc.h b/include/linux/rxrpc.h index f7b826b565c7..a53915cd5581 100644 --- a/include/linux/rxrpc.h +++ b/include/linux/rxrpc.h | |||
@@ -58,5 +58,12 @@ struct sockaddr_rxrpc { | |||
58 | #define RXRPC_SECURITY_AUTH 1 /* authenticated packets */ | 58 | #define RXRPC_SECURITY_AUTH 1 /* authenticated packets */ |
59 | #define RXRPC_SECURITY_ENCRYPT 2 /* encrypted packets */ | 59 | #define RXRPC_SECURITY_ENCRYPT 2 /* encrypted packets */ |
60 | 60 | ||
61 | /* | ||
62 | * RxRPC security indices | ||
63 | */ | ||
64 | #define RXRPC_SECURITY_NONE 0 /* no security protocol */ | ||
65 | #define RXRPC_SECURITY_RXKAD 2 /* kaserver or kerberos 4 */ | ||
66 | #define RXRPC_SECURITY_RXGK 4 /* gssapi-based */ | ||
67 | #define RXRPC_SECURITY_RXK5 5 /* kerberos 5 */ | ||
61 | 68 | ||
62 | #endif /* _LINUX_RXRPC_H */ | 69 | #endif /* _LINUX_RXRPC_H */ |
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h index bb69e256cd16..f81473052059 100644 --- a/include/linux/usb/usbnet.h +++ b/include/linux/usb/usbnet.h | |||
@@ -89,6 +89,7 @@ struct driver_info { | |||
89 | #define FLAG_FRAMING_AX 0x0040 /* AX88772/178 packets */ | 89 | #define FLAG_FRAMING_AX 0x0040 /* AX88772/178 packets */ |
90 | #define FLAG_WLAN 0x0080 /* use "wlan%d" names */ | 90 | #define FLAG_WLAN 0x0080 /* use "wlan%d" names */ |
91 | #define FLAG_AVOID_UNLINK_URBS 0x0100 /* don't unlink urbs at usbnet_stop() */ | 91 | #define FLAG_AVOID_UNLINK_URBS 0x0100 /* don't unlink urbs at usbnet_stop() */ |
92 | #define FLAG_SEND_ZLP 0x0200 /* hw requires ZLPs are sent */ | ||
92 | 93 | ||
93 | 94 | ||
94 | /* init device ... can sleep, or cause probe() failure */ | 95 | /* init device ... can sleep, or cause probe() failure */ |
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 7b55ab215a64..0f7c37825fc1 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -143,6 +143,8 @@ extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr | |||
143 | extern int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr); | 143 | extern int ipv6_dev_mc_dec(struct net_device *dev, const struct in6_addr *addr); |
144 | extern void ipv6_mc_up(struct inet6_dev *idev); | 144 | extern void ipv6_mc_up(struct inet6_dev *idev); |
145 | extern void ipv6_mc_down(struct inet6_dev *idev); | 145 | extern void ipv6_mc_down(struct inet6_dev *idev); |
146 | extern void ipv6_mc_unmap(struct inet6_dev *idev); | ||
147 | extern void ipv6_mc_remap(struct inet6_dev *idev); | ||
146 | extern void ipv6_mc_init_dev(struct inet6_dev *idev); | 148 | extern void ipv6_mc_init_dev(struct inet6_dev *idev); |
147 | extern void ipv6_mc_destroy_dev(struct inet6_dev *idev); | 149 | extern void ipv6_mc_destroy_dev(struct inet6_dev *idev); |
148 | extern void addrconf_dad_failure(struct inet6_ifaddr *ifp); | 150 | extern void addrconf_dad_failure(struct inet6_ifaddr *ifp); |
diff --git a/include/net/protocol.h b/include/net/protocol.h index 1089d5aabd49..60249e51b669 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h | |||
@@ -94,21 +94,20 @@ struct inet_protosw { | |||
94 | #define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ | 94 | #define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ |
95 | #define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ | 95 | #define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ |
96 | 96 | ||
97 | extern struct net_protocol *inet_protocol_base; | 97 | extern const struct net_protocol *inet_protos[MAX_INET_PROTOS]; |
98 | extern struct net_protocol *inet_protos[MAX_INET_PROTOS]; | ||
99 | 98 | ||
100 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 99 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
101 | extern struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; | 100 | extern const struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; |
102 | #endif | 101 | #endif |
103 | 102 | ||
104 | extern int inet_add_protocol(struct net_protocol *prot, unsigned char num); | 103 | extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num); |
105 | extern int inet_del_protocol(struct net_protocol *prot, unsigned char num); | 104 | extern int inet_del_protocol(const struct net_protocol *prot, unsigned char num); |
106 | extern void inet_register_protosw(struct inet_protosw *p); | 105 | extern void inet_register_protosw(struct inet_protosw *p); |
107 | extern void inet_unregister_protosw(struct inet_protosw *p); | 106 | extern void inet_unregister_protosw(struct inet_protosw *p); |
108 | 107 | ||
109 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 108 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
110 | extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num); | 109 | extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num); |
111 | extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num); | 110 | extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num); |
112 | extern int inet6_register_protosw(struct inet_protosw *p); | 111 | extern int inet6_register_protosw(struct inet_protosw *p); |
113 | extern void inet6_unregister_protosw(struct inet_protosw *p); | 112 | extern void inet6_unregister_protosw(struct inet_protosw *p); |
114 | #endif | 113 | #endif |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 88eb9de095de..c33180dd42b4 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -81,7 +81,7 @@ struct Qdisc | |||
81 | struct Qdisc_class_ops | 81 | struct Qdisc_class_ops |
82 | { | 82 | { |
83 | /* Child qdisc manipulation */ | 83 | /* Child qdisc manipulation */ |
84 | unsigned int (*select_queue)(struct Qdisc *, struct tcmsg *); | 84 | struct netdev_queue * (*select_queue)(struct Qdisc *, struct tcmsg *); |
85 | int (*graft)(struct Qdisc *, unsigned long cl, | 85 | int (*graft)(struct Qdisc *, unsigned long cl, |
86 | struct Qdisc *, struct Qdisc **); | 86 | struct Qdisc *, struct Qdisc **); |
87 | struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); | 87 | struct Qdisc * (*leaf)(struct Qdisc *, unsigned long cl); |
diff --git a/include/net/tcp.h b/include/net/tcp.h index b71a446d58f6..56b76027b85e 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -793,6 +793,13 @@ static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp) | |||
793 | return tp->packets_out - tcp_left_out(tp) + tp->retrans_out; | 793 | return tp->packets_out - tcp_left_out(tp) + tp->retrans_out; |
794 | } | 794 | } |
795 | 795 | ||
796 | #define TCP_INFINITE_SSTHRESH 0x7fffffff | ||
797 | |||
798 | static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp) | ||
799 | { | ||
800 | return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH; | ||
801 | } | ||
802 | |||
796 | /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. | 803 | /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. |
797 | * The exception is rate halving phase, when cwnd is decreasing towards | 804 | * The exception is rate halving phase, when cwnd is decreasing towards |
798 | * ssthresh. | 805 | * ssthresh. |
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c index 68320f6b07b5..44e5936118d2 100644 --- a/kernel/sys_ni.c +++ b/kernel/sys_ni.c | |||
@@ -49,6 +49,7 @@ cond_syscall(sys_sendmsg); | |||
49 | cond_syscall(compat_sys_sendmsg); | 49 | cond_syscall(compat_sys_sendmsg); |
50 | cond_syscall(sys_recvmsg); | 50 | cond_syscall(sys_recvmsg); |
51 | cond_syscall(compat_sys_recvmsg); | 51 | cond_syscall(compat_sys_recvmsg); |
52 | cond_syscall(compat_sys_recvfrom); | ||
52 | cond_syscall(sys_socketcall); | 53 | cond_syscall(sys_socketcall); |
53 | cond_syscall(sys_futex); | 54 | cond_syscall(sys_futex); |
54 | cond_syscall(compat_sys_futex); | 55 | cond_syscall(compat_sys_futex); |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index cb8a112030bb..a1941f8d205f 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -671,7 +671,7 @@ static char *ip4_string(char *p, const u8 *addr, bool leading_zeros) | |||
671 | return p; | 671 | return p; |
672 | } | 672 | } |
673 | 673 | ||
674 | static char *ip6_compressed_string(char *p, const struct in6_addr *addr) | 674 | static char *ip6_compressed_string(char *p, const char *addr) |
675 | { | 675 | { |
676 | int i; | 676 | int i; |
677 | int j; | 677 | int j; |
@@ -683,7 +683,12 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr) | |||
683 | u8 hi; | 683 | u8 hi; |
684 | u8 lo; | 684 | u8 lo; |
685 | bool needcolon = false; | 685 | bool needcolon = false; |
686 | bool useIPv4 = ipv6_addr_v4mapped(addr) || ipv6_addr_is_isatap(addr); | 686 | bool useIPv4; |
687 | struct in6_addr in6; | ||
688 | |||
689 | memcpy(&in6, addr, sizeof(struct in6_addr)); | ||
690 | |||
691 | useIPv4 = ipv6_addr_v4mapped(&in6) || ipv6_addr_is_isatap(&in6); | ||
687 | 692 | ||
688 | memset(zerolength, 0, sizeof(zerolength)); | 693 | memset(zerolength, 0, sizeof(zerolength)); |
689 | 694 | ||
@@ -695,7 +700,7 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr) | |||
695 | /* find position of longest 0 run */ | 700 | /* find position of longest 0 run */ |
696 | for (i = 0; i < range; i++) { | 701 | for (i = 0; i < range; i++) { |
697 | for (j = i; j < range; j++) { | 702 | for (j = i; j < range; j++) { |
698 | if (addr->s6_addr16[j] != 0) | 703 | if (in6.s6_addr16[j] != 0) |
699 | break; | 704 | break; |
700 | zerolength[i]++; | 705 | zerolength[i]++; |
701 | } | 706 | } |
@@ -722,7 +727,7 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr) | |||
722 | needcolon = false; | 727 | needcolon = false; |
723 | } | 728 | } |
724 | /* hex u16 without leading 0s */ | 729 | /* hex u16 without leading 0s */ |
725 | word = ntohs(addr->s6_addr16[i]); | 730 | word = ntohs(in6.s6_addr16[i]); |
726 | hi = word >> 8; | 731 | hi = word >> 8; |
727 | lo = word & 0xff; | 732 | lo = word & 0xff; |
728 | if (hi) { | 733 | if (hi) { |
@@ -741,19 +746,19 @@ static char *ip6_compressed_string(char *p, const struct in6_addr *addr) | |||
741 | if (useIPv4) { | 746 | if (useIPv4) { |
742 | if (needcolon) | 747 | if (needcolon) |
743 | *p++ = ':'; | 748 | *p++ = ':'; |
744 | p = ip4_string(p, &addr->s6_addr[12], false); | 749 | p = ip4_string(p, &in6.s6_addr[12], false); |
745 | } | 750 | } |
746 | 751 | ||
747 | *p = '\0'; | 752 | *p = '\0'; |
748 | return p; | 753 | return p; |
749 | } | 754 | } |
750 | 755 | ||
751 | static char *ip6_string(char *p, const struct in6_addr *addr, const char *fmt) | 756 | static char *ip6_string(char *p, const char *addr, const char *fmt) |
752 | { | 757 | { |
753 | int i; | 758 | int i; |
754 | for (i = 0; i < 8; i++) { | 759 | for (i = 0; i < 8; i++) { |
755 | p = pack_hex_byte(p, addr->s6_addr[2 * i]); | 760 | p = pack_hex_byte(p, *addr++); |
756 | p = pack_hex_byte(p, addr->s6_addr[2 * i + 1]); | 761 | p = pack_hex_byte(p, *addr++); |
757 | if (fmt[0] == 'I' && i != 7) | 762 | if (fmt[0] == 'I' && i != 7) |
758 | *p++ = ':'; | 763 | *p++ = ':'; |
759 | } | 764 | } |
@@ -768,9 +773,9 @@ static char *ip6_addr_string(char *buf, char *end, const u8 *addr, | |||
768 | char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")]; | 773 | char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")]; |
769 | 774 | ||
770 | if (fmt[0] == 'I' && fmt[2] == 'c') | 775 | if (fmt[0] == 'I' && fmt[2] == 'c') |
771 | ip6_compressed_string(ip6_addr, (const struct in6_addr *)addr); | 776 | ip6_compressed_string(ip6_addr, addr); |
772 | else | 777 | else |
773 | ip6_string(ip6_addr, (const struct in6_addr *)addr, fmt); | 778 | ip6_string(ip6_addr, addr, fmt); |
774 | 779 | ||
775 | return string(buf, end, ip6_addr, spec); | 780 | return string(buf, end, ip6_addr, spec); |
776 | } | 781 | } |
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 4a6ff2ba4d07..b1a4290996b5 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -1372,7 +1372,7 @@ static int atalk_route_packet(struct sk_buff *skb, struct net_device *dev, | |||
1372 | 1372 | ||
1373 | if (aarp_send_ddp(rt->dev, skb, &ta, NULL) == NET_XMIT_DROP) | 1373 | if (aarp_send_ddp(rt->dev, skb, &ta, NULL) == NET_XMIT_DROP) |
1374 | return NET_RX_DROP; | 1374 | return NET_RX_DROP; |
1375 | return NET_XMIT_SUCCESS; | 1375 | return NET_RX_SUCCESS; |
1376 | free_it: | 1376 | free_it: |
1377 | kfree_skb(skb); | 1377 | kfree_skb(skb); |
1378 | drop: | 1378 | drop: |
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index da0f64f82b57..d6b1b054e294 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -1781,8 +1781,8 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1781 | ax25_info.idletimer = ax25_display_timer(&ax25->idletimer) / (60 * HZ); | 1781 | ax25_info.idletimer = ax25_display_timer(&ax25->idletimer) / (60 * HZ); |
1782 | ax25_info.n2count = ax25->n2count; | 1782 | ax25_info.n2count = ax25->n2count; |
1783 | ax25_info.state = ax25->state; | 1783 | ax25_info.state = ax25->state; |
1784 | ax25_info.rcv_q = sk_wmem_alloc_get(sk); | 1784 | ax25_info.rcv_q = sk_rmem_alloc_get(sk); |
1785 | ax25_info.snd_q = sk_rmem_alloc_get(sk); | 1785 | ax25_info.snd_q = sk_wmem_alloc_get(sk); |
1786 | ax25_info.vs = ax25->vs; | 1786 | ax25_info.vs = ax25->vs; |
1787 | ax25_info.vr = ax25->vr; | 1787 | ax25_info.vr = ax25->vr; |
1788 | ax25_info.va = ax25->va; | 1788 | ax25_info.va = ax25->va; |
diff --git a/net/can/af_can.c b/net/can/af_can.c index ef1c43a2ed56..606832115674 100644 --- a/net/can/af_can.c +++ b/net/can/af_can.c | |||
@@ -199,6 +199,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol) | |||
199 | * @skb: pointer to socket buffer with CAN frame in data section | 199 | * @skb: pointer to socket buffer with CAN frame in data section |
200 | * @loop: loopback for listeners on local CAN sockets (recommended default!) | 200 | * @loop: loopback for listeners on local CAN sockets (recommended default!) |
201 | * | 201 | * |
202 | * Due to the loopback this routine must not be called from hardirq context. | ||
203 | * | ||
202 | * Return: | 204 | * Return: |
203 | * 0 on success | 205 | * 0 on success |
204 | * -ENETDOWN when the selected interface is down | 206 | * -ENETDOWN when the selected interface is down |
@@ -278,7 +280,7 @@ int can_send(struct sk_buff *skb, int loop) | |||
278 | } | 280 | } |
279 | 281 | ||
280 | if (newskb) | 282 | if (newskb) |
281 | netif_rx(newskb); | 283 | netif_rx_ni(newskb); |
282 | 284 | ||
283 | /* update statistics */ | 285 | /* update statistics */ |
284 | can_stats.tx_frames++; | 286 | can_stats.tx_frames++; |
diff --git a/net/core/dev.c b/net/core/dev.c index 84945470ab38..560c8c9c03ab 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1017,9 +1017,9 @@ void netdev_state_change(struct net_device *dev) | |||
1017 | } | 1017 | } |
1018 | EXPORT_SYMBOL(netdev_state_change); | 1018 | EXPORT_SYMBOL(netdev_state_change); |
1019 | 1019 | ||
1020 | void netdev_bonding_change(struct net_device *dev) | 1020 | void netdev_bonding_change(struct net_device *dev, unsigned long event) |
1021 | { | 1021 | { |
1022 | call_netdevice_notifiers(NETDEV_BONDING_FAILOVER, dev); | 1022 | call_netdevice_notifiers(event, dev); |
1023 | } | 1023 | } |
1024 | EXPORT_SYMBOL(netdev_bonding_change); | 1024 | EXPORT_SYMBOL(netdev_bonding_change); |
1025 | 1025 | ||
diff --git a/net/dccp/ccids/Kconfig b/net/dccp/ccids/Kconfig index 4b5db44970aa..8408398cd44e 100644 --- a/net/dccp/ccids/Kconfig +++ b/net/dccp/ccids/Kconfig | |||
@@ -66,9 +66,9 @@ config IP_DCCP_CCID3_RTO | |||
66 | A value of 0 disables this feature by enforcing the value specified | 66 | A value of 0 disables this feature by enforcing the value specified |
67 | in RFC 3448. The following values have been suggested as bounds for | 67 | in RFC 3448. The following values have been suggested as bounds for |
68 | experimental use: | 68 | experimental use: |
69 | * 16-20ms to match the typical multimedia inter-frame interval | 69 | * 16-20ms to match the typical multimedia inter-frame interval |
70 | * 100ms as a reasonable compromise [default] | 70 | * 100ms as a reasonable compromise [default] |
71 | * 1000ms corresponds to the lower TCP RTO bound (RFC 2988, 2.4) | 71 | * 1000ms corresponds to the lower TCP RTO bound (RFC 2988, 2.4) |
72 | 72 | ||
73 | The default of 100ms is a compromise between a large value for | 73 | The default of 100ms is a compromise between a large value for |
74 | efficient DCCP implementations, and a small value to avoid disrupting | 74 | efficient DCCP implementations, and a small value to avoid disrupting |
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c index d235294ace23..e8cf99e880b0 100644 --- a/net/dccp/ccids/ccid2.c +++ b/net/dccp/ccids/ccid2.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * net/dccp/ccids/ccid2.c | ||
3 | * | ||
4 | * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk> | 2 | * Copyright (c) 2005, 2006 Andrea Bittau <a.bittau@cs.ucl.ac.uk> |
5 | * | 3 | * |
6 | * Changes to meet Linux coding standards, and DCCP infrastructure fixes. | 4 | * Changes to meet Linux coding standards, and DCCP infrastructure fixes. |
diff --git a/net/dccp/ccids/ccid2.h b/net/dccp/ccids/ccid2.h index 2c94ca029010..326ac90fb909 100644 --- a/net/dccp/ccids/ccid2.h +++ b/net/dccp/ccids/ccid2.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * net/dccp/ccids/ccid2.h | ||
3 | * | ||
4 | * Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk> | 2 | * Copyright (c) 2005 Andrea Bittau <a.bittau@cs.ucl.ac.uk> |
5 | * | 3 | * |
6 | * This program is free software; you can redistribute it and/or modify | 4 | * This program is free software; you can redistribute it and/or modify |
@@ -40,14 +38,14 @@ struct ccid2_seq { | |||
40 | #define CCID2_SEQBUF_LEN 1024 | 38 | #define CCID2_SEQBUF_LEN 1024 |
41 | #define CCID2_SEQBUF_MAX 128 | 39 | #define CCID2_SEQBUF_MAX 128 |
42 | 40 | ||
43 | /** struct ccid2_hc_tx_sock - CCID2 TX half connection | 41 | /** |
44 | * | 42 | * struct ccid2_hc_tx_sock - CCID2 TX half connection |
45 | * @ccid2hctx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5 | 43 | * @ccid2hctx_{cwnd,ssthresh,pipe}: as per RFC 4341, section 5 |
46 | * @ccid2hctx_packets_acked - Ack counter for deriving cwnd growth (RFC 3465) | 44 | * @ccid2hctx_packets_acked - Ack counter for deriving cwnd growth (RFC 3465) |
47 | * @ccid2hctx_lastrtt -time RTT was last measured | 45 | * @ccid2hctx_lastrtt -time RTT was last measured |
48 | * @ccid2hctx_rpseq - last consecutive seqno | 46 | * @ccid2hctx_rpseq - last consecutive seqno |
49 | * @ccid2hctx_rpdupack - dupacks since rpseq | 47 | * @ccid2hctx_rpdupack - dupacks since rpseq |
50 | */ | 48 | */ |
51 | struct ccid2_hc_tx_sock { | 49 | struct ccid2_hc_tx_sock { |
52 | u32 ccid2hctx_cwnd; | 50 | u32 ccid2hctx_cwnd; |
53 | u32 ccid2hctx_ssthresh; | 51 | u32 ccid2hctx_ssthresh; |
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index f596ce149c3c..34dcc798c457 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * net/dccp/ccids/ccid3.c | ||
3 | * | ||
4 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK | 2 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK |
5 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. | 3 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. |
6 | * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> | 4 | * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> |
@@ -750,7 +748,8 @@ static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) | |||
750 | return 0; | 748 | return 0; |
751 | } | 749 | } |
752 | 750 | ||
753 | /** ccid3_first_li - Implements [RFC 3448, 6.3.1] | 751 | /** |
752 | * ccid3_first_li - Implements [RFC 5348, 6.3.1] | ||
754 | * | 753 | * |
755 | * Determine the length of the first loss interval via inverse lookup. | 754 | * Determine the length of the first loss interval via inverse lookup. |
756 | * Assume that X_recv can be computed by the throughput equation | 755 | * Assume that X_recv can be computed by the throughput equation |
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index 49ca32bd7e79..e5a244143846 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * net/dccp/ccids/ccid3.h | ||
3 | * | ||
4 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. | 2 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. |
5 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK | 3 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK |
6 | * | 4 | * |
@@ -75,8 +73,8 @@ enum ccid3_hc_tx_states { | |||
75 | TFRC_SSTATE_TERM, | 73 | TFRC_SSTATE_TERM, |
76 | }; | 74 | }; |
77 | 75 | ||
78 | /** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket | 76 | /** |
79 | * | 77 | * struct ccid3_hc_tx_sock - CCID3 sender half-connection socket |
80 | * @ccid3hctx_x - Current sending rate in 64 * bytes per second | 78 | * @ccid3hctx_x - Current sending rate in 64 * bytes per second |
81 | * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second | 79 | * @ccid3hctx_x_recv - Receive rate in 64 * bytes per second |
82 | * @ccid3hctx_x_calc - Calculated rate in bytes per second | 80 | * @ccid3hctx_x_calc - Calculated rate in bytes per second |
@@ -119,9 +117,9 @@ struct ccid3_hc_tx_sock { | |||
119 | 117 | ||
120 | static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) | 118 | static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk) |
121 | { | 119 | { |
122 | struct ccid3_hc_tx_sock *hctx = ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid); | 120 | struct ccid3_hc_tx_sock *hctx = ccid_priv(dccp_sk(sk)->dccps_hc_tx_ccid); |
123 | BUG_ON(hctx == NULL); | 121 | BUG_ON(hctx == NULL); |
124 | return hctx; | 122 | return hctx; |
125 | } | 123 | } |
126 | 124 | ||
127 | /* TFRC receiver states */ | 125 | /* TFRC receiver states */ |
@@ -131,22 +129,22 @@ enum ccid3_hc_rx_states { | |||
131 | TFRC_RSTATE_TERM = 127, | 129 | TFRC_RSTATE_TERM = 127, |
132 | }; | 130 | }; |
133 | 131 | ||
134 | /** struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket | 132 | /** |
135 | * | 133 | * struct ccid3_hc_rx_sock - CCID3 receiver half-connection socket |
136 | * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3) | 134 | * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448 4.3) |
137 | * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard) | 135 | * @ccid3hcrx_rtt - Receiver estimate of rtt (non-standard) |
138 | * @ccid3hcrx_p - Current loss event rate (RFC 3448 5.4) | 136 | * @ccid3hcrx_p - Current loss event rate (RFC 3448 5.4) |
139 | * @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1) | 137 | * @ccid3hcrx_last_counter - Tracks window counter (RFC 4342, 8.1) |
140 | * @ccid3hcrx_state - Receiver state, one of %ccid3_hc_rx_states | 138 | * @ccid3hcrx_state - Receiver state, one of %ccid3_hc_rx_states |
141 | * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes | 139 | * @ccid3hcrx_bytes_recv - Total sum of DCCP payload bytes |
142 | * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3) | 140 | * @ccid3hcrx_x_recv - Receiver estimate of send rate (RFC 3448, sec. 4.3) |
143 | * @ccid3hcrx_rtt - Receiver estimate of RTT | 141 | * @ccid3hcrx_rtt - Receiver estimate of RTT |
144 | * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent | 142 | * @ccid3hcrx_tstamp_last_feedback - Time at which last feedback was sent |
145 | * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent | 143 | * @ccid3hcrx_tstamp_last_ack - Time at which last feedback was sent |
146 | * @ccid3hcrx_hist - Packet history (loss detection + RTT sampling) | 144 | * @ccid3hcrx_hist - Packet history (loss detection + RTT sampling) |
147 | * @ccid3hcrx_li_hist - Loss Interval database | 145 | * @ccid3hcrx_li_hist - Loss Interval database |
148 | * @ccid3hcrx_s - Received packet size in bytes | 146 | * @ccid3hcrx_s - Received packet size in bytes |
149 | * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5) | 147 | * @ccid3hcrx_pinv - Inverse of Loss Event Rate (RFC 4342, sec. 8.5) |
150 | */ | 148 | */ |
151 | struct ccid3_hc_rx_sock { | 149 | struct ccid3_hc_rx_sock { |
152 | u8 ccid3hcrx_last_counter:4; | 150 | u8 ccid3hcrx_last_counter:4; |
@@ -163,9 +161,9 @@ struct ccid3_hc_rx_sock { | |||
163 | 161 | ||
164 | static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) | 162 | static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk) |
165 | { | 163 | { |
166 | struct ccid3_hc_rx_sock *hcrx = ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid); | 164 | struct ccid3_hc_rx_sock *hcrx = ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid); |
167 | BUG_ON(hcrx == NULL); | 165 | BUG_ON(hcrx == NULL); |
168 | return hcrx; | 166 | return hcrx; |
169 | } | 167 | } |
170 | 168 | ||
171 | #endif /* _DCCP_CCID3_H_ */ | 169 | #endif /* _DCCP_CCID3_H_ */ |
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c index 4d1e40127264..8fc3cbf79071 100644 --- a/net/dccp/ccids/lib/loss_interval.c +++ b/net/dccp/ccids/lib/loss_interval.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * net/dccp/ccids/lib/loss_interval.c | ||
3 | * | ||
4 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK | 2 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK |
5 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. | 3 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. |
6 | * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> | 4 | * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> |
@@ -21,7 +19,7 @@ static const int tfrc_lh_weights[NINTERVAL] = { 10, 10, 10, 10, 8, 6, 4, 2 }; | |||
21 | /* implements LIFO semantics on the array */ | 19 | /* implements LIFO semantics on the array */ |
22 | static inline u8 LIH_INDEX(const u8 ctr) | 20 | static inline u8 LIH_INDEX(const u8 ctr) |
23 | { | 21 | { |
24 | return (LIH_SIZE - 1 - (ctr % LIH_SIZE)); | 22 | return LIH_SIZE - 1 - (ctr % LIH_SIZE); |
25 | } | 23 | } |
26 | 24 | ||
27 | /* the `counter' index always points at the next entry to be populated */ | 25 | /* the `counter' index always points at the next entry to be populated */ |
@@ -129,7 +127,8 @@ static inline u8 tfrc_lh_is_new_loss(struct tfrc_loss_interval *cur, | |||
129 | (cur->li_is_closed || SUB16(new_loss->tfrchrx_ccval, cur->li_ccval) > 4); | 127 | (cur->li_is_closed || SUB16(new_loss->tfrchrx_ccval, cur->li_ccval) > 4); |
130 | } | 128 | } |
131 | 129 | ||
132 | /** tfrc_lh_interval_add - Insert new record into the Loss Interval database | 130 | /** |
131 | * tfrc_lh_interval_add - Insert new record into the Loss Interval database | ||
133 | * @lh: Loss Interval database | 132 | * @lh: Loss Interval database |
134 | * @rh: Receive history containing a fresh loss event | 133 | * @rh: Receive history containing a fresh loss event |
135 | * @calc_first_li: Caller-dependent routine to compute length of first interval | 134 | * @calc_first_li: Caller-dependent routine to compute length of first interval |
diff --git a/net/dccp/ccids/lib/loss_interval.h b/net/dccp/ccids/lib/loss_interval.h index 246018a3b269..d1d2f5383b7d 100644 --- a/net/dccp/ccids/lib/loss_interval.h +++ b/net/dccp/ccids/lib/loss_interval.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef _DCCP_LI_HIST_ | 1 | #ifndef _DCCP_LI_HIST_ |
2 | #define _DCCP_LI_HIST_ | 2 | #define _DCCP_LI_HIST_ |
3 | /* | 3 | /* |
4 | * net/dccp/ccids/lib/loss_interval.h | ||
5 | * | ||
6 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK | 4 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK |
7 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. | 5 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. |
8 | * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> | 6 | * Copyright (c) 2005-7 Ian McDonald <ian.mcdonald@jandi.co.nz> |
diff --git a/net/dccp/ccids/lib/packet_history.c b/net/dccp/ccids/lib/packet_history.c index b7785b3581ec..3a4f414e94a0 100644 --- a/net/dccp/ccids/lib/packet_history.c +++ b/net/dccp/ccids/lib/packet_history.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * net/dccp/packet_history.c | ||
3 | * | ||
4 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK | 2 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK |
5 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. | 3 | * Copyright (c) 2005-7 The University of Waikato, Hamilton, New Zealand. |
6 | * | 4 | * |
@@ -128,7 +126,7 @@ u32 tfrc_tx_hist_rtt(struct tfrc_tx_hist_entry *head, const u64 seqno, | |||
128 | 126 | ||
129 | 127 | ||
130 | /* | 128 | /* |
131 | * Receiver History Routines | 129 | * Receiver History Routines |
132 | */ | 130 | */ |
133 | static struct kmem_cache *tfrc_rx_hist_slab; | 131 | static struct kmem_cache *tfrc_rx_hist_slab; |
134 | 132 | ||
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index 461cc91cce88..7df6c5299999 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h | |||
@@ -70,7 +70,6 @@ struct tfrc_rx_hist_entry { | |||
70 | 70 | ||
71 | /** | 71 | /** |
72 | * tfrc_rx_hist - RX history structure for TFRC-based protocols | 72 | * tfrc_rx_hist - RX history structure for TFRC-based protocols |
73 | * | ||
74 | * @ring: Packet history for RTT sampling and loss detection | 73 | * @ring: Packet history for RTT sampling and loss detection |
75 | * @loss_count: Number of entries in circular history | 74 | * @loss_count: Number of entries in circular history |
76 | * @loss_start: Movable index (for loss detection) | 75 | * @loss_start: Movable index (for loss detection) |
diff --git a/net/dccp/ccids/lib/tfrc.h b/net/dccp/ccids/lib/tfrc.h index e9720b143275..01bb48e96c2e 100644 --- a/net/dccp/ccids/lib/tfrc.h +++ b/net/dccp/ccids/lib/tfrc.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef _TFRC_H_ | 1 | #ifndef _TFRC_H_ |
2 | #define _TFRC_H_ | 2 | #define _TFRC_H_ |
3 | /* | 3 | /* |
4 | * net/dccp/ccids/lib/tfrc.h | ||
5 | * | ||
6 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK | 4 | * Copyright (c) 2007 The University of Aberdeen, Scotland, UK |
7 | * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. | 5 | * Copyright (c) 2005-6 The University of Waikato, Hamilton, New Zealand. |
8 | * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz> | 6 | * Copyright (c) 2005-6 Ian McDonald <ian.mcdonald@jandi.co.nz> |
@@ -32,7 +30,7 @@ extern int tfrc_debug; | |||
32 | /* integer-arithmetic divisions of type (a * 1000000)/b */ | 30 | /* integer-arithmetic divisions of type (a * 1000000)/b */ |
33 | static inline u64 scaled_div(u64 a, u64 b) | 31 | static inline u64 scaled_div(u64 a, u64 b) |
34 | { | 32 | { |
35 | BUG_ON(b==0); | 33 | BUG_ON(b == 0); |
36 | return div64_u64(a * 1000000, b); | 34 | return div64_u64(a * 1000000, b); |
37 | } | 35 | } |
38 | 36 | ||
diff --git a/net/dccp/ccids/lib/tfrc_equation.c b/net/dccp/ccids/lib/tfrc_equation.c index c5d3a9e5a5a4..22ca1cf0eb55 100644 --- a/net/dccp/ccids/lib/tfrc_equation.c +++ b/net/dccp/ccids/lib/tfrc_equation.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * net/dccp/ccids/lib/tfrc_equation.c | ||
3 | * | ||
4 | * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. | 2 | * Copyright (c) 2005 The University of Waikato, Hamilton, New Zealand. |
5 | * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz> | 3 | * Copyright (c) 2005 Ian McDonald <ian.mcdonald@jandi.co.nz> |
6 | * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> | 4 | * Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@conectiva.com.br> |
@@ -79,10 +77,10 @@ | |||
79 | } | 77 | } |
80 | 78 | ||
81 | With the given configuration, we have, with M = TFRC_CALC_X_ARRSIZE-1, | 79 | With the given configuration, we have, with M = TFRC_CALC_X_ARRSIZE-1, |
82 | lookup[0][0] = g(1000000/(M+1)) = 1000000 * f(0.2%) | 80 | lookup[0][0] = g(1000000/(M+1)) = 1000000 * f(0.2%) |
83 | lookup[M][0] = g(1000000) = 1000000 * f(100%) | 81 | lookup[M][0] = g(1000000) = 1000000 * f(100%) |
84 | lookup[0][1] = g(TFRC_SMALLEST_P) = 1000000 * f(0.01%) | 82 | lookup[0][1] = g(TFRC_SMALLEST_P) = 1000000 * f(0.01%) |
85 | lookup[M][1] = g(TFRC_CALC_X_SPLIT) = 1000000 * f(5%) | 83 | lookup[M][1] = g(TFRC_CALC_X_SPLIT) = 1000000 * f(5%) |
86 | 84 | ||
87 | In summary, the two columns represent f(p) for the following ranges: | 85 | In summary, the two columns represent f(p) for the following ranges: |
88 | * The first column is for 0.002 <= p <= 1.0 | 86 | * The first column is for 0.002 <= p <= 1.0 |
@@ -610,11 +608,10 @@ static inline u32 tfrc_binsearch(u32 fval, u8 small) | |||
610 | 608 | ||
611 | /** | 609 | /** |
612 | * tfrc_calc_x - Calculate the send rate as per section 3.1 of RFC3448 | 610 | * tfrc_calc_x - Calculate the send rate as per section 3.1 of RFC3448 |
613 | * | 611 | * @s: packet size in bytes |
614 | * @s: packet size in bytes | 612 | * @R: RTT scaled by 1000000 (i.e., microseconds) |
615 | * @R: RTT scaled by 1000000 (i.e., microseconds) | 613 | * @p: loss ratio estimate scaled by 1000000 |
616 | * @p: loss ratio estimate scaled by 1000000 | 614 | * Returns X_calc in bytes per second (not scaled). |
617 | * Returns X_calc in bytes per second (not scaled). | ||
618 | */ | 615 | */ |
619 | u32 tfrc_calc_x(u16 s, u32 R, u32 p) | 616 | u32 tfrc_calc_x(u16 s, u32 R, u32 p) |
620 | { | 617 | { |
@@ -630,17 +627,17 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p) | |||
630 | return ~0U; | 627 | return ~0U; |
631 | } | 628 | } |
632 | 629 | ||
633 | if (p <= TFRC_CALC_X_SPLIT) { /* 0.0000 < p <= 0.05 */ | 630 | if (p <= TFRC_CALC_X_SPLIT) { /* 0.0000 < p <= 0.05 */ |
634 | if (p < TFRC_SMALLEST_P) { /* 0.0000 < p < 0.0001 */ | 631 | if (p < TFRC_SMALLEST_P) { /* 0.0000 < p < 0.0001 */ |
635 | DCCP_WARN("Value of p (%d) below resolution. " | 632 | DCCP_WARN("Value of p (%d) below resolution. " |
636 | "Substituting %d\n", p, TFRC_SMALLEST_P); | 633 | "Substituting %d\n", p, TFRC_SMALLEST_P); |
637 | index = 0; | 634 | index = 0; |
638 | } else /* 0.0001 <= p <= 0.05 */ | 635 | } else /* 0.0001 <= p <= 0.05 */ |
639 | index = p/TFRC_SMALLEST_P - 1; | 636 | index = p/TFRC_SMALLEST_P - 1; |
640 | 637 | ||
641 | f = tfrc_calc_x_lookup[index][1]; | 638 | f = tfrc_calc_x_lookup[index][1]; |
642 | 639 | ||
643 | } else { /* 0.05 < p <= 1.00 */ | 640 | } else { /* 0.05 < p <= 1.00 */ |
644 | index = p/(1000000/TFRC_CALC_X_ARRSIZE) - 1; | 641 | index = p/(1000000/TFRC_CALC_X_ARRSIZE) - 1; |
645 | 642 | ||
646 | f = tfrc_calc_x_lookup[index][0]; | 643 | f = tfrc_calc_x_lookup[index][0]; |
@@ -661,7 +658,6 @@ u32 tfrc_calc_x(u16 s, u32 R, u32 p) | |||
661 | 658 | ||
662 | /** | 659 | /** |
663 | * tfrc_calc_x_reverse_lookup - try to find p given f(p) | 660 | * tfrc_calc_x_reverse_lookup - try to find p given f(p) |
664 | * | ||
665 | * @fvalue: function value to match, scaled by 1000000 | 661 | * @fvalue: function value to match, scaled by 1000000 |
666 | * Returns closest match for p, also scaled by 1000000 | 662 | * Returns closest match for p, also scaled by 1000000 |
667 | */ | 663 | */ |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index d01c00de1ad0..7302e1498d46 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -948,7 +948,7 @@ static struct proto dccp_v4_prot = { | |||
948 | #endif | 948 | #endif |
949 | }; | 949 | }; |
950 | 950 | ||
951 | static struct net_protocol dccp_v4_protocol = { | 951 | static const struct net_protocol dccp_v4_protocol = { |
952 | .handler = dccp_v4_rcv, | 952 | .handler = dccp_v4_rcv, |
953 | .err_handler = dccp_v4_err, | 953 | .err_handler = dccp_v4_err, |
954 | .no_policy = 1, | 954 | .no_policy = 1, |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index 64f011cc4491..e48ca5d45658 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -1152,13 +1152,13 @@ static struct proto dccp_v6_prot = { | |||
1152 | #endif | 1152 | #endif |
1153 | }; | 1153 | }; |
1154 | 1154 | ||
1155 | static struct inet6_protocol dccp_v6_protocol = { | 1155 | static const struct inet6_protocol dccp_v6_protocol = { |
1156 | .handler = dccp_v6_rcv, | 1156 | .handler = dccp_v6_rcv, |
1157 | .err_handler = dccp_v6_err, | 1157 | .err_handler = dccp_v6_err, |
1158 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, | 1158 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, |
1159 | }; | 1159 | }; |
1160 | 1160 | ||
1161 | static struct proto_ops inet6_dccp_ops = { | 1161 | static const struct proto_ops inet6_dccp_ops = { |
1162 | .family = PF_INET6, | 1162 | .family = PF_INET6, |
1163 | .owner = THIS_MODULE, | 1163 | .owner = THIS_MODULE, |
1164 | .release = inet6_release, | 1164 | .release = inet6_release, |
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c index 77ae6852b93d..51593a48f2dd 100644 --- a/net/ieee802154/dgram.c +++ b/net/ieee802154/dgram.c | |||
@@ -414,7 +414,7 @@ static int dgram_getsockopt(struct sock *sk, int level, int optname, | |||
414 | } | 414 | } |
415 | 415 | ||
416 | static int dgram_setsockopt(struct sock *sk, int level, int optname, | 416 | static int dgram_setsockopt(struct sock *sk, int level, int optname, |
417 | char __user *optval, int __user optlen) | 417 | char __user *optval, int optlen) |
418 | { | 418 | { |
419 | struct dgram_sock *ro = dgram_sk(sk); | 419 | struct dgram_sock *ro = dgram_sk(sk); |
420 | int val; | 420 | int val; |
diff --git a/net/ieee802154/netlink.c b/net/ieee802154/netlink.c index 2106ecbf0308..ca767bde17a4 100644 --- a/net/ieee802154/netlink.c +++ b/net/ieee802154/netlink.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <net/ieee802154_netdev.h> | 35 | #include <net/ieee802154_netdev.h> |
36 | 36 | ||
37 | static unsigned int ieee802154_seq_num; | 37 | static unsigned int ieee802154_seq_num; |
38 | static DEFINE_SPINLOCK(ieee802154_seq_lock); | ||
38 | 39 | ||
39 | static struct genl_family ieee802154_coordinator_family = { | 40 | static struct genl_family ieee802154_coordinator_family = { |
40 | .id = GENL_ID_GENERATE, | 41 | .id = GENL_ID_GENERATE, |
@@ -57,12 +58,15 @@ static struct sk_buff *ieee802154_nl_create(int flags, u8 req) | |||
57 | { | 58 | { |
58 | void *hdr; | 59 | void *hdr; |
59 | struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); | 60 | struct sk_buff *msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC); |
61 | unsigned long f; | ||
60 | 62 | ||
61 | if (!msg) | 63 | if (!msg) |
62 | return NULL; | 64 | return NULL; |
63 | 65 | ||
66 | spin_lock_irqsave(&ieee802154_seq_lock, f); | ||
64 | hdr = genlmsg_put(msg, 0, ieee802154_seq_num++, | 67 | hdr = genlmsg_put(msg, 0, ieee802154_seq_num++, |
65 | &ieee802154_coordinator_family, flags, req); | 68 | &ieee802154_coordinator_family, flags, req); |
69 | spin_unlock_irqrestore(&ieee802154_seq_lock, f); | ||
66 | if (!hdr) { | 70 | if (!hdr) { |
67 | nlmsg_free(msg); | 71 | nlmsg_free(msg); |
68 | return NULL; | 72 | return NULL; |
diff --git a/net/ieee802154/raw.c b/net/ieee802154/raw.c index 4681501aae93..13198859982e 100644 --- a/net/ieee802154/raw.c +++ b/net/ieee802154/raw.c | |||
@@ -244,7 +244,7 @@ static int raw_getsockopt(struct sock *sk, int level, int optname, | |||
244 | } | 244 | } |
245 | 245 | ||
246 | static int raw_setsockopt(struct sock *sk, int level, int optname, | 246 | static int raw_setsockopt(struct sock *sk, int level, int optname, |
247 | char __user *optval, int __user optlen) | 247 | char __user *optval, int optlen) |
248 | { | 248 | { |
249 | return -EOPNOTSUPP; | 249 | return -EOPNOTSUPP; |
250 | } | 250 | } |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 6c30a73f03f5..58c4b0f7c4aa 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -244,7 +244,7 @@ EXPORT_SYMBOL(build_ehash_secret); | |||
244 | static inline int inet_netns_ok(struct net *net, int protocol) | 244 | static inline int inet_netns_ok(struct net *net, int protocol) |
245 | { | 245 | { |
246 | int hash; | 246 | int hash; |
247 | struct net_protocol *ipprot; | 247 | const struct net_protocol *ipprot; |
248 | 248 | ||
249 | if (net_eq(net, &init_net)) | 249 | if (net_eq(net, &init_net)) |
250 | return 1; | 250 | return 1; |
@@ -1162,7 +1162,7 @@ EXPORT_SYMBOL(inet_sk_rebuild_header); | |||
1162 | static int inet_gso_send_check(struct sk_buff *skb) | 1162 | static int inet_gso_send_check(struct sk_buff *skb) |
1163 | { | 1163 | { |
1164 | struct iphdr *iph; | 1164 | struct iphdr *iph; |
1165 | struct net_protocol *ops; | 1165 | const struct net_protocol *ops; |
1166 | int proto; | 1166 | int proto; |
1167 | int ihl; | 1167 | int ihl; |
1168 | int err = -EINVAL; | 1168 | int err = -EINVAL; |
@@ -1198,7 +1198,7 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features) | |||
1198 | { | 1198 | { |
1199 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 1199 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
1200 | struct iphdr *iph; | 1200 | struct iphdr *iph; |
1201 | struct net_protocol *ops; | 1201 | const struct net_protocol *ops; |
1202 | int proto; | 1202 | int proto; |
1203 | int ihl; | 1203 | int ihl; |
1204 | int id; | 1204 | int id; |
@@ -1265,7 +1265,7 @@ out: | |||
1265 | static struct sk_buff **inet_gro_receive(struct sk_buff **head, | 1265 | static struct sk_buff **inet_gro_receive(struct sk_buff **head, |
1266 | struct sk_buff *skb) | 1266 | struct sk_buff *skb) |
1267 | { | 1267 | { |
1268 | struct net_protocol *ops; | 1268 | const struct net_protocol *ops; |
1269 | struct sk_buff **pp = NULL; | 1269 | struct sk_buff **pp = NULL; |
1270 | struct sk_buff *p; | 1270 | struct sk_buff *p; |
1271 | struct iphdr *iph; | 1271 | struct iphdr *iph; |
@@ -1342,7 +1342,7 @@ out: | |||
1342 | 1342 | ||
1343 | static int inet_gro_complete(struct sk_buff *skb) | 1343 | static int inet_gro_complete(struct sk_buff *skb) |
1344 | { | 1344 | { |
1345 | struct net_protocol *ops; | 1345 | const struct net_protocol *ops; |
1346 | struct iphdr *iph = ip_hdr(skb); | 1346 | struct iphdr *iph = ip_hdr(skb); |
1347 | int proto = iph->protocol & (MAX_INET_PROTOS - 1); | 1347 | int proto = iph->protocol & (MAX_INET_PROTOS - 1); |
1348 | int err = -ENOSYS; | 1348 | int err = -ENOSYS; |
@@ -1427,13 +1427,13 @@ void snmp_mib_free(void *ptr[2]) | |||
1427 | EXPORT_SYMBOL_GPL(snmp_mib_free); | 1427 | EXPORT_SYMBOL_GPL(snmp_mib_free); |
1428 | 1428 | ||
1429 | #ifdef CONFIG_IP_MULTICAST | 1429 | #ifdef CONFIG_IP_MULTICAST |
1430 | static struct net_protocol igmp_protocol = { | 1430 | static const struct net_protocol igmp_protocol = { |
1431 | .handler = igmp_rcv, | 1431 | .handler = igmp_rcv, |
1432 | .netns_ok = 1, | 1432 | .netns_ok = 1, |
1433 | }; | 1433 | }; |
1434 | #endif | 1434 | #endif |
1435 | 1435 | ||
1436 | static struct net_protocol tcp_protocol = { | 1436 | static const struct net_protocol tcp_protocol = { |
1437 | .handler = tcp_v4_rcv, | 1437 | .handler = tcp_v4_rcv, |
1438 | .err_handler = tcp_v4_err, | 1438 | .err_handler = tcp_v4_err, |
1439 | .gso_send_check = tcp_v4_gso_send_check, | 1439 | .gso_send_check = tcp_v4_gso_send_check, |
@@ -1444,7 +1444,7 @@ static struct net_protocol tcp_protocol = { | |||
1444 | .netns_ok = 1, | 1444 | .netns_ok = 1, |
1445 | }; | 1445 | }; |
1446 | 1446 | ||
1447 | static struct net_protocol udp_protocol = { | 1447 | static const struct net_protocol udp_protocol = { |
1448 | .handler = udp_rcv, | 1448 | .handler = udp_rcv, |
1449 | .err_handler = udp_err, | 1449 | .err_handler = udp_err, |
1450 | .gso_send_check = udp4_ufo_send_check, | 1450 | .gso_send_check = udp4_ufo_send_check, |
@@ -1453,7 +1453,7 @@ static struct net_protocol udp_protocol = { | |||
1453 | .netns_ok = 1, | 1453 | .netns_ok = 1, |
1454 | }; | 1454 | }; |
1455 | 1455 | ||
1456 | static struct net_protocol icmp_protocol = { | 1456 | static const struct net_protocol icmp_protocol = { |
1457 | .handler = icmp_rcv, | 1457 | .handler = icmp_rcv, |
1458 | .no_policy = 1, | 1458 | .no_policy = 1, |
1459 | .netns_ok = 1, | 1459 | .netns_ok = 1, |
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index e878e494296e..5c662703eb1e 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c | |||
@@ -311,7 +311,7 @@ static const struct xfrm_type ah_type = | |||
311 | .output = ah_output | 311 | .output = ah_output |
312 | }; | 312 | }; |
313 | 313 | ||
314 | static struct net_protocol ah4_protocol = { | 314 | static const struct net_protocol ah4_protocol = { |
315 | .handler = xfrm4_rcv, | 315 | .handler = xfrm4_rcv, |
316 | .err_handler = ah4_err, | 316 | .err_handler = ah4_err, |
317 | .no_policy = 1, | 317 | .no_policy = 1, |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 3863c3a4223f..07336c6201f0 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -1087,6 +1087,12 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1087 | case NETDEV_DOWN: | 1087 | case NETDEV_DOWN: |
1088 | ip_mc_down(in_dev); | 1088 | ip_mc_down(in_dev); |
1089 | break; | 1089 | break; |
1090 | case NETDEV_BONDING_OLDTYPE: | ||
1091 | ip_mc_unmap(in_dev); | ||
1092 | break; | ||
1093 | case NETDEV_BONDING_NEWTYPE: | ||
1094 | ip_mc_remap(in_dev); | ||
1095 | break; | ||
1090 | case NETDEV_CHANGEMTU: | 1096 | case NETDEV_CHANGEMTU: |
1091 | if (inetdev_valid_mtu(dev->mtu)) | 1097 | if (inetdev_valid_mtu(dev->mtu)) |
1092 | break; | 1098 | break; |
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 18bb383ea393..12f7287e902d 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
@@ -615,7 +615,7 @@ static const struct xfrm_type esp_type = | |||
615 | .output = esp_output | 615 | .output = esp_output |
616 | }; | 616 | }; |
617 | 617 | ||
618 | static struct net_protocol esp4_protocol = { | 618 | static const struct net_protocol esp4_protocol = { |
619 | .handler = xfrm4_rcv, | 619 | .handler = xfrm4_rcv, |
620 | .err_handler = esp4_err, | 620 | .err_handler = esp4_err, |
621 | .no_policy = 1, | 621 | .no_policy = 1, |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 97c410e84388..5bc13fe816d1 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -655,7 +655,7 @@ static void icmp_unreach(struct sk_buff *skb) | |||
655 | struct iphdr *iph; | 655 | struct iphdr *iph; |
656 | struct icmphdr *icmph; | 656 | struct icmphdr *icmph; |
657 | int hash, protocol; | 657 | int hash, protocol; |
658 | struct net_protocol *ipprot; | 658 | const struct net_protocol *ipprot; |
659 | u32 info = 0; | 659 | u32 info = 0; |
660 | struct net *net; | 660 | struct net *net; |
661 | 661 | ||
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 01b4284ed694..d41e5de79a82 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -1298,6 +1298,28 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr) | |||
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | /* Device changing type */ | ||
1302 | |||
1303 | void ip_mc_unmap(struct in_device *in_dev) | ||
1304 | { | ||
1305 | struct ip_mc_list *i; | ||
1306 | |||
1307 | ASSERT_RTNL(); | ||
1308 | |||
1309 | for (i = in_dev->mc_list; i; i = i->next) | ||
1310 | igmp_group_dropped(i); | ||
1311 | } | ||
1312 | |||
1313 | void ip_mc_remap(struct in_device *in_dev) | ||
1314 | { | ||
1315 | struct ip_mc_list *i; | ||
1316 | |||
1317 | ASSERT_RTNL(); | ||
1318 | |||
1319 | for (i = in_dev->mc_list; i; i = i->next) | ||
1320 | igmp_group_added(i); | ||
1321 | } | ||
1322 | |||
1301 | /* Device going down */ | 1323 | /* Device going down */ |
1302 | 1324 | ||
1303 | void ip_mc_down(struct in_device *in_dev) | 1325 | void ip_mc_down(struct in_device *in_dev) |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 533afaadefd4..d9645c94a067 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -1288,7 +1288,7 @@ static void ipgre_fb_tunnel_init(struct net_device *dev) | |||
1288 | } | 1288 | } |
1289 | 1289 | ||
1290 | 1290 | ||
1291 | static struct net_protocol ipgre_protocol = { | 1291 | static const struct net_protocol ipgre_protocol = { |
1292 | .handler = ipgre_rcv, | 1292 | .handler = ipgre_rcv, |
1293 | .err_handler = ipgre_err, | 1293 | .err_handler = ipgre_err, |
1294 | .netns_ok = 1, | 1294 | .netns_ok = 1, |
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index db46b4b5b2b9..6c98b43badf4 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c | |||
@@ -202,7 +202,7 @@ static int ip_local_deliver_finish(struct sk_buff *skb) | |||
202 | { | 202 | { |
203 | int protocol = ip_hdr(skb)->protocol; | 203 | int protocol = ip_hdr(skb)->protocol; |
204 | int hash, raw; | 204 | int hash, raw; |
205 | struct net_protocol *ipprot; | 205 | const struct net_protocol *ipprot; |
206 | 206 | ||
207 | resubmit: | 207 | resubmit: |
208 | raw = raw_local_deliver(skb, protocol); | 208 | raw = raw_local_deliver(skb, protocol); |
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index 3262ce06294c..38fbf04150ae 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c | |||
@@ -146,7 +146,7 @@ static const struct xfrm_type ipcomp_type = { | |||
146 | .output = ipcomp_output | 146 | .output = ipcomp_output |
147 | }; | 147 | }; |
148 | 148 | ||
149 | static struct net_protocol ipcomp4_protocol = { | 149 | static const struct net_protocol ipcomp4_protocol = { |
150 | .handler = xfrm4_rcv, | 150 | .handler = xfrm4_rcv, |
151 | .err_handler = ipcomp4_err, | 151 | .err_handler = ipcomp4_err, |
152 | .no_policy = 1, | 152 | .no_policy = 1, |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 65d421cf5bc7..c43ec2d51ce2 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -99,10 +99,6 @@ static int ipmr_cache_report(struct net *net, | |||
99 | struct sk_buff *pkt, vifi_t vifi, int assert); | 99 | struct sk_buff *pkt, vifi_t vifi, int assert); |
100 | static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm); | 100 | static int ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm); |
101 | 101 | ||
102 | #ifdef CONFIG_IP_PIMSM_V2 | ||
103 | static struct net_protocol pim_protocol; | ||
104 | #endif | ||
105 | |||
106 | static struct timer_list ipmr_expire_timer; | 102 | static struct timer_list ipmr_expire_timer; |
107 | 103 | ||
108 | /* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */ | 104 | /* Service routines creating virtual interfaces: DVMRP tunnels and PIMREG */ |
@@ -1945,7 +1941,7 @@ static const struct file_operations ipmr_mfc_fops = { | |||
1945 | #endif | 1941 | #endif |
1946 | 1942 | ||
1947 | #ifdef CONFIG_IP_PIMSM_V2 | 1943 | #ifdef CONFIG_IP_PIMSM_V2 |
1948 | static struct net_protocol pim_protocol = { | 1944 | static const struct net_protocol pim_protocol = { |
1949 | .handler = pim_rcv, | 1945 | .handler = pim_rcv, |
1950 | .netns_ok = 1, | 1946 | .netns_ok = 1, |
1951 | }; | 1947 | }; |
diff --git a/net/ipv4/protocol.c b/net/ipv4/protocol.c index a2e5fc0a15e1..542f22fc98b3 100644 --- a/net/ipv4/protocol.c +++ b/net/ipv4/protocol.c | |||
@@ -28,14 +28,14 @@ | |||
28 | #include <linux/spinlock.h> | 28 | #include <linux/spinlock.h> |
29 | #include <net/protocol.h> | 29 | #include <net/protocol.h> |
30 | 30 | ||
31 | struct net_protocol *inet_protos[MAX_INET_PROTOS] ____cacheline_aligned_in_smp; | 31 | const struct net_protocol *inet_protos[MAX_INET_PROTOS] ____cacheline_aligned_in_smp; |
32 | static DEFINE_SPINLOCK(inet_proto_lock); | 32 | static DEFINE_SPINLOCK(inet_proto_lock); |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * Add a protocol handler to the hash tables | 35 | * Add a protocol handler to the hash tables |
36 | */ | 36 | */ |
37 | 37 | ||
38 | int inet_add_protocol(struct net_protocol *prot, unsigned char protocol) | 38 | int inet_add_protocol(const struct net_protocol *prot, unsigned char protocol) |
39 | { | 39 | { |
40 | int hash, ret; | 40 | int hash, ret; |
41 | 41 | ||
@@ -57,7 +57,7 @@ int inet_add_protocol(struct net_protocol *prot, unsigned char protocol) | |||
57 | * Remove a protocol from the hash tables. | 57 | * Remove a protocol from the hash tables. |
58 | */ | 58 | */ |
59 | 59 | ||
60 | int inet_del_protocol(struct net_protocol *prot, unsigned char protocol) | 60 | int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol) |
61 | { | 61 | { |
62 | int hash, ret; | 62 | int hash, ret; |
63 | 63 | ||
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index edeea060db44..19a0612b8a20 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2012,7 +2012,7 @@ int tcp_disconnect(struct sock *sk, int flags) | |||
2012 | tp->snd_cwnd = 2; | 2012 | tp->snd_cwnd = 2; |
2013 | icsk->icsk_probes_out = 0; | 2013 | icsk->icsk_probes_out = 0; |
2014 | tp->packets_out = 0; | 2014 | tp->packets_out = 0; |
2015 | tp->snd_ssthresh = 0x7fffffff; | 2015 | tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; |
2016 | tp->snd_cwnd_cnt = 0; | 2016 | tp->snd_cwnd_cnt = 0; |
2017 | tp->bytes_acked = 0; | 2017 | tp->bytes_acked = 0; |
2018 | tcp_set_ca_state(sk, TCP_CA_Open); | 2018 | tcp_set_ca_state(sk, TCP_CA_Open); |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index af6d6fa00db1..d86784be7ab3 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -761,7 +761,7 @@ void tcp_update_metrics(struct sock *sk) | |||
761 | set_dst_metric_rtt(dst, RTAX_RTTVAR, var); | 761 | set_dst_metric_rtt(dst, RTAX_RTTVAR, var); |
762 | } | 762 | } |
763 | 763 | ||
764 | if (tp->snd_ssthresh >= 0xFFFF) { | 764 | if (tcp_in_initial_slowstart(tp)) { |
765 | /* Slow start still did not finish. */ | 765 | /* Slow start still did not finish. */ |
766 | if (dst_metric(dst, RTAX_SSTHRESH) && | 766 | if (dst_metric(dst, RTAX_SSTHRESH) && |
767 | !dst_metric_locked(dst, RTAX_SSTHRESH) && | 767 | !dst_metric_locked(dst, RTAX_SSTHRESH) && |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 0543561da999..7cda24b53f61 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1808,7 +1808,7 @@ static int tcp_v4_init_sock(struct sock *sk) | |||
1808 | /* See draft-stevens-tcpca-spec-01 for discussion of the | 1808 | /* See draft-stevens-tcpca-spec-01 for discussion of the |
1809 | * initialization of these values. | 1809 | * initialization of these values. |
1810 | */ | 1810 | */ |
1811 | tp->snd_ssthresh = 0x7fffffff; /* Infinity */ | 1811 | tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; |
1812 | tp->snd_cwnd_clamp = ~0; | 1812 | tp->snd_cwnd_clamp = ~0; |
1813 | tp->mss_cache = 536; | 1813 | tp->mss_cache = 536; |
1814 | 1814 | ||
@@ -2284,7 +2284,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len) | |||
2284 | jiffies_to_clock_t(icsk->icsk_ack.ato), | 2284 | jiffies_to_clock_t(icsk->icsk_ack.ato), |
2285 | (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong, | 2285 | (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong, |
2286 | tp->snd_cwnd, | 2286 | tp->snd_cwnd, |
2287 | tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh, | 2287 | tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh, |
2288 | len); | 2288 | len); |
2289 | } | 2289 | } |
2290 | 2290 | ||
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index e48c37d74d77..624c3c9b3c2b 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -363,7 +363,7 @@ void tcp_twsk_destructor(struct sock *sk) | |||
363 | #ifdef CONFIG_TCP_MD5SIG | 363 | #ifdef CONFIG_TCP_MD5SIG |
364 | struct tcp_timewait_sock *twsk = tcp_twsk(sk); | 364 | struct tcp_timewait_sock *twsk = tcp_twsk(sk); |
365 | if (twsk->tw_md5_keylen) | 365 | if (twsk->tw_md5_keylen) |
366 | tcp_put_md5sig_pool(); | 366 | tcp_free_md5sig_pool(); |
367 | #endif | 367 | #endif |
368 | } | 368 | } |
369 | 369 | ||
@@ -410,7 +410,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, | |||
410 | newtp->retrans_out = 0; | 410 | newtp->retrans_out = 0; |
411 | newtp->sacked_out = 0; | 411 | newtp->sacked_out = 0; |
412 | newtp->fackets_out = 0; | 412 | newtp->fackets_out = 0; |
413 | newtp->snd_ssthresh = 0x7fffffff; | 413 | newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH; |
414 | 414 | ||
415 | /* So many TCP implementations out there (incorrectly) count the | 415 | /* So many TCP implementations out there (incorrectly) count the |
416 | * initial SYN frame in their delayed-ACK and congestion control | 416 | * initial SYN frame in their delayed-ACK and congestion control |
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c index cb1f0e83830b..3959e0ca456a 100644 --- a/net/ipv4/tunnel4.c +++ b/net/ipv4/tunnel4.c | |||
@@ -132,7 +132,7 @@ static void tunnel64_err(struct sk_buff *skb, u32 info) | |||
132 | } | 132 | } |
133 | #endif | 133 | #endif |
134 | 134 | ||
135 | static struct net_protocol tunnel4_protocol = { | 135 | static const struct net_protocol tunnel4_protocol = { |
136 | .handler = tunnel4_rcv, | 136 | .handler = tunnel4_rcv, |
137 | .err_handler = tunnel4_err, | 137 | .err_handler = tunnel4_err, |
138 | .no_policy = 1, | 138 | .no_policy = 1, |
@@ -140,7 +140,7 @@ static struct net_protocol tunnel4_protocol = { | |||
140 | }; | 140 | }; |
141 | 141 | ||
142 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 142 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
143 | static struct net_protocol tunnel64_protocol = { | 143 | static const struct net_protocol tunnel64_protocol = { |
144 | .handler = tunnel64_rcv, | 144 | .handler = tunnel64_rcv, |
145 | .err_handler = tunnel64_err, | 145 | .err_handler = tunnel64_err, |
146 | .no_policy = 1, | 146 | .no_policy = 1, |
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index c784891cb7e5..95248d7f75ec 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c | |||
@@ -25,7 +25,7 @@ static void udplite_err(struct sk_buff *skb, u32 info) | |||
25 | __udp4_lib_err(skb, info, &udplite_table); | 25 | __udp4_lib_err(skb, info, &udplite_table); |
26 | } | 26 | } |
27 | 27 | ||
28 | static struct net_protocol udplite_protocol = { | 28 | static const struct net_protocol udplite_protocol = { |
29 | .handler = udplite_rcv, | 29 | .handler = udplite_rcv, |
30 | .err_handler = udplite_err, | 30 | .err_handler = udplite_err, |
31 | .no_policy = 1, | 31 | .no_policy = 1, |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index c9b369034a40..55f486d89c88 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -137,6 +137,8 @@ static DEFINE_SPINLOCK(addrconf_verify_lock); | |||
137 | static void addrconf_join_anycast(struct inet6_ifaddr *ifp); | 137 | static void addrconf_join_anycast(struct inet6_ifaddr *ifp); |
138 | static void addrconf_leave_anycast(struct inet6_ifaddr *ifp); | 138 | static void addrconf_leave_anycast(struct inet6_ifaddr *ifp); |
139 | 139 | ||
140 | static void addrconf_bonding_change(struct net_device *dev, | ||
141 | unsigned long event); | ||
140 | static int addrconf_ifdown(struct net_device *dev, int how); | 142 | static int addrconf_ifdown(struct net_device *dev, int how); |
141 | 143 | ||
142 | static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags); | 144 | static void addrconf_dad_start(struct inet6_ifaddr *ifp, u32 flags); |
@@ -1405,8 +1407,8 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp) | |||
1405 | struct inet6_dev *idev = ifp->idev; | 1407 | struct inet6_dev *idev = ifp->idev; |
1406 | 1408 | ||
1407 | if (net_ratelimit()) | 1409 | if (net_ratelimit()) |
1408 | printk(KERN_INFO "%s: IPv6 duplicate address detected!\n", | 1410 | printk(KERN_INFO "%s: IPv6 duplicate address %pI6c detected!\n", |
1409 | ifp->idev->dev->name); | 1411 | ifp->idev->dev->name, &ifp->addr); |
1410 | 1412 | ||
1411 | if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) { | 1413 | if (idev->cnf.accept_dad > 1 && !idev->cnf.disable_ipv6) { |
1412 | struct in6_addr addr; | 1414 | struct in6_addr addr; |
@@ -2582,6 +2584,10 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event, | |||
2582 | return notifier_from_errno(err); | 2584 | return notifier_from_errno(err); |
2583 | } | 2585 | } |
2584 | break; | 2586 | break; |
2587 | case NETDEV_BONDING_OLDTYPE: | ||
2588 | case NETDEV_BONDING_NEWTYPE: | ||
2589 | addrconf_bonding_change(dev, event); | ||
2590 | break; | ||
2585 | } | 2591 | } |
2586 | 2592 | ||
2587 | return NOTIFY_OK; | 2593 | return NOTIFY_OK; |
@@ -2595,6 +2601,19 @@ static struct notifier_block ipv6_dev_notf = { | |||
2595 | .priority = 0 | 2601 | .priority = 0 |
2596 | }; | 2602 | }; |
2597 | 2603 | ||
2604 | static void addrconf_bonding_change(struct net_device *dev, unsigned long event) | ||
2605 | { | ||
2606 | struct inet6_dev *idev; | ||
2607 | ASSERT_RTNL(); | ||
2608 | |||
2609 | idev = __in6_dev_get(dev); | ||
2610 | |||
2611 | if (event == NETDEV_BONDING_NEWTYPE) | ||
2612 | ipv6_mc_remap(idev); | ||
2613 | else if (event == NETDEV_BONDING_OLDTYPE) | ||
2614 | ipv6_mc_unmap(idev); | ||
2615 | } | ||
2616 | |||
2598 | static int addrconf_ifdown(struct net_device *dev, int how) | 2617 | static int addrconf_ifdown(struct net_device *dev, int how) |
2599 | { | 2618 | { |
2600 | struct inet6_dev *idev; | 2619 | struct inet6_dev *idev; |
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index a123a328aeb3..e127a32f9540 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -710,7 +710,7 @@ EXPORT_SYMBOL_GPL(ipv6_opt_accepted); | |||
710 | 710 | ||
711 | static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto) | 711 | static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto) |
712 | { | 712 | { |
713 | struct inet6_protocol *ops = NULL; | 713 | const struct inet6_protocol *ops = NULL; |
714 | 714 | ||
715 | for (;;) { | 715 | for (;;) { |
716 | struct ipv6_opt_hdr *opth; | 716 | struct ipv6_opt_hdr *opth; |
@@ -745,7 +745,7 @@ static int ipv6_gso_pull_exthdrs(struct sk_buff *skb, int proto) | |||
745 | static int ipv6_gso_send_check(struct sk_buff *skb) | 745 | static int ipv6_gso_send_check(struct sk_buff *skb) |
746 | { | 746 | { |
747 | struct ipv6hdr *ipv6h; | 747 | struct ipv6hdr *ipv6h; |
748 | struct inet6_protocol *ops; | 748 | const struct inet6_protocol *ops; |
749 | int err = -EINVAL; | 749 | int err = -EINVAL; |
750 | 750 | ||
751 | if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) | 751 | if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) |
@@ -773,7 +773,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features) | |||
773 | { | 773 | { |
774 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 774 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
775 | struct ipv6hdr *ipv6h; | 775 | struct ipv6hdr *ipv6h; |
776 | struct inet6_protocol *ops; | 776 | const struct inet6_protocol *ops; |
777 | int proto; | 777 | int proto; |
778 | struct frag_hdr *fptr; | 778 | struct frag_hdr *fptr; |
779 | unsigned int unfrag_ip6hlen; | 779 | unsigned int unfrag_ip6hlen; |
@@ -840,7 +840,7 @@ struct ipv6_gro_cb { | |||
840 | static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, | 840 | static struct sk_buff **ipv6_gro_receive(struct sk_buff **head, |
841 | struct sk_buff *skb) | 841 | struct sk_buff *skb) |
842 | { | 842 | { |
843 | struct inet6_protocol *ops; | 843 | const struct inet6_protocol *ops; |
844 | struct sk_buff **pp = NULL; | 844 | struct sk_buff **pp = NULL; |
845 | struct sk_buff *p; | 845 | struct sk_buff *p; |
846 | struct ipv6hdr *iph; | 846 | struct ipv6hdr *iph; |
@@ -926,7 +926,7 @@ out: | |||
926 | 926 | ||
927 | static int ipv6_gro_complete(struct sk_buff *skb) | 927 | static int ipv6_gro_complete(struct sk_buff *skb) |
928 | { | 928 | { |
929 | struct inet6_protocol *ops; | 929 | const struct inet6_protocol *ops; |
930 | struct ipv6hdr *iph = ipv6_hdr(skb); | 930 | struct ipv6hdr *iph = ipv6_hdr(skb); |
931 | int err = -ENOSYS; | 931 | int err = -ENOSYS; |
932 | 932 | ||
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index 86f42a288c4b..c1589e2f1dc9 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c | |||
@@ -527,7 +527,7 @@ static const struct xfrm_type ah6_type = | |||
527 | .hdr_offset = xfrm6_find_1stfragopt, | 527 | .hdr_offset = xfrm6_find_1stfragopt, |
528 | }; | 528 | }; |
529 | 529 | ||
530 | static struct inet6_protocol ah6_protocol = { | 530 | static const struct inet6_protocol ah6_protocol = { |
531 | .handler = xfrm6_rcv, | 531 | .handler = xfrm6_rcv, |
532 | .err_handler = ah6_err, | 532 | .err_handler = ah6_err, |
533 | .flags = INET6_PROTO_NOPOLICY, | 533 | .flags = INET6_PROTO_NOPOLICY, |
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index 678bb95b1525..af597c73ebe9 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c | |||
@@ -558,7 +558,7 @@ static const struct xfrm_type esp6_type = | |||
558 | .hdr_offset = xfrm6_find_1stfragopt, | 558 | .hdr_offset = xfrm6_find_1stfragopt, |
559 | }; | 559 | }; |
560 | 560 | ||
561 | static struct inet6_protocol esp6_protocol = { | 561 | static const struct inet6_protocol esp6_protocol = { |
562 | .handler = xfrm6_rcv, | 562 | .handler = xfrm6_rcv, |
563 | .err_handler = esp6_err, | 563 | .err_handler = esp6_err, |
564 | .flags = INET6_PROTO_NOPOLICY, | 564 | .flags = INET6_PROTO_NOPOLICY, |
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 4aae658e5501..df159fffe4bc 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c | |||
@@ -500,17 +500,17 @@ unknown_rh: | |||
500 | return -1; | 500 | return -1; |
501 | } | 501 | } |
502 | 502 | ||
503 | static struct inet6_protocol rthdr_protocol = { | 503 | static const struct inet6_protocol rthdr_protocol = { |
504 | .handler = ipv6_rthdr_rcv, | 504 | .handler = ipv6_rthdr_rcv, |
505 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, | 505 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, |
506 | }; | 506 | }; |
507 | 507 | ||
508 | static struct inet6_protocol destopt_protocol = { | 508 | static const struct inet6_protocol destopt_protocol = { |
509 | .handler = ipv6_destopt_rcv, | 509 | .handler = ipv6_destopt_rcv, |
510 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, | 510 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_GSO_EXTHDR, |
511 | }; | 511 | }; |
512 | 512 | ||
513 | static struct inet6_protocol nodata_protocol = { | 513 | static const struct inet6_protocol nodata_protocol = { |
514 | .handler = dst_discard, | 514 | .handler = dst_discard, |
515 | .flags = INET6_PROTO_NOPOLICY, | 515 | .flags = INET6_PROTO_NOPOLICY, |
516 | }; | 516 | }; |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index e2325f6a05fb..f23ebbec0631 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -86,7 +86,7 @@ static inline struct sock *icmpv6_sk(struct net *net) | |||
86 | 86 | ||
87 | static int icmpv6_rcv(struct sk_buff *skb); | 87 | static int icmpv6_rcv(struct sk_buff *skb); |
88 | 88 | ||
89 | static struct inet6_protocol icmpv6_protocol = { | 89 | static const struct inet6_protocol icmpv6_protocol = { |
90 | .handler = icmpv6_rcv, | 90 | .handler = icmpv6_rcv, |
91 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 91 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, |
92 | }; | 92 | }; |
@@ -583,7 +583,7 @@ out: | |||
583 | 583 | ||
584 | static void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info) | 584 | static void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info) |
585 | { | 585 | { |
586 | struct inet6_protocol *ipprot; | 586 | const struct inet6_protocol *ipprot; |
587 | int inner_offset; | 587 | int inner_offset; |
588 | int hash; | 588 | int hash; |
589 | u8 nexthdr; | 589 | u8 nexthdr; |
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c index 2d9cbaa67edb..237e2dba6e94 100644 --- a/net/ipv6/ip6_input.c +++ b/net/ipv6/ip6_input.c | |||
@@ -159,7 +159,7 @@ drop: | |||
159 | 159 | ||
160 | static int ip6_input_finish(struct sk_buff *skb) | 160 | static int ip6_input_finish(struct sk_buff *skb) |
161 | { | 161 | { |
162 | struct inet6_protocol *ipprot; | 162 | const struct inet6_protocol *ipprot; |
163 | unsigned int nhoff; | 163 | unsigned int nhoff; |
164 | int nexthdr, raw; | 164 | int nexthdr, raw; |
165 | u8 hash; | 165 | u8 hash; |
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c index 5c8d73730c75..3907510c2ce3 100644 --- a/net/ipv6/ip6mr.c +++ b/net/ipv6/ip6mr.c | |||
@@ -83,10 +83,6 @@ static int ip6mr_cache_report(struct net *net, struct sk_buff *pkt, | |||
83 | static int ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm); | 83 | static int ip6mr_fill_mroute(struct sk_buff *skb, struct mfc6_cache *c, struct rtmsg *rtm); |
84 | static void mroute_clean_tables(struct net *net); | 84 | static void mroute_clean_tables(struct net *net); |
85 | 85 | ||
86 | #ifdef CONFIG_IPV6_PIMSM_V2 | ||
87 | static struct inet6_protocol pim6_protocol; | ||
88 | #endif | ||
89 | |||
90 | static struct timer_list ipmr_expire_timer; | 86 | static struct timer_list ipmr_expire_timer; |
91 | 87 | ||
92 | 88 | ||
@@ -410,7 +406,7 @@ static int pim6_rcv(struct sk_buff *skb) | |||
410 | return 0; | 406 | return 0; |
411 | } | 407 | } |
412 | 408 | ||
413 | static struct inet6_protocol pim6_protocol = { | 409 | static const struct inet6_protocol pim6_protocol = { |
414 | .handler = pim6_rcv, | 410 | .handler = pim6_rcv, |
415 | }; | 411 | }; |
416 | 412 | ||
diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c index 79c172f1ff01..2f2a5ca2c878 100644 --- a/net/ipv6/ipcomp6.c +++ b/net/ipv6/ipcomp6.c | |||
@@ -178,7 +178,7 @@ static const struct xfrm_type ipcomp6_type = | |||
178 | .hdr_offset = xfrm6_find_1stfragopt, | 178 | .hdr_offset = xfrm6_find_1stfragopt, |
179 | }; | 179 | }; |
180 | 180 | ||
181 | static struct inet6_protocol ipcomp6_protocol = | 181 | static const struct inet6_protocol ipcomp6_protocol = |
182 | { | 182 | { |
183 | .handler = xfrm6_rcv, | 183 | .handler = xfrm6_rcv, |
184 | .err_handler = ipcomp6_err, | 184 | .err_handler = ipcomp6_err, |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 71c3dacec1ed..f9fcf690bd5d 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -2249,6 +2249,25 @@ static void igmp6_timer_handler(unsigned long data) | |||
2249 | ma_put(ma); | 2249 | ma_put(ma); |
2250 | } | 2250 | } |
2251 | 2251 | ||
2252 | /* Device changing type */ | ||
2253 | |||
2254 | void ipv6_mc_unmap(struct inet6_dev *idev) | ||
2255 | { | ||
2256 | struct ifmcaddr6 *i; | ||
2257 | |||
2258 | /* Install multicast list, except for all-nodes (already installed) */ | ||
2259 | |||
2260 | read_lock_bh(&idev->lock); | ||
2261 | for (i = idev->mc_list; i; i = i->next) | ||
2262 | igmp6_group_dropped(i); | ||
2263 | read_unlock_bh(&idev->lock); | ||
2264 | } | ||
2265 | |||
2266 | void ipv6_mc_remap(struct inet6_dev *idev) | ||
2267 | { | ||
2268 | ipv6_mc_up(idev); | ||
2269 | } | ||
2270 | |||
2252 | /* Device going down */ | 2271 | /* Device going down */ |
2253 | 2272 | ||
2254 | void ipv6_mc_down(struct inet6_dev *idev) | 2273 | void ipv6_mc_down(struct inet6_dev *idev) |
diff --git a/net/ipv6/protocol.c b/net/ipv6/protocol.c index 568864f722ca..1fa3468f0f32 100644 --- a/net/ipv6/protocol.c +++ b/net/ipv6/protocol.c | |||
@@ -25,11 +25,11 @@ | |||
25 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
26 | #include <net/protocol.h> | 26 | #include <net/protocol.h> |
27 | 27 | ||
28 | struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; | 28 | const struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; |
29 | static DEFINE_SPINLOCK(inet6_proto_lock); | 29 | static DEFINE_SPINLOCK(inet6_proto_lock); |
30 | 30 | ||
31 | 31 | ||
32 | int inet6_add_protocol(struct inet6_protocol *prot, unsigned char protocol) | 32 | int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char protocol) |
33 | { | 33 | { |
34 | int ret, hash = protocol & (MAX_INET_PROTOS - 1); | 34 | int ret, hash = protocol & (MAX_INET_PROTOS - 1); |
35 | 35 | ||
@@ -53,7 +53,7 @@ EXPORT_SYMBOL(inet6_add_protocol); | |||
53 | * Remove a protocol from the hash tables. | 53 | * Remove a protocol from the hash tables. |
54 | */ | 54 | */ |
55 | 55 | ||
56 | int inet6_del_protocol(struct inet6_protocol *prot, unsigned char protocol) | 56 | int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char protocol) |
57 | { | 57 | { |
58 | int ret, hash = protocol & (MAX_INET_PROTOS - 1); | 58 | int ret, hash = protocol & (MAX_INET_PROTOS - 1); |
59 | 59 | ||
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 2642a41a8535..da5bd0ed83df 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c | |||
@@ -627,7 +627,7 @@ fail_hdr: | |||
627 | return -1; | 627 | return -1; |
628 | } | 628 | } |
629 | 629 | ||
630 | static struct inet6_protocol frag_protocol = | 630 | static const struct inet6_protocol frag_protocol = |
631 | { | 631 | { |
632 | .handler = ipv6_frag_rcv, | 632 | .handler = ipv6_frag_rcv, |
633 | .flags = INET6_PROTO_NOPOLICY, | 633 | .flags = INET6_PROTO_NOPOLICY, |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 9ccfef345560..77aecbe8ff6c 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -481,7 +481,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, | |||
481 | 481 | ||
482 | pref = rinfo->route_pref; | 482 | pref = rinfo->route_pref; |
483 | if (pref == ICMPV6_ROUTER_PREF_INVALID) | 483 | if (pref == ICMPV6_ROUTER_PREF_INVALID) |
484 | pref = ICMPV6_ROUTER_PREF_MEDIUM; | 484 | return -EINVAL; |
485 | 485 | ||
486 | lifetime = addrconf_timeout_fixup(ntohl(rinfo->lifetime), HZ); | 486 | lifetime = addrconf_timeout_fixup(ntohl(rinfo->lifetime), HZ); |
487 | 487 | ||
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 3aae0f217d61..21d100b68b19 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -1846,7 +1846,7 @@ static int tcp_v6_init_sock(struct sock *sk) | |||
1846 | /* See draft-stevens-tcpca-spec-01 for discussion of the | 1846 | /* See draft-stevens-tcpca-spec-01 for discussion of the |
1847 | * initialization of these values. | 1847 | * initialization of these values. |
1848 | */ | 1848 | */ |
1849 | tp->snd_ssthresh = 0x7fffffff; | 1849 | tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; |
1850 | tp->snd_cwnd_clamp = ~0; | 1850 | tp->snd_cwnd_clamp = ~0; |
1851 | tp->mss_cache = 536; | 1851 | tp->mss_cache = 536; |
1852 | 1852 | ||
@@ -1969,7 +1969,8 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i) | |||
1969 | jiffies_to_clock_t(icsk->icsk_rto), | 1969 | jiffies_to_clock_t(icsk->icsk_rto), |
1970 | jiffies_to_clock_t(icsk->icsk_ack.ato), | 1970 | jiffies_to_clock_t(icsk->icsk_ack.ato), |
1971 | (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong, | 1971 | (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong, |
1972 | tp->snd_cwnd, tp->snd_ssthresh>=0xFFFF?-1:tp->snd_ssthresh | 1972 | tp->snd_cwnd, |
1973 | tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh | ||
1973 | ); | 1974 | ); |
1974 | } | 1975 | } |
1975 | 1976 | ||
@@ -2093,7 +2094,7 @@ struct proto tcpv6_prot = { | |||
2093 | #endif | 2094 | #endif |
2094 | }; | 2095 | }; |
2095 | 2096 | ||
2096 | static struct inet6_protocol tcpv6_protocol = { | 2097 | static const struct inet6_protocol tcpv6_protocol = { |
2097 | .handler = tcp_v6_rcv, | 2098 | .handler = tcp_v6_rcv, |
2098 | .err_handler = tcp_v6_err, | 2099 | .err_handler = tcp_v6_err, |
2099 | .gso_send_check = tcp_v6_gso_send_check, | 2100 | .gso_send_check = tcp_v6_gso_send_check, |
diff --git a/net/ipv6/tunnel6.c b/net/ipv6/tunnel6.c index 633ad789effc..51e2832d13a6 100644 --- a/net/ipv6/tunnel6.c +++ b/net/ipv6/tunnel6.c | |||
@@ -133,13 +133,13 @@ static void tunnel6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
133 | break; | 133 | break; |
134 | } | 134 | } |
135 | 135 | ||
136 | static struct inet6_protocol tunnel6_protocol = { | 136 | static const struct inet6_protocol tunnel6_protocol = { |
137 | .handler = tunnel6_rcv, | 137 | .handler = tunnel6_rcv, |
138 | .err_handler = tunnel6_err, | 138 | .err_handler = tunnel6_err, |
139 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 139 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, |
140 | }; | 140 | }; |
141 | 141 | ||
142 | static struct inet6_protocol tunnel46_protocol = { | 142 | static const struct inet6_protocol tunnel46_protocol = { |
143 | .handler = tunnel46_rcv, | 143 | .handler = tunnel46_rcv, |
144 | .err_handler = tunnel6_err, | 144 | .err_handler = tunnel6_err, |
145 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 145 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 164040613c2e..b265b7047d3e 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -1172,7 +1172,7 @@ out: | |||
1172 | return segs; | 1172 | return segs; |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | static struct inet6_protocol udpv6_protocol = { | 1175 | static const struct inet6_protocol udpv6_protocol = { |
1176 | .handler = udpv6_rcv, | 1176 | .handler = udpv6_rcv, |
1177 | .err_handler = udpv6_err, | 1177 | .err_handler = udpv6_err, |
1178 | .gso_send_check = udp6_ufo_send_check, | 1178 | .gso_send_check = udp6_ufo_send_check, |
diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 4818c48688f2..d737a27ee010 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c | |||
@@ -25,7 +25,7 @@ static void udplitev6_err(struct sk_buff *skb, | |||
25 | __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table); | 25 | __udp6_lib_err(skb, opt, type, code, offset, info, &udplite_table); |
26 | } | 26 | } |
27 | 27 | ||
28 | static struct inet6_protocol udplitev6_protocol = { | 28 | static const struct inet6_protocol udplitev6_protocol = { |
29 | .handler = udplitev6_rcv, | 29 | .handler = udplitev6_rcv, |
30 | .err_handler = udplitev6_err, | 30 | .err_handler = udplitev6_err, |
31 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 31 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, |
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 49c15b48408e..d985d163dcfc 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c | |||
@@ -34,7 +34,7 @@ | |||
34 | 34 | ||
35 | static char iucv_userid[80]; | 35 | static char iucv_userid[80]; |
36 | 36 | ||
37 | static struct proto_ops iucv_sock_ops; | 37 | static const struct proto_ops iucv_sock_ops; |
38 | 38 | ||
39 | static struct proto iucv_proto = { | 39 | static struct proto iucv_proto = { |
40 | .name = "AF_IUCV", | 40 | .name = "AF_IUCV", |
@@ -59,8 +59,8 @@ do { \ | |||
59 | DEFINE_WAIT(__wait); \ | 59 | DEFINE_WAIT(__wait); \ |
60 | long __timeo = timeo; \ | 60 | long __timeo = timeo; \ |
61 | ret = 0; \ | 61 | ret = 0; \ |
62 | prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \ | ||
62 | while (!(condition)) { \ | 63 | while (!(condition)) { \ |
63 | prepare_to_wait(sk->sk_sleep, &__wait, TASK_INTERRUPTIBLE); \ | ||
64 | if (!__timeo) { \ | 64 | if (!__timeo) { \ |
65 | ret = -EAGAIN; \ | 65 | ret = -EAGAIN; \ |
66 | break; \ | 66 | break; \ |
@@ -361,10 +361,9 @@ static void iucv_sock_cleanup_listen(struct sock *parent) | |||
361 | } | 361 | } |
362 | 362 | ||
363 | parent->sk_state = IUCV_CLOSED; | 363 | parent->sk_state = IUCV_CLOSED; |
364 | sock_set_flag(parent, SOCK_ZAPPED); | ||
365 | } | 364 | } |
366 | 365 | ||
367 | /* Kill socket */ | 366 | /* Kill socket (only if zapped and orphaned) */ |
368 | static void iucv_sock_kill(struct sock *sk) | 367 | static void iucv_sock_kill(struct sock *sk) |
369 | { | 368 | { |
370 | if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) | 369 | if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket) |
@@ -426,17 +425,18 @@ static void iucv_sock_close(struct sock *sk) | |||
426 | 425 | ||
427 | skb_queue_purge(&iucv->send_skb_q); | 426 | skb_queue_purge(&iucv->send_skb_q); |
428 | skb_queue_purge(&iucv->backlog_skb_q); | 427 | skb_queue_purge(&iucv->backlog_skb_q); |
429 | |||
430 | sock_set_flag(sk, SOCK_ZAPPED); | ||
431 | break; | 428 | break; |
432 | 429 | ||
433 | default: | 430 | default: |
434 | sock_set_flag(sk, SOCK_ZAPPED); | 431 | sock_set_flag(sk, SOCK_ZAPPED); |
432 | /* nothing to do here */ | ||
435 | break; | 433 | break; |
436 | } | 434 | } |
437 | 435 | ||
436 | /* mark socket for deletion by iucv_sock_kill() */ | ||
437 | sock_set_flag(sk, SOCK_ZAPPED); | ||
438 | |||
438 | release_sock(sk); | 439 | release_sock(sk); |
439 | iucv_sock_kill(sk); | ||
440 | } | 440 | } |
441 | 441 | ||
442 | static void iucv_sock_init(struct sock *sk, struct sock *parent) | 442 | static void iucv_sock_init(struct sock *sk, struct sock *parent) |
@@ -569,6 +569,7 @@ struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock) | |||
569 | 569 | ||
570 | if (sk->sk_state == IUCV_CONNECTED || | 570 | if (sk->sk_state == IUCV_CONNECTED || |
571 | sk->sk_state == IUCV_SEVERED || | 571 | sk->sk_state == IUCV_SEVERED || |
572 | sk->sk_state == IUCV_DISCONN || /* due to PM restore */ | ||
572 | !newsock) { | 573 | !newsock) { |
573 | iucv_accept_unlink(sk); | 574 | iucv_accept_unlink(sk); |
574 | if (newsock) | 575 | if (newsock) |
@@ -1035,6 +1036,10 @@ out: | |||
1035 | return err; | 1036 | return err; |
1036 | } | 1037 | } |
1037 | 1038 | ||
1039 | /* iucv_fragment_skb() - Fragment a single IUCV message into multiple skb's | ||
1040 | * | ||
1041 | * Locking: must be called with message_q.lock held | ||
1042 | */ | ||
1038 | static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len) | 1043 | static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len) |
1039 | { | 1044 | { |
1040 | int dataleft, size, copied = 0; | 1045 | int dataleft, size, copied = 0; |
@@ -1069,6 +1074,10 @@ static int iucv_fragment_skb(struct sock *sk, struct sk_buff *skb, int len) | |||
1069 | return 0; | 1074 | return 0; |
1070 | } | 1075 | } |
1071 | 1076 | ||
1077 | /* iucv_process_message() - Receive a single outstanding IUCV message | ||
1078 | * | ||
1079 | * Locking: must be called with message_q.lock held | ||
1080 | */ | ||
1072 | static void iucv_process_message(struct sock *sk, struct sk_buff *skb, | 1081 | static void iucv_process_message(struct sock *sk, struct sk_buff *skb, |
1073 | struct iucv_path *path, | 1082 | struct iucv_path *path, |
1074 | struct iucv_message *msg) | 1083 | struct iucv_message *msg) |
@@ -1119,6 +1128,10 @@ static void iucv_process_message(struct sock *sk, struct sk_buff *skb, | |||
1119 | skb_queue_head(&iucv_sk(sk)->backlog_skb_q, skb); | 1128 | skb_queue_head(&iucv_sk(sk)->backlog_skb_q, skb); |
1120 | } | 1129 | } |
1121 | 1130 | ||
1131 | /* iucv_process_message_q() - Process outstanding IUCV messages | ||
1132 | * | ||
1133 | * Locking: must be called with message_q.lock held | ||
1134 | */ | ||
1122 | static void iucv_process_message_q(struct sock *sk) | 1135 | static void iucv_process_message_q(struct sock *sk) |
1123 | { | 1136 | { |
1124 | struct iucv_sock *iucv = iucv_sk(sk); | 1137 | struct iucv_sock *iucv = iucv_sk(sk); |
@@ -1209,6 +1222,7 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1209 | kfree_skb(skb); | 1222 | kfree_skb(skb); |
1210 | 1223 | ||
1211 | /* Queue backlog skbs */ | 1224 | /* Queue backlog skbs */ |
1225 | spin_lock_bh(&iucv->message_q.lock); | ||
1212 | rskb = skb_dequeue(&iucv->backlog_skb_q); | 1226 | rskb = skb_dequeue(&iucv->backlog_skb_q); |
1213 | while (rskb) { | 1227 | while (rskb) { |
1214 | if (sock_queue_rcv_skb(sk, rskb)) { | 1228 | if (sock_queue_rcv_skb(sk, rskb)) { |
@@ -1220,11 +1234,10 @@ static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1220 | } | 1234 | } |
1221 | } | 1235 | } |
1222 | if (skb_queue_empty(&iucv->backlog_skb_q)) { | 1236 | if (skb_queue_empty(&iucv->backlog_skb_q)) { |
1223 | spin_lock_bh(&iucv->message_q.lock); | ||
1224 | if (!list_empty(&iucv->message_q.list)) | 1237 | if (!list_empty(&iucv->message_q.list)) |
1225 | iucv_process_message_q(sk); | 1238 | iucv_process_message_q(sk); |
1226 | spin_unlock_bh(&iucv->message_q.lock); | ||
1227 | } | 1239 | } |
1240 | spin_unlock_bh(&iucv->message_q.lock); | ||
1228 | } | 1241 | } |
1229 | 1242 | ||
1230 | done: | 1243 | done: |
@@ -1682,7 +1695,7 @@ static void iucv_callback_shutdown(struct iucv_path *path, u8 ipuser[16]) | |||
1682 | bh_unlock_sock(sk); | 1695 | bh_unlock_sock(sk); |
1683 | } | 1696 | } |
1684 | 1697 | ||
1685 | static struct proto_ops iucv_sock_ops = { | 1698 | static const struct proto_ops iucv_sock_ops = { |
1686 | .family = PF_IUCV, | 1699 | .family = PF_IUCV, |
1687 | .owner = THIS_MODULE, | 1700 | .owner = THIS_MODULE, |
1688 | .release = iucv_sock_release, | 1701 | .release = iucv_sock_release, |
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index c833481d32e3..3973d0e61e56 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c | |||
@@ -79,6 +79,14 @@ static int iucv_bus_match(struct device *dev, struct device_driver *drv) | |||
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | 81 | ||
82 | enum iucv_pm_states { | ||
83 | IUCV_PM_INITIAL = 0, | ||
84 | IUCV_PM_FREEZING = 1, | ||
85 | IUCV_PM_THAWING = 2, | ||
86 | IUCV_PM_RESTORING = 3, | ||
87 | }; | ||
88 | static enum iucv_pm_states iucv_pm_state; | ||
89 | |||
82 | static int iucv_pm_prepare(struct device *); | 90 | static int iucv_pm_prepare(struct device *); |
83 | static void iucv_pm_complete(struct device *); | 91 | static void iucv_pm_complete(struct device *); |
84 | static int iucv_pm_freeze(struct device *); | 92 | static int iucv_pm_freeze(struct device *); |
@@ -354,7 +362,7 @@ static int iucv_query_maxconn(void) | |||
354 | " srl %0,28\n" | 362 | " srl %0,28\n" |
355 | : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc"); | 363 | : "=d" (ccode), "+d" (reg0), "+d" (reg1) : : "cc"); |
356 | if (ccode == 0) | 364 | if (ccode == 0) |
357 | iucv_max_pathid = reg0; | 365 | iucv_max_pathid = reg1; |
358 | kfree(param); | 366 | kfree(param); |
359 | return ccode ? -EPERM : 0; | 367 | return ccode ? -EPERM : 0; |
360 | } | 368 | } |
@@ -856,7 +864,7 @@ int iucv_path_accept(struct iucv_path *path, struct iucv_handler *handler, | |||
856 | int rc; | 864 | int rc; |
857 | 865 | ||
858 | local_bh_disable(); | 866 | local_bh_disable(); |
859 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 867 | if (cpus_empty(iucv_buffer_cpumask)) { |
860 | rc = -EIO; | 868 | rc = -EIO; |
861 | goto out; | 869 | goto out; |
862 | } | 870 | } |
@@ -905,7 +913,7 @@ int iucv_path_connect(struct iucv_path *path, struct iucv_handler *handler, | |||
905 | 913 | ||
906 | spin_lock_bh(&iucv_table_lock); | 914 | spin_lock_bh(&iucv_table_lock); |
907 | iucv_cleanup_queue(); | 915 | iucv_cleanup_queue(); |
908 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 916 | if (cpus_empty(iucv_buffer_cpumask)) { |
909 | rc = -EIO; | 917 | rc = -EIO; |
910 | goto out; | 918 | goto out; |
911 | } | 919 | } |
@@ -965,7 +973,7 @@ int iucv_path_quiesce(struct iucv_path *path, u8 userdata[16]) | |||
965 | int rc; | 973 | int rc; |
966 | 974 | ||
967 | local_bh_disable(); | 975 | local_bh_disable(); |
968 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 976 | if (cpus_empty(iucv_buffer_cpumask)) { |
969 | rc = -EIO; | 977 | rc = -EIO; |
970 | goto out; | 978 | goto out; |
971 | } | 979 | } |
@@ -997,7 +1005,7 @@ int iucv_path_resume(struct iucv_path *path, u8 userdata[16]) | |||
997 | int rc; | 1005 | int rc; |
998 | 1006 | ||
999 | local_bh_disable(); | 1007 | local_bh_disable(); |
1000 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1008 | if (cpus_empty(iucv_buffer_cpumask)) { |
1001 | rc = -EIO; | 1009 | rc = -EIO; |
1002 | goto out; | 1010 | goto out; |
1003 | } | 1011 | } |
@@ -1026,7 +1034,7 @@ int iucv_path_sever(struct iucv_path *path, u8 userdata[16]) | |||
1026 | int rc; | 1034 | int rc; |
1027 | 1035 | ||
1028 | preempt_disable(); | 1036 | preempt_disable(); |
1029 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1037 | if (cpus_empty(iucv_buffer_cpumask)) { |
1030 | rc = -EIO; | 1038 | rc = -EIO; |
1031 | goto out; | 1039 | goto out; |
1032 | } | 1040 | } |
@@ -1060,7 +1068,7 @@ int iucv_message_purge(struct iucv_path *path, struct iucv_message *msg, | |||
1060 | int rc; | 1068 | int rc; |
1061 | 1069 | ||
1062 | local_bh_disable(); | 1070 | local_bh_disable(); |
1063 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1071 | if (cpus_empty(iucv_buffer_cpumask)) { |
1064 | rc = -EIO; | 1072 | rc = -EIO; |
1065 | goto out; | 1073 | goto out; |
1066 | } | 1074 | } |
@@ -1152,7 +1160,7 @@ int __iucv_message_receive(struct iucv_path *path, struct iucv_message *msg, | |||
1152 | if (msg->flags & IUCV_IPRMDATA) | 1160 | if (msg->flags & IUCV_IPRMDATA) |
1153 | return iucv_message_receive_iprmdata(path, msg, flags, | 1161 | return iucv_message_receive_iprmdata(path, msg, flags, |
1154 | buffer, size, residual); | 1162 | buffer, size, residual); |
1155 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1163 | if (cpus_empty(iucv_buffer_cpumask)) { |
1156 | rc = -EIO; | 1164 | rc = -EIO; |
1157 | goto out; | 1165 | goto out; |
1158 | } | 1166 | } |
@@ -1225,7 +1233,7 @@ int iucv_message_reject(struct iucv_path *path, struct iucv_message *msg) | |||
1225 | int rc; | 1233 | int rc; |
1226 | 1234 | ||
1227 | local_bh_disable(); | 1235 | local_bh_disable(); |
1228 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1236 | if (cpus_empty(iucv_buffer_cpumask)) { |
1229 | rc = -EIO; | 1237 | rc = -EIO; |
1230 | goto out; | 1238 | goto out; |
1231 | } | 1239 | } |
@@ -1264,7 +1272,7 @@ int iucv_message_reply(struct iucv_path *path, struct iucv_message *msg, | |||
1264 | int rc; | 1272 | int rc; |
1265 | 1273 | ||
1266 | local_bh_disable(); | 1274 | local_bh_disable(); |
1267 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1275 | if (cpus_empty(iucv_buffer_cpumask)) { |
1268 | rc = -EIO; | 1276 | rc = -EIO; |
1269 | goto out; | 1277 | goto out; |
1270 | } | 1278 | } |
@@ -1314,7 +1322,7 @@ int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg, | |||
1314 | union iucv_param *parm; | 1322 | union iucv_param *parm; |
1315 | int rc; | 1323 | int rc; |
1316 | 1324 | ||
1317 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1325 | if (cpus_empty(iucv_buffer_cpumask)) { |
1318 | rc = -EIO; | 1326 | rc = -EIO; |
1319 | goto out; | 1327 | goto out; |
1320 | } | 1328 | } |
@@ -1401,7 +1409,7 @@ int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg, | |||
1401 | int rc; | 1409 | int rc; |
1402 | 1410 | ||
1403 | local_bh_disable(); | 1411 | local_bh_disable(); |
1404 | if (!cpu_isset(smp_processor_id(), iucv_buffer_cpumask)) { | 1412 | if (cpus_empty(iucv_buffer_cpumask)) { |
1405 | rc = -EIO; | 1413 | rc = -EIO; |
1406 | goto out; | 1414 | goto out; |
1407 | } | 1415 | } |
@@ -1875,6 +1883,7 @@ static int iucv_pm_freeze(struct device *dev) | |||
1875 | #ifdef CONFIG_PM_DEBUG | 1883 | #ifdef CONFIG_PM_DEBUG |
1876 | printk(KERN_WARNING "iucv_pm_freeze\n"); | 1884 | printk(KERN_WARNING "iucv_pm_freeze\n"); |
1877 | #endif | 1885 | #endif |
1886 | iucv_pm_state = IUCV_PM_FREEZING; | ||
1878 | for_each_cpu_mask_nr(cpu, iucv_irq_cpumask) | 1887 | for_each_cpu_mask_nr(cpu, iucv_irq_cpumask) |
1879 | smp_call_function_single(cpu, iucv_block_cpu_almost, NULL, 1); | 1888 | smp_call_function_single(cpu, iucv_block_cpu_almost, NULL, 1); |
1880 | if (dev->driver && dev->driver->pm && dev->driver->pm->freeze) | 1889 | if (dev->driver && dev->driver->pm && dev->driver->pm->freeze) |
@@ -1899,6 +1908,7 @@ static int iucv_pm_thaw(struct device *dev) | |||
1899 | #ifdef CONFIG_PM_DEBUG | 1908 | #ifdef CONFIG_PM_DEBUG |
1900 | printk(KERN_WARNING "iucv_pm_thaw\n"); | 1909 | printk(KERN_WARNING "iucv_pm_thaw\n"); |
1901 | #endif | 1910 | #endif |
1911 | iucv_pm_state = IUCV_PM_THAWING; | ||
1902 | if (!iucv_path_table) { | 1912 | if (!iucv_path_table) { |
1903 | rc = iucv_enable(); | 1913 | rc = iucv_enable(); |
1904 | if (rc) | 1914 | if (rc) |
@@ -1933,6 +1943,10 @@ static int iucv_pm_restore(struct device *dev) | |||
1933 | #ifdef CONFIG_PM_DEBUG | 1943 | #ifdef CONFIG_PM_DEBUG |
1934 | printk(KERN_WARNING "iucv_pm_restore %p\n", iucv_path_table); | 1944 | printk(KERN_WARNING "iucv_pm_restore %p\n", iucv_path_table); |
1935 | #endif | 1945 | #endif |
1946 | if ((iucv_pm_state != IUCV_PM_RESTORING) && iucv_path_table) | ||
1947 | pr_warning("Suspending Linux did not completely close all IUCV " | ||
1948 | "connections\n"); | ||
1949 | iucv_pm_state = IUCV_PM_RESTORING; | ||
1936 | if (cpus_empty(iucv_irq_cpumask)) { | 1950 | if (cpus_empty(iucv_irq_cpumask)) { |
1937 | rc = iucv_query_maxconn(); | 1951 | rc = iucv_query_maxconn(); |
1938 | rc = iucv_enable(); | 1952 | rc = iucv_enable(); |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index d0ff382c40ca..c5aab6a368ce 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -177,9 +177,11 @@ static void netlink_sock_destruct(struct sock *sk) | |||
177 | * this, _but_ remember, it adds useless work on UP machines. | 177 | * this, _but_ remember, it adds useless work on UP machines. |
178 | */ | 178 | */ |
179 | 179 | ||
180 | static void netlink_table_grab(void) | 180 | void netlink_table_grab(void) |
181 | __acquires(nl_table_lock) | 181 | __acquires(nl_table_lock) |
182 | { | 182 | { |
183 | might_sleep(); | ||
184 | |||
183 | write_lock_irq(&nl_table_lock); | 185 | write_lock_irq(&nl_table_lock); |
184 | 186 | ||
185 | if (atomic_read(&nl_table_users)) { | 187 | if (atomic_read(&nl_table_users)) { |
@@ -200,7 +202,7 @@ static void netlink_table_grab(void) | |||
200 | } | 202 | } |
201 | } | 203 | } |
202 | 204 | ||
203 | static void netlink_table_ungrab(void) | 205 | void netlink_table_ungrab(void) |
204 | __releases(nl_table_lock) | 206 | __releases(nl_table_lock) |
205 | { | 207 | { |
206 | write_unlock_irq(&nl_table_lock); | 208 | write_unlock_irq(&nl_table_lock); |
@@ -1549,37 +1551,21 @@ static void netlink_free_old_listeners(struct rcu_head *rcu_head) | |||
1549 | kfree(lrh->ptr); | 1551 | kfree(lrh->ptr); |
1550 | } | 1552 | } |
1551 | 1553 | ||
1552 | /** | 1554 | int __netlink_change_ngroups(struct sock *sk, unsigned int groups) |
1553 | * netlink_change_ngroups - change number of multicast groups | ||
1554 | * | ||
1555 | * This changes the number of multicast groups that are available | ||
1556 | * on a certain netlink family. Note that it is not possible to | ||
1557 | * change the number of groups to below 32. Also note that it does | ||
1558 | * not implicitly call netlink_clear_multicast_users() when the | ||
1559 | * number of groups is reduced. | ||
1560 | * | ||
1561 | * @sk: The kernel netlink socket, as returned by netlink_kernel_create(). | ||
1562 | * @groups: The new number of groups. | ||
1563 | */ | ||
1564 | int netlink_change_ngroups(struct sock *sk, unsigned int groups) | ||
1565 | { | 1555 | { |
1566 | unsigned long *listeners, *old = NULL; | 1556 | unsigned long *listeners, *old = NULL; |
1567 | struct listeners_rcu_head *old_rcu_head; | 1557 | struct listeners_rcu_head *old_rcu_head; |
1568 | struct netlink_table *tbl = &nl_table[sk->sk_protocol]; | 1558 | struct netlink_table *tbl = &nl_table[sk->sk_protocol]; |
1569 | int err = 0; | ||
1570 | 1559 | ||
1571 | if (groups < 32) | 1560 | if (groups < 32) |
1572 | groups = 32; | 1561 | groups = 32; |
1573 | 1562 | ||
1574 | netlink_table_grab(); | ||
1575 | if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) { | 1563 | if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) { |
1576 | listeners = kzalloc(NLGRPSZ(groups) + | 1564 | listeners = kzalloc(NLGRPSZ(groups) + |
1577 | sizeof(struct listeners_rcu_head), | 1565 | sizeof(struct listeners_rcu_head), |
1578 | GFP_ATOMIC); | 1566 | GFP_ATOMIC); |
1579 | if (!listeners) { | 1567 | if (!listeners) |
1580 | err = -ENOMEM; | 1568 | return -ENOMEM; |
1581 | goto out_ungrab; | ||
1582 | } | ||
1583 | old = tbl->listeners; | 1569 | old = tbl->listeners; |
1584 | memcpy(listeners, old, NLGRPSZ(tbl->groups)); | 1570 | memcpy(listeners, old, NLGRPSZ(tbl->groups)); |
1585 | rcu_assign_pointer(tbl->listeners, listeners); | 1571 | rcu_assign_pointer(tbl->listeners, listeners); |
@@ -1597,8 +1583,29 @@ int netlink_change_ngroups(struct sock *sk, unsigned int groups) | |||
1597 | } | 1583 | } |
1598 | tbl->groups = groups; | 1584 | tbl->groups = groups; |
1599 | 1585 | ||
1600 | out_ungrab: | 1586 | return 0; |
1587 | } | ||
1588 | |||
1589 | /** | ||
1590 | * netlink_change_ngroups - change number of multicast groups | ||
1591 | * | ||
1592 | * This changes the number of multicast groups that are available | ||
1593 | * on a certain netlink family. Note that it is not possible to | ||
1594 | * change the number of groups to below 32. Also note that it does | ||
1595 | * not implicitly call netlink_clear_multicast_users() when the | ||
1596 | * number of groups is reduced. | ||
1597 | * | ||
1598 | * @sk: The kernel netlink socket, as returned by netlink_kernel_create(). | ||
1599 | * @groups: The new number of groups. | ||
1600 | */ | ||
1601 | int netlink_change_ngroups(struct sock *sk, unsigned int groups) | ||
1602 | { | ||
1603 | int err; | ||
1604 | |||
1605 | netlink_table_grab(); | ||
1606 | err = __netlink_change_ngroups(sk, groups); | ||
1601 | netlink_table_ungrab(); | 1607 | netlink_table_ungrab(); |
1608 | |||
1602 | return err; | 1609 | return err; |
1603 | } | 1610 | } |
1604 | 1611 | ||
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 66f6ba0bab11..566941e03363 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -176,9 +176,10 @@ int genl_register_mc_group(struct genl_family *family, | |||
176 | if (family->netnsok) { | 176 | if (family->netnsok) { |
177 | struct net *net; | 177 | struct net *net; |
178 | 178 | ||
179 | netlink_table_grab(); | ||
179 | rcu_read_lock(); | 180 | rcu_read_lock(); |
180 | for_each_net_rcu(net) { | 181 | for_each_net_rcu(net) { |
181 | err = netlink_change_ngroups(net->genl_sock, | 182 | err = __netlink_change_ngroups(net->genl_sock, |
182 | mc_groups_longs * BITS_PER_LONG); | 183 | mc_groups_longs * BITS_PER_LONG); |
183 | if (err) { | 184 | if (err) { |
184 | /* | 185 | /* |
@@ -188,10 +189,12 @@ int genl_register_mc_group(struct genl_family *family, | |||
188 | * increased on some sockets which is ok. | 189 | * increased on some sockets which is ok. |
189 | */ | 190 | */ |
190 | rcu_read_unlock(); | 191 | rcu_read_unlock(); |
192 | netlink_table_ungrab(); | ||
191 | goto out; | 193 | goto out; |
192 | } | 194 | } |
193 | } | 195 | } |
194 | rcu_read_unlock(); | 196 | rcu_read_unlock(); |
197 | netlink_table_ungrab(); | ||
195 | } else { | 198 | } else { |
196 | err = netlink_change_ngroups(init_net.genl_sock, | 199 | err = netlink_change_ngroups(init_net.genl_sock, |
197 | mc_groups_longs * BITS_PER_LONG); | 200 | mc_groups_longs * BITS_PER_LONG); |
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index 2f65dcaed2fb..5f42f30dd168 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c | |||
@@ -209,7 +209,14 @@ static int phonet_device_autoconf(struct net_device *dev) | |||
209 | SIOCPNGAUTOCONF); | 209 | SIOCPNGAUTOCONF); |
210 | if (ret < 0) | 210 | if (ret < 0) |
211 | return ret; | 211 | return ret; |
212 | return phonet_address_add(dev, req.ifr_phonet_autoconf.device); | 212 | |
213 | ASSERT_RTNL(); | ||
214 | ret = phonet_address_add(dev, req.ifr_phonet_autoconf.device); | ||
215 | if (ret) | ||
216 | return ret; | ||
217 | phonet_address_notify(RTM_NEWADDR, dev, | ||
218 | req.ifr_phonet_autoconf.device); | ||
219 | return 0; | ||
213 | } | 220 | } |
214 | 221 | ||
215 | /* notify Phonet of device events */ | 222 | /* notify Phonet of device events */ |
diff --git a/net/rds/af_rds.c b/net/rds/af_rds.c index 108ed2e671c5..6b58aeff4c7a 100644 --- a/net/rds/af_rds.c +++ b/net/rds/af_rds.c | |||
@@ -359,7 +359,7 @@ static struct proto rds_proto = { | |||
359 | .obj_size = sizeof(struct rds_sock), | 359 | .obj_size = sizeof(struct rds_sock), |
360 | }; | 360 | }; |
361 | 361 | ||
362 | static struct proto_ops rds_proto_ops = { | 362 | static const struct proto_ops rds_proto_ops = { |
363 | .family = AF_RDS, | 363 | .family = AF_RDS, |
364 | .owner = THIS_MODULE, | 364 | .owner = THIS_MODULE, |
365 | .release = rds_release, | 365 | .release = rds_release, |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index e5f478ca3d61..1e166c9685aa 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -63,7 +63,7 @@ int sysctl_rose_window_size = ROSE_DEFAULT_WINDOW_SIZE; | |||
63 | static HLIST_HEAD(rose_list); | 63 | static HLIST_HEAD(rose_list); |
64 | static DEFINE_SPINLOCK(rose_list_lock); | 64 | static DEFINE_SPINLOCK(rose_list_lock); |
65 | 65 | ||
66 | static struct proto_ops rose_proto_ops; | 66 | static const struct proto_ops rose_proto_ops; |
67 | 67 | ||
68 | ax25_address rose_callsign; | 68 | ax25_address rose_callsign; |
69 | 69 | ||
@@ -1515,7 +1515,7 @@ static struct net_proto_family rose_family_ops = { | |||
1515 | .owner = THIS_MODULE, | 1515 | .owner = THIS_MODULE, |
1516 | }; | 1516 | }; |
1517 | 1517 | ||
1518 | static struct proto_ops rose_proto_ops = { | 1518 | static const struct proto_ops rose_proto_ops = { |
1519 | .family = PF_ROSE, | 1519 | .family = PF_ROSE, |
1520 | .owner = THIS_MODULE, | 1520 | .owner = THIS_MODULE, |
1521 | .release = rose_release, | 1521 | .release = rose_release, |
diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c index c9f1f0a3a2ff..b4a220977031 100644 --- a/net/rxrpc/ar-ack.c +++ b/net/rxrpc/ar-ack.c | |||
@@ -40,7 +40,7 @@ static const s8 rxrpc_ack_priority[] = { | |||
40 | /* | 40 | /* |
41 | * propose an ACK be sent | 41 | * propose an ACK be sent |
42 | */ | 42 | */ |
43 | void __rxrpc_propose_ACK(struct rxrpc_call *call, uint8_t ack_reason, | 43 | void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, |
44 | __be32 serial, bool immediate) | 44 | __be32 serial, bool immediate) |
45 | { | 45 | { |
46 | unsigned long expiry; | 46 | unsigned long expiry; |
@@ -120,7 +120,7 @@ cancel_timer: | |||
120 | /* | 120 | /* |
121 | * propose an ACK be sent, locking the call structure | 121 | * propose an ACK be sent, locking the call structure |
122 | */ | 122 | */ |
123 | void rxrpc_propose_ACK(struct rxrpc_call *call, uint8_t ack_reason, | 123 | void rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason, |
124 | __be32 serial, bool immediate) | 124 | __be32 serial, bool immediate) |
125 | { | 125 | { |
126 | s8 prior = rxrpc_ack_priority[ack_reason]; | 126 | s8 prior = rxrpc_ack_priority[ack_reason]; |
@@ -520,7 +520,7 @@ static void rxrpc_zap_tx_window(struct rxrpc_call *call) | |||
520 | struct rxrpc_skb_priv *sp; | 520 | struct rxrpc_skb_priv *sp; |
521 | struct sk_buff *skb; | 521 | struct sk_buff *skb; |
522 | unsigned long _skb, *acks_window; | 522 | unsigned long _skb, *acks_window; |
523 | uint8_t winsz = call->acks_winsz; | 523 | u8 winsz = call->acks_winsz; |
524 | int tail; | 524 | int tail; |
525 | 525 | ||
526 | acks_window = call->acks_window; | 526 | acks_window = call->acks_window; |
diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h index 3e7318c1343c..7043b294bb67 100644 --- a/net/rxrpc/ar-internal.h +++ b/net/rxrpc/ar-internal.h | |||
@@ -229,7 +229,7 @@ struct rxrpc_conn_bundle { | |||
229 | int debug_id; /* debug ID for printks */ | 229 | int debug_id; /* debug ID for printks */ |
230 | unsigned short num_conns; /* number of connections in this bundle */ | 230 | unsigned short num_conns; /* number of connections in this bundle */ |
231 | __be16 service_id; /* service ID */ | 231 | __be16 service_id; /* service ID */ |
232 | uint8_t security_ix; /* security type */ | 232 | u8 security_ix; /* security type */ |
233 | }; | 233 | }; |
234 | 234 | ||
235 | /* | 235 | /* |
@@ -370,10 +370,10 @@ struct rxrpc_call { | |||
370 | u8 channel; /* connection channel occupied by this call */ | 370 | u8 channel; /* connection channel occupied by this call */ |
371 | 371 | ||
372 | /* transmission-phase ACK management */ | 372 | /* transmission-phase ACK management */ |
373 | uint8_t acks_head; /* offset into window of first entry */ | 373 | u8 acks_head; /* offset into window of first entry */ |
374 | uint8_t acks_tail; /* offset into window of last entry */ | 374 | u8 acks_tail; /* offset into window of last entry */ |
375 | uint8_t acks_winsz; /* size of un-ACK'd window */ | 375 | u8 acks_winsz; /* size of un-ACK'd window */ |
376 | uint8_t acks_unacked; /* lowest unacked packet in last ACK received */ | 376 | u8 acks_unacked; /* lowest unacked packet in last ACK received */ |
377 | int acks_latest; /* serial number of latest ACK received */ | 377 | int acks_latest; /* serial number of latest ACK received */ |
378 | rxrpc_seq_t acks_hard; /* highest definitively ACK'd msg seq */ | 378 | rxrpc_seq_t acks_hard; /* highest definitively ACK'd msg seq */ |
379 | unsigned long *acks_window; /* sent packet window | 379 | unsigned long *acks_window; /* sent packet window |
@@ -388,7 +388,7 @@ struct rxrpc_call { | |||
388 | rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */ | 388 | rxrpc_seq_t rx_first_oos; /* first packet in rx_oos_queue (or 0) */ |
389 | rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */ | 389 | rxrpc_seq_t ackr_win_top; /* top of ACK window (rx_data_eaten is bottom) */ |
390 | rxrpc_seq_net_t ackr_prev_seq; /* previous sequence number received */ | 390 | rxrpc_seq_net_t ackr_prev_seq; /* previous sequence number received */ |
391 | uint8_t ackr_reason; /* reason to ACK */ | 391 | u8 ackr_reason; /* reason to ACK */ |
392 | __be32 ackr_serial; /* serial of packet being ACK'd */ | 392 | __be32 ackr_serial; /* serial of packet being ACK'd */ |
393 | atomic_t ackr_not_idle; /* number of packets in Rx queue */ | 393 | atomic_t ackr_not_idle; /* number of packets in Rx queue */ |
394 | 394 | ||
@@ -402,22 +402,6 @@ struct rxrpc_call { | |||
402 | }; | 402 | }; |
403 | 403 | ||
404 | /* | 404 | /* |
405 | * RxRPC key for Kerberos (type-2 security) | ||
406 | */ | ||
407 | struct rxkad_key { | ||
408 | u16 security_index; /* RxRPC header security index */ | ||
409 | u16 ticket_len; /* length of ticket[] */ | ||
410 | u32 expiry; /* time at which expires */ | ||
411 | u32 kvno; /* key version number */ | ||
412 | u8 session_key[8]; /* DES session key */ | ||
413 | u8 ticket[0]; /* the encrypted ticket */ | ||
414 | }; | ||
415 | |||
416 | struct rxrpc_key_payload { | ||
417 | struct rxkad_key k; | ||
418 | }; | ||
419 | |||
420 | /* | ||
421 | * locally abort an RxRPC call | 405 | * locally abort an RxRPC call |
422 | */ | 406 | */ |
423 | static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code) | 407 | static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code) |
@@ -450,8 +434,8 @@ extern int rxrpc_reject_call(struct rxrpc_sock *); | |||
450 | /* | 434 | /* |
451 | * ar-ack.c | 435 | * ar-ack.c |
452 | */ | 436 | */ |
453 | extern void __rxrpc_propose_ACK(struct rxrpc_call *, uint8_t, __be32, bool); | 437 | extern void __rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool); |
454 | extern void rxrpc_propose_ACK(struct rxrpc_call *, uint8_t, __be32, bool); | 438 | extern void rxrpc_propose_ACK(struct rxrpc_call *, u8, __be32, bool); |
455 | extern void rxrpc_process_call(struct work_struct *); | 439 | extern void rxrpc_process_call(struct work_struct *); |
456 | 440 | ||
457 | /* | 441 | /* |
diff --git a/net/rxrpc/ar-key.c b/net/rxrpc/ar-key.c index ad8c7a782da1..74697b200496 100644 --- a/net/rxrpc/ar-key.c +++ b/net/rxrpc/ar-key.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/skbuff.h> | 17 | #include <linux/skbuff.h> |
18 | #include <linux/key-type.h> | 18 | #include <linux/key-type.h> |
19 | #include <linux/crypto.h> | 19 | #include <linux/crypto.h> |
20 | #include <linux/ctype.h> | ||
20 | #include <net/sock.h> | 21 | #include <net/sock.h> |
21 | #include <net/af_rxrpc.h> | 22 | #include <net/af_rxrpc.h> |
22 | #include <keys/rxrpc-type.h> | 23 | #include <keys/rxrpc-type.h> |
@@ -28,6 +29,7 @@ static int rxrpc_instantiate_s(struct key *, const void *, size_t); | |||
28 | static void rxrpc_destroy(struct key *); | 29 | static void rxrpc_destroy(struct key *); |
29 | static void rxrpc_destroy_s(struct key *); | 30 | static void rxrpc_destroy_s(struct key *); |
30 | static void rxrpc_describe(const struct key *, struct seq_file *); | 31 | static void rxrpc_describe(const struct key *, struct seq_file *); |
32 | static long rxrpc_read(const struct key *, char __user *, size_t); | ||
31 | 33 | ||
32 | /* | 34 | /* |
33 | * rxrpc defined keys take an arbitrary string as the description and an | 35 | * rxrpc defined keys take an arbitrary string as the description and an |
@@ -39,6 +41,7 @@ struct key_type key_type_rxrpc = { | |||
39 | .match = user_match, | 41 | .match = user_match, |
40 | .destroy = rxrpc_destroy, | 42 | .destroy = rxrpc_destroy, |
41 | .describe = rxrpc_describe, | 43 | .describe = rxrpc_describe, |
44 | .read = rxrpc_read, | ||
42 | }; | 45 | }; |
43 | EXPORT_SYMBOL(key_type_rxrpc); | 46 | EXPORT_SYMBOL(key_type_rxrpc); |
44 | 47 | ||
@@ -55,6 +58,595 @@ struct key_type key_type_rxrpc_s = { | |||
55 | }; | 58 | }; |
56 | 59 | ||
57 | /* | 60 | /* |
61 | * parse an RxKAD type XDR format token | ||
62 | * - the caller guarantees we have at least 4 words | ||
63 | */ | ||
64 | static int rxrpc_instantiate_xdr_rxkad(struct key *key, const __be32 *xdr, | ||
65 | unsigned toklen) | ||
66 | { | ||
67 | struct rxrpc_key_token *token, **pptoken; | ||
68 | size_t plen; | ||
69 | u32 tktlen; | ||
70 | int ret; | ||
71 | |||
72 | _enter(",{%x,%x,%x,%x},%u", | ||
73 | ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]), | ||
74 | toklen); | ||
75 | |||
76 | if (toklen <= 8 * 4) | ||
77 | return -EKEYREJECTED; | ||
78 | tktlen = ntohl(xdr[7]); | ||
79 | _debug("tktlen: %x", tktlen); | ||
80 | if (tktlen > AFSTOKEN_RK_TIX_MAX) | ||
81 | return -EKEYREJECTED; | ||
82 | if (8 * 4 + tktlen != toklen) | ||
83 | return -EKEYREJECTED; | ||
84 | |||
85 | plen = sizeof(*token) + sizeof(*token->kad) + tktlen; | ||
86 | ret = key_payload_reserve(key, key->datalen + plen); | ||
87 | if (ret < 0) | ||
88 | return ret; | ||
89 | |||
90 | plen -= sizeof(*token); | ||
91 | token = kmalloc(sizeof(*token), GFP_KERNEL); | ||
92 | if (!token) | ||
93 | return -ENOMEM; | ||
94 | |||
95 | token->kad = kmalloc(plen, GFP_KERNEL); | ||
96 | if (!token->kad) { | ||
97 | kfree(token); | ||
98 | return -ENOMEM; | ||
99 | } | ||
100 | |||
101 | token->security_index = RXRPC_SECURITY_RXKAD; | ||
102 | token->kad->ticket_len = tktlen; | ||
103 | token->kad->vice_id = ntohl(xdr[0]); | ||
104 | token->kad->kvno = ntohl(xdr[1]); | ||
105 | token->kad->start = ntohl(xdr[4]); | ||
106 | token->kad->expiry = ntohl(xdr[5]); | ||
107 | token->kad->primary_flag = ntohl(xdr[6]); | ||
108 | memcpy(&token->kad->session_key, &xdr[2], 8); | ||
109 | memcpy(&token->kad->ticket, &xdr[8], tktlen); | ||
110 | |||
111 | _debug("SCIX: %u", token->security_index); | ||
112 | _debug("TLEN: %u", token->kad->ticket_len); | ||
113 | _debug("EXPY: %x", token->kad->expiry); | ||
114 | _debug("KVNO: %u", token->kad->kvno); | ||
115 | _debug("PRIM: %u", token->kad->primary_flag); | ||
116 | _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x", | ||
117 | token->kad->session_key[0], token->kad->session_key[1], | ||
118 | token->kad->session_key[2], token->kad->session_key[3], | ||
119 | token->kad->session_key[4], token->kad->session_key[5], | ||
120 | token->kad->session_key[6], token->kad->session_key[7]); | ||
121 | if (token->kad->ticket_len >= 8) | ||
122 | _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x", | ||
123 | token->kad->ticket[0], token->kad->ticket[1], | ||
124 | token->kad->ticket[2], token->kad->ticket[3], | ||
125 | token->kad->ticket[4], token->kad->ticket[5], | ||
126 | token->kad->ticket[6], token->kad->ticket[7]); | ||
127 | |||
128 | /* count the number of tokens attached */ | ||
129 | key->type_data.x[0]++; | ||
130 | |||
131 | /* attach the data */ | ||
132 | for (pptoken = (struct rxrpc_key_token **)&key->payload.data; | ||
133 | *pptoken; | ||
134 | pptoken = &(*pptoken)->next) | ||
135 | continue; | ||
136 | *pptoken = token; | ||
137 | if (token->kad->expiry < key->expiry) | ||
138 | key->expiry = token->kad->expiry; | ||
139 | |||
140 | _leave(" = 0"); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static void rxrpc_free_krb5_principal(struct krb5_principal *princ) | ||
145 | { | ||
146 | int loop; | ||
147 | |||
148 | if (princ->name_parts) { | ||
149 | for (loop = princ->n_name_parts - 1; loop >= 0; loop--) | ||
150 | kfree(princ->name_parts[loop]); | ||
151 | kfree(princ->name_parts); | ||
152 | } | ||
153 | kfree(princ->realm); | ||
154 | } | ||
155 | |||
156 | static void rxrpc_free_krb5_tagged(struct krb5_tagged_data *td) | ||
157 | { | ||
158 | kfree(td->data); | ||
159 | } | ||
160 | |||
161 | /* | ||
162 | * free up an RxK5 token | ||
163 | */ | ||
164 | static void rxrpc_rxk5_free(struct rxk5_key *rxk5) | ||
165 | { | ||
166 | int loop; | ||
167 | |||
168 | rxrpc_free_krb5_principal(&rxk5->client); | ||
169 | rxrpc_free_krb5_principal(&rxk5->server); | ||
170 | rxrpc_free_krb5_tagged(&rxk5->session); | ||
171 | |||
172 | if (rxk5->addresses) { | ||
173 | for (loop = rxk5->n_addresses - 1; loop >= 0; loop--) | ||
174 | rxrpc_free_krb5_tagged(&rxk5->addresses[loop]); | ||
175 | kfree(rxk5->addresses); | ||
176 | } | ||
177 | if (rxk5->authdata) { | ||
178 | for (loop = rxk5->n_authdata - 1; loop >= 0; loop--) | ||
179 | rxrpc_free_krb5_tagged(&rxk5->authdata[loop]); | ||
180 | kfree(rxk5->authdata); | ||
181 | } | ||
182 | |||
183 | kfree(rxk5->ticket); | ||
184 | kfree(rxk5->ticket2); | ||
185 | kfree(rxk5); | ||
186 | } | ||
187 | |||
188 | /* | ||
189 | * extract a krb5 principal | ||
190 | */ | ||
191 | static int rxrpc_krb5_decode_principal(struct krb5_principal *princ, | ||
192 | const __be32 **_xdr, | ||
193 | unsigned *_toklen) | ||
194 | { | ||
195 | const __be32 *xdr = *_xdr; | ||
196 | unsigned toklen = *_toklen, n_parts, loop, tmp; | ||
197 | |||
198 | /* there must be at least one name, and at least #names+1 length | ||
199 | * words */ | ||
200 | if (toklen <= 12) | ||
201 | return -EINVAL; | ||
202 | |||
203 | _enter(",{%x,%x,%x},%u", | ||
204 | ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), toklen); | ||
205 | |||
206 | n_parts = ntohl(*xdr++); | ||
207 | toklen -= 4; | ||
208 | if (n_parts <= 0 || n_parts > AFSTOKEN_K5_COMPONENTS_MAX) | ||
209 | return -EINVAL; | ||
210 | princ->n_name_parts = n_parts; | ||
211 | |||
212 | if (toklen <= (n_parts + 1) * 4) | ||
213 | return -EINVAL; | ||
214 | |||
215 | princ->name_parts = kcalloc(sizeof(char *), n_parts, GFP_KERNEL); | ||
216 | if (!princ->name_parts) | ||
217 | return -ENOMEM; | ||
218 | |||
219 | for (loop = 0; loop < n_parts; loop++) { | ||
220 | if (toklen < 4) | ||
221 | return -EINVAL; | ||
222 | tmp = ntohl(*xdr++); | ||
223 | toklen -= 4; | ||
224 | if (tmp <= 0 || tmp > AFSTOKEN_STRING_MAX) | ||
225 | return -EINVAL; | ||
226 | if (tmp > toklen) | ||
227 | return -EINVAL; | ||
228 | princ->name_parts[loop] = kmalloc(tmp + 1, GFP_KERNEL); | ||
229 | if (!princ->name_parts[loop]) | ||
230 | return -ENOMEM; | ||
231 | memcpy(princ->name_parts[loop], xdr, tmp); | ||
232 | princ->name_parts[loop][tmp] = 0; | ||
233 | tmp = (tmp + 3) & ~3; | ||
234 | toklen -= tmp; | ||
235 | xdr += tmp >> 2; | ||
236 | } | ||
237 | |||
238 | if (toklen < 4) | ||
239 | return -EINVAL; | ||
240 | tmp = ntohl(*xdr++); | ||
241 | toklen -= 4; | ||
242 | if (tmp <= 0 || tmp > AFSTOKEN_K5_REALM_MAX) | ||
243 | return -EINVAL; | ||
244 | if (tmp > toklen) | ||
245 | return -EINVAL; | ||
246 | princ->realm = kmalloc(tmp + 1, GFP_KERNEL); | ||
247 | if (!princ->realm) | ||
248 | return -ENOMEM; | ||
249 | memcpy(princ->realm, xdr, tmp); | ||
250 | princ->realm[tmp] = 0; | ||
251 | tmp = (tmp + 3) & ~3; | ||
252 | toklen -= tmp; | ||
253 | xdr += tmp >> 2; | ||
254 | |||
255 | _debug("%s/...@%s", princ->name_parts[0], princ->realm); | ||
256 | |||
257 | *_xdr = xdr; | ||
258 | *_toklen = toklen; | ||
259 | _leave(" = 0 [toklen=%u]", toklen); | ||
260 | return 0; | ||
261 | } | ||
262 | |||
263 | /* | ||
264 | * extract a piece of krb5 tagged data | ||
265 | */ | ||
266 | static int rxrpc_krb5_decode_tagged_data(struct krb5_tagged_data *td, | ||
267 | size_t max_data_size, | ||
268 | const __be32 **_xdr, | ||
269 | unsigned *_toklen) | ||
270 | { | ||
271 | const __be32 *xdr = *_xdr; | ||
272 | unsigned toklen = *_toklen, len; | ||
273 | |||
274 | /* there must be at least one tag and one length word */ | ||
275 | if (toklen <= 8) | ||
276 | return -EINVAL; | ||
277 | |||
278 | _enter(",%zu,{%x,%x},%u", | ||
279 | max_data_size, ntohl(xdr[0]), ntohl(xdr[1]), toklen); | ||
280 | |||
281 | td->tag = ntohl(*xdr++); | ||
282 | len = ntohl(*xdr++); | ||
283 | toklen -= 8; | ||
284 | if (len > max_data_size) | ||
285 | return -EINVAL; | ||
286 | td->data_len = len; | ||
287 | |||
288 | if (len > 0) { | ||
289 | td->data = kmalloc(len, GFP_KERNEL); | ||
290 | if (!td->data) | ||
291 | return -ENOMEM; | ||
292 | memcpy(td->data, xdr, len); | ||
293 | len = (len + 3) & ~3; | ||
294 | toklen -= len; | ||
295 | xdr += len >> 2; | ||
296 | } | ||
297 | |||
298 | _debug("tag %x len %x", td->tag, td->data_len); | ||
299 | |||
300 | *_xdr = xdr; | ||
301 | *_toklen = toklen; | ||
302 | _leave(" = 0 [toklen=%u]", toklen); | ||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | /* | ||
307 | * extract an array of tagged data | ||
308 | */ | ||
309 | static int rxrpc_krb5_decode_tagged_array(struct krb5_tagged_data **_td, | ||
310 | u8 *_n_elem, | ||
311 | u8 max_n_elem, | ||
312 | size_t max_elem_size, | ||
313 | const __be32 **_xdr, | ||
314 | unsigned *_toklen) | ||
315 | { | ||
316 | struct krb5_tagged_data *td; | ||
317 | const __be32 *xdr = *_xdr; | ||
318 | unsigned toklen = *_toklen, n_elem, loop; | ||
319 | int ret; | ||
320 | |||
321 | /* there must be at least one count */ | ||
322 | if (toklen < 4) | ||
323 | return -EINVAL; | ||
324 | |||
325 | _enter(",,%u,%zu,{%x},%u", | ||
326 | max_n_elem, max_elem_size, ntohl(xdr[0]), toklen); | ||
327 | |||
328 | n_elem = ntohl(*xdr++); | ||
329 | toklen -= 4; | ||
330 | if (n_elem < 0 || n_elem > max_n_elem) | ||
331 | return -EINVAL; | ||
332 | *_n_elem = n_elem; | ||
333 | if (n_elem > 0) { | ||
334 | if (toklen <= (n_elem + 1) * 4) | ||
335 | return -EINVAL; | ||
336 | |||
337 | _debug("n_elem %d", n_elem); | ||
338 | |||
339 | td = kcalloc(sizeof(struct krb5_tagged_data), n_elem, | ||
340 | GFP_KERNEL); | ||
341 | if (!td) | ||
342 | return -ENOMEM; | ||
343 | *_td = td; | ||
344 | |||
345 | for (loop = 0; loop < n_elem; loop++) { | ||
346 | ret = rxrpc_krb5_decode_tagged_data(&td[loop], | ||
347 | max_elem_size, | ||
348 | &xdr, &toklen); | ||
349 | if (ret < 0) | ||
350 | return ret; | ||
351 | } | ||
352 | } | ||
353 | |||
354 | *_xdr = xdr; | ||
355 | *_toklen = toklen; | ||
356 | _leave(" = 0 [toklen=%u]", toklen); | ||
357 | return 0; | ||
358 | } | ||
359 | |||
360 | /* | ||
361 | * extract a krb5 ticket | ||
362 | */ | ||
363 | static int rxrpc_krb5_decode_ticket(u8 **_ticket, u16 *_tktlen, | ||
364 | const __be32 **_xdr, unsigned *_toklen) | ||
365 | { | ||
366 | const __be32 *xdr = *_xdr; | ||
367 | unsigned toklen = *_toklen, len; | ||
368 | |||
369 | /* there must be at least one length word */ | ||
370 | if (toklen <= 4) | ||
371 | return -EINVAL; | ||
372 | |||
373 | _enter(",{%x},%u", ntohl(xdr[0]), toklen); | ||
374 | |||
375 | len = ntohl(*xdr++); | ||
376 | toklen -= 4; | ||
377 | if (len > AFSTOKEN_K5_TIX_MAX) | ||
378 | return -EINVAL; | ||
379 | *_tktlen = len; | ||
380 | |||
381 | _debug("ticket len %u", len); | ||
382 | |||
383 | if (len > 0) { | ||
384 | *_ticket = kmalloc(len, GFP_KERNEL); | ||
385 | if (!*_ticket) | ||
386 | return -ENOMEM; | ||
387 | memcpy(*_ticket, xdr, len); | ||
388 | len = (len + 3) & ~3; | ||
389 | toklen -= len; | ||
390 | xdr += len >> 2; | ||
391 | } | ||
392 | |||
393 | *_xdr = xdr; | ||
394 | *_toklen = toklen; | ||
395 | _leave(" = 0 [toklen=%u]", toklen); | ||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | /* | ||
400 | * parse an RxK5 type XDR format token | ||
401 | * - the caller guarantees we have at least 4 words | ||
402 | */ | ||
403 | static int rxrpc_instantiate_xdr_rxk5(struct key *key, const __be32 *xdr, | ||
404 | unsigned toklen) | ||
405 | { | ||
406 | struct rxrpc_key_token *token, **pptoken; | ||
407 | struct rxk5_key *rxk5; | ||
408 | const __be32 *end_xdr = xdr + (toklen >> 2); | ||
409 | int ret; | ||
410 | |||
411 | _enter(",{%x,%x,%x,%x},%u", | ||
412 | ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]), | ||
413 | toklen); | ||
414 | |||
415 | /* reserve some payload space for this subkey - the length of the token | ||
416 | * is a reasonable approximation */ | ||
417 | ret = key_payload_reserve(key, key->datalen + toklen); | ||
418 | if (ret < 0) | ||
419 | return ret; | ||
420 | |||
421 | token = kzalloc(sizeof(*token), GFP_KERNEL); | ||
422 | if (!token) | ||
423 | return -ENOMEM; | ||
424 | |||
425 | rxk5 = kzalloc(sizeof(*rxk5), GFP_KERNEL); | ||
426 | if (!rxk5) { | ||
427 | kfree(token); | ||
428 | return -ENOMEM; | ||
429 | } | ||
430 | |||
431 | token->security_index = RXRPC_SECURITY_RXK5; | ||
432 | token->k5 = rxk5; | ||
433 | |||
434 | /* extract the principals */ | ||
435 | ret = rxrpc_krb5_decode_principal(&rxk5->client, &xdr, &toklen); | ||
436 | if (ret < 0) | ||
437 | goto error; | ||
438 | ret = rxrpc_krb5_decode_principal(&rxk5->server, &xdr, &toklen); | ||
439 | if (ret < 0) | ||
440 | goto error; | ||
441 | |||
442 | /* extract the session key and the encoding type (the tag field -> | ||
443 | * ENCTYPE_xxx) */ | ||
444 | ret = rxrpc_krb5_decode_tagged_data(&rxk5->session, AFSTOKEN_DATA_MAX, | ||
445 | &xdr, &toklen); | ||
446 | if (ret < 0) | ||
447 | goto error; | ||
448 | |||
449 | if (toklen < 4 * 8 + 2 * 4) | ||
450 | goto inval; | ||
451 | rxk5->authtime = be64_to_cpup((const __be64 *) xdr); | ||
452 | xdr += 2; | ||
453 | rxk5->starttime = be64_to_cpup((const __be64 *) xdr); | ||
454 | xdr += 2; | ||
455 | rxk5->endtime = be64_to_cpup((const __be64 *) xdr); | ||
456 | xdr += 2; | ||
457 | rxk5->renew_till = be64_to_cpup((const __be64 *) xdr); | ||
458 | xdr += 2; | ||
459 | rxk5->is_skey = ntohl(*xdr++); | ||
460 | rxk5->flags = ntohl(*xdr++); | ||
461 | toklen -= 4 * 8 + 2 * 4; | ||
462 | |||
463 | _debug("times: a=%llx s=%llx e=%llx rt=%llx", | ||
464 | rxk5->authtime, rxk5->starttime, rxk5->endtime, | ||
465 | rxk5->renew_till); | ||
466 | _debug("is_skey=%x flags=%x", rxk5->is_skey, rxk5->flags); | ||
467 | |||
468 | /* extract the permitted client addresses */ | ||
469 | ret = rxrpc_krb5_decode_tagged_array(&rxk5->addresses, | ||
470 | &rxk5->n_addresses, | ||
471 | AFSTOKEN_K5_ADDRESSES_MAX, | ||
472 | AFSTOKEN_DATA_MAX, | ||
473 | &xdr, &toklen); | ||
474 | if (ret < 0) | ||
475 | goto error; | ||
476 | |||
477 | ASSERTCMP((end_xdr - xdr) << 2, ==, toklen); | ||
478 | |||
479 | /* extract the tickets */ | ||
480 | ret = rxrpc_krb5_decode_ticket(&rxk5->ticket, &rxk5->ticket_len, | ||
481 | &xdr, &toklen); | ||
482 | if (ret < 0) | ||
483 | goto error; | ||
484 | ret = rxrpc_krb5_decode_ticket(&rxk5->ticket2, &rxk5->ticket2_len, | ||
485 | &xdr, &toklen); | ||
486 | if (ret < 0) | ||
487 | goto error; | ||
488 | |||
489 | ASSERTCMP((end_xdr - xdr) << 2, ==, toklen); | ||
490 | |||
491 | /* extract the typed auth data */ | ||
492 | ret = rxrpc_krb5_decode_tagged_array(&rxk5->authdata, | ||
493 | &rxk5->n_authdata, | ||
494 | AFSTOKEN_K5_AUTHDATA_MAX, | ||
495 | AFSTOKEN_BDATALN_MAX, | ||
496 | &xdr, &toklen); | ||
497 | if (ret < 0) | ||
498 | goto error; | ||
499 | |||
500 | ASSERTCMP((end_xdr - xdr) << 2, ==, toklen); | ||
501 | |||
502 | if (toklen != 0) | ||
503 | goto inval; | ||
504 | |||
505 | /* attach the payload to the key */ | ||
506 | for (pptoken = (struct rxrpc_key_token **)&key->payload.data; | ||
507 | *pptoken; | ||
508 | pptoken = &(*pptoken)->next) | ||
509 | continue; | ||
510 | *pptoken = token; | ||
511 | if (token->kad->expiry < key->expiry) | ||
512 | key->expiry = token->kad->expiry; | ||
513 | |||
514 | _leave(" = 0"); | ||
515 | return 0; | ||
516 | |||
517 | inval: | ||
518 | ret = -EINVAL; | ||
519 | error: | ||
520 | rxrpc_rxk5_free(rxk5); | ||
521 | kfree(token); | ||
522 | _leave(" = %d", ret); | ||
523 | return ret; | ||
524 | } | ||
525 | |||
526 | /* | ||
527 | * attempt to parse the data as the XDR format | ||
528 | * - the caller guarantees we have more than 7 words | ||
529 | */ | ||
530 | static int rxrpc_instantiate_xdr(struct key *key, const void *data, size_t datalen) | ||
531 | { | ||
532 | const __be32 *xdr = data, *token; | ||
533 | const char *cp; | ||
534 | unsigned len, tmp, loop, ntoken, toklen, sec_ix; | ||
535 | int ret; | ||
536 | |||
537 | _enter(",{%x,%x,%x,%x},%zu", | ||
538 | ntohl(xdr[0]), ntohl(xdr[1]), ntohl(xdr[2]), ntohl(xdr[3]), | ||
539 | datalen); | ||
540 | |||
541 | if (datalen > AFSTOKEN_LENGTH_MAX) | ||
542 | goto not_xdr; | ||
543 | |||
544 | /* XDR is an array of __be32's */ | ||
545 | if (datalen & 3) | ||
546 | goto not_xdr; | ||
547 | |||
548 | /* the flags should be 0 (the setpag bit must be handled by | ||
549 | * userspace) */ | ||
550 | if (ntohl(*xdr++) != 0) | ||
551 | goto not_xdr; | ||
552 | datalen -= 4; | ||
553 | |||
554 | /* check the cell name */ | ||
555 | len = ntohl(*xdr++); | ||
556 | if (len < 1 || len > AFSTOKEN_CELL_MAX) | ||
557 | goto not_xdr; | ||
558 | datalen -= 4; | ||
559 | tmp = (len + 3) & ~3; | ||
560 | if (tmp > datalen) | ||
561 | goto not_xdr; | ||
562 | |||
563 | cp = (const char *) xdr; | ||
564 | for (loop = 0; loop < len; loop++) | ||
565 | if (!isprint(cp[loop])) | ||
566 | goto not_xdr; | ||
567 | if (len < tmp) | ||
568 | for (; loop < tmp; loop++) | ||
569 | if (cp[loop]) | ||
570 | goto not_xdr; | ||
571 | _debug("cellname: [%u/%u] '%*.*s'", | ||
572 | len, tmp, len, len, (const char *) xdr); | ||
573 | datalen -= tmp; | ||
574 | xdr += tmp >> 2; | ||
575 | |||
576 | /* get the token count */ | ||
577 | if (datalen < 12) | ||
578 | goto not_xdr; | ||
579 | ntoken = ntohl(*xdr++); | ||
580 | datalen -= 4; | ||
581 | _debug("ntoken: %x", ntoken); | ||
582 | if (ntoken < 1 || ntoken > AFSTOKEN_MAX) | ||
583 | goto not_xdr; | ||
584 | |||
585 | /* check each token wrapper */ | ||
586 | token = xdr; | ||
587 | loop = ntoken; | ||
588 | do { | ||
589 | if (datalen < 8) | ||
590 | goto not_xdr; | ||
591 | toklen = ntohl(*xdr++); | ||
592 | sec_ix = ntohl(*xdr); | ||
593 | datalen -= 4; | ||
594 | _debug("token: [%x/%zx] %x", toklen, datalen, sec_ix); | ||
595 | if (toklen < 20 || toklen > datalen) | ||
596 | goto not_xdr; | ||
597 | datalen -= (toklen + 3) & ~3; | ||
598 | xdr += (toklen + 3) >> 2; | ||
599 | |||
600 | } while (--loop > 0); | ||
601 | |||
602 | _debug("remainder: %zu", datalen); | ||
603 | if (datalen != 0) | ||
604 | goto not_xdr; | ||
605 | |||
606 | /* okay: we're going to assume it's valid XDR format | ||
607 | * - we ignore the cellname, relying on the key to be correctly named | ||
608 | */ | ||
609 | do { | ||
610 | xdr = token; | ||
611 | toklen = ntohl(*xdr++); | ||
612 | token = xdr + ((toklen + 3) >> 2); | ||
613 | sec_ix = ntohl(*xdr++); | ||
614 | toklen -= 4; | ||
615 | |||
616 | _debug("TOKEN type=%u [%p-%p]", sec_ix, xdr, token); | ||
617 | |||
618 | switch (sec_ix) { | ||
619 | case RXRPC_SECURITY_RXKAD: | ||
620 | ret = rxrpc_instantiate_xdr_rxkad(key, xdr, toklen); | ||
621 | if (ret != 0) | ||
622 | goto error; | ||
623 | break; | ||
624 | |||
625 | case RXRPC_SECURITY_RXK5: | ||
626 | ret = rxrpc_instantiate_xdr_rxk5(key, xdr, toklen); | ||
627 | if (ret != 0) | ||
628 | goto error; | ||
629 | break; | ||
630 | |||
631 | default: | ||
632 | ret = -EPROTONOSUPPORT; | ||
633 | goto error; | ||
634 | } | ||
635 | |||
636 | } while (--ntoken > 0); | ||
637 | |||
638 | _leave(" = 0"); | ||
639 | return 0; | ||
640 | |||
641 | not_xdr: | ||
642 | _leave(" = -EPROTO"); | ||
643 | return -EPROTO; | ||
644 | error: | ||
645 | _leave(" = %d", ret); | ||
646 | return ret; | ||
647 | } | ||
648 | |||
649 | /* | ||
58 | * instantiate an rxrpc defined key | 650 | * instantiate an rxrpc defined key |
59 | * data should be of the form: | 651 | * data should be of the form: |
60 | * OFFSET LEN CONTENT | 652 | * OFFSET LEN CONTENT |
@@ -70,8 +662,8 @@ struct key_type key_type_rxrpc_s = { | |||
70 | */ | 662 | */ |
71 | static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen) | 663 | static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen) |
72 | { | 664 | { |
73 | const struct rxkad_key *tsec; | 665 | const struct rxrpc_key_data_v1 *v1; |
74 | struct rxrpc_key_payload *upayload; | 666 | struct rxrpc_key_token *token, **pp; |
75 | size_t plen; | 667 | size_t plen; |
76 | u32 kver; | 668 | u32 kver; |
77 | int ret; | 669 | int ret; |
@@ -82,6 +674,13 @@ static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen) | |||
82 | if (!data && datalen == 0) | 674 | if (!data && datalen == 0) |
83 | return 0; | 675 | return 0; |
84 | 676 | ||
677 | /* determine if the XDR payload format is being used */ | ||
678 | if (datalen > 7 * 4) { | ||
679 | ret = rxrpc_instantiate_xdr(key, data, datalen); | ||
680 | if (ret != -EPROTO) | ||
681 | return ret; | ||
682 | } | ||
683 | |||
85 | /* get the key interface version number */ | 684 | /* get the key interface version number */ |
86 | ret = -EINVAL; | 685 | ret = -EINVAL; |
87 | if (datalen <= 4 || !data) | 686 | if (datalen <= 4 || !data) |
@@ -98,53 +697,67 @@ static int rxrpc_instantiate(struct key *key, const void *data, size_t datalen) | |||
98 | 697 | ||
99 | /* deal with a version 1 key */ | 698 | /* deal with a version 1 key */ |
100 | ret = -EINVAL; | 699 | ret = -EINVAL; |
101 | if (datalen < sizeof(*tsec)) | 700 | if (datalen < sizeof(*v1)) |
102 | goto error; | 701 | goto error; |
103 | 702 | ||
104 | tsec = data; | 703 | v1 = data; |
105 | if (datalen != sizeof(*tsec) + tsec->ticket_len) | 704 | if (datalen != sizeof(*v1) + v1->ticket_length) |
106 | goto error; | 705 | goto error; |
107 | 706 | ||
108 | _debug("SCIX: %u", tsec->security_index); | 707 | _debug("SCIX: %u", v1->security_index); |
109 | _debug("TLEN: %u", tsec->ticket_len); | 708 | _debug("TLEN: %u", v1->ticket_length); |
110 | _debug("EXPY: %x", tsec->expiry); | 709 | _debug("EXPY: %x", v1->expiry); |
111 | _debug("KVNO: %u", tsec->kvno); | 710 | _debug("KVNO: %u", v1->kvno); |
112 | _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x", | 711 | _debug("SKEY: %02x%02x%02x%02x%02x%02x%02x%02x", |
113 | tsec->session_key[0], tsec->session_key[1], | 712 | v1->session_key[0], v1->session_key[1], |
114 | tsec->session_key[2], tsec->session_key[3], | 713 | v1->session_key[2], v1->session_key[3], |
115 | tsec->session_key[4], tsec->session_key[5], | 714 | v1->session_key[4], v1->session_key[5], |
116 | tsec->session_key[6], tsec->session_key[7]); | 715 | v1->session_key[6], v1->session_key[7]); |
117 | if (tsec->ticket_len >= 8) | 716 | if (v1->ticket_length >= 8) |
118 | _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x", | 717 | _debug("TCKT: %02x%02x%02x%02x%02x%02x%02x%02x", |
119 | tsec->ticket[0], tsec->ticket[1], | 718 | v1->ticket[0], v1->ticket[1], |
120 | tsec->ticket[2], tsec->ticket[3], | 719 | v1->ticket[2], v1->ticket[3], |
121 | tsec->ticket[4], tsec->ticket[5], | 720 | v1->ticket[4], v1->ticket[5], |
122 | tsec->ticket[6], tsec->ticket[7]); | 721 | v1->ticket[6], v1->ticket[7]); |
123 | 722 | ||
124 | ret = -EPROTONOSUPPORT; | 723 | ret = -EPROTONOSUPPORT; |
125 | if (tsec->security_index != 2) | 724 | if (v1->security_index != RXRPC_SECURITY_RXKAD) |
126 | goto error; | 725 | goto error; |
127 | 726 | ||
128 | key->type_data.x[0] = tsec->security_index; | 727 | plen = sizeof(*token->kad) + v1->ticket_length; |
129 | 728 | ret = key_payload_reserve(key, plen + sizeof(*token)); | |
130 | plen = sizeof(*upayload) + tsec->ticket_len; | ||
131 | ret = key_payload_reserve(key, plen); | ||
132 | if (ret < 0) | 729 | if (ret < 0) |
133 | goto error; | 730 | goto error; |
134 | 731 | ||
135 | ret = -ENOMEM; | 732 | ret = -ENOMEM; |
136 | upayload = kmalloc(plen, GFP_KERNEL); | 733 | token = kmalloc(sizeof(*token), GFP_KERNEL); |
137 | if (!upayload) | 734 | if (!token) |
138 | goto error; | 735 | goto error; |
736 | token->kad = kmalloc(plen, GFP_KERNEL); | ||
737 | if (!token->kad) | ||
738 | goto error_free; | ||
739 | |||
740 | token->security_index = RXRPC_SECURITY_RXKAD; | ||
741 | token->kad->ticket_len = v1->ticket_length; | ||
742 | token->kad->expiry = v1->expiry; | ||
743 | token->kad->kvno = v1->kvno; | ||
744 | memcpy(&token->kad->session_key, &v1->session_key, 8); | ||
745 | memcpy(&token->kad->ticket, v1->ticket, v1->ticket_length); | ||
139 | 746 | ||
140 | /* attach the data */ | 747 | /* attach the data */ |
141 | memcpy(&upayload->k, tsec, sizeof(*tsec)); | 748 | key->type_data.x[0]++; |
142 | memcpy(&upayload->k.ticket, (void *)tsec + sizeof(*tsec), | 749 | |
143 | tsec->ticket_len); | 750 | pp = (struct rxrpc_key_token **)&key->payload.data; |
144 | key->payload.data = upayload; | 751 | while (*pp) |
145 | key->expiry = tsec->expiry; | 752 | pp = &(*pp)->next; |
753 | *pp = token; | ||
754 | if (token->kad->expiry < key->expiry) | ||
755 | key->expiry = token->kad->expiry; | ||
756 | token = NULL; | ||
146 | ret = 0; | 757 | ret = 0; |
147 | 758 | ||
759 | error_free: | ||
760 | kfree(token); | ||
148 | error: | 761 | error: |
149 | return ret; | 762 | return ret; |
150 | } | 763 | } |
@@ -184,7 +797,26 @@ static int rxrpc_instantiate_s(struct key *key, const void *data, | |||
184 | */ | 797 | */ |
185 | static void rxrpc_destroy(struct key *key) | 798 | static void rxrpc_destroy(struct key *key) |
186 | { | 799 | { |
187 | kfree(key->payload.data); | 800 | struct rxrpc_key_token *token; |
801 | |||
802 | while ((token = key->payload.data)) { | ||
803 | key->payload.data = token->next; | ||
804 | switch (token->security_index) { | ||
805 | case RXRPC_SECURITY_RXKAD: | ||
806 | kfree(token->kad); | ||
807 | break; | ||
808 | case RXRPC_SECURITY_RXK5: | ||
809 | if (token->k5) | ||
810 | rxrpc_rxk5_free(token->k5); | ||
811 | break; | ||
812 | default: | ||
813 | printk(KERN_ERR "Unknown token type %x on rxrpc key\n", | ||
814 | token->security_index); | ||
815 | BUG(); | ||
816 | } | ||
817 | |||
818 | kfree(token); | ||
819 | } | ||
188 | } | 820 | } |
189 | 821 | ||
190 | /* | 822 | /* |
@@ -293,7 +925,7 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn, | |||
293 | 925 | ||
294 | struct { | 926 | struct { |
295 | u32 kver; | 927 | u32 kver; |
296 | struct rxkad_key tsec; | 928 | struct rxrpc_key_data_v1 v1; |
297 | } data; | 929 | } data; |
298 | 930 | ||
299 | _enter(""); | 931 | _enter(""); |
@@ -308,13 +940,12 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *conn, | |||
308 | _debug("key %d", key_serial(key)); | 940 | _debug("key %d", key_serial(key)); |
309 | 941 | ||
310 | data.kver = 1; | 942 | data.kver = 1; |
311 | data.tsec.security_index = 2; | 943 | data.v1.security_index = RXRPC_SECURITY_RXKAD; |
312 | data.tsec.ticket_len = 0; | 944 | data.v1.ticket_length = 0; |
313 | data.tsec.expiry = expiry; | 945 | data.v1.expiry = expiry; |
314 | data.tsec.kvno = 0; | 946 | data.v1.kvno = 0; |
315 | 947 | ||
316 | memcpy(&data.tsec.session_key, session_key, | 948 | memcpy(&data.v1.session_key, session_key, sizeof(data.v1.session_key)); |
317 | sizeof(data.tsec.session_key)); | ||
318 | 949 | ||
319 | ret = key_instantiate_and_link(key, &data, sizeof(data), NULL, NULL); | 950 | ret = key_instantiate_and_link(key, &data, sizeof(data), NULL, NULL); |
320 | if (ret < 0) | 951 | if (ret < 0) |
@@ -360,3 +991,210 @@ struct key *rxrpc_get_null_key(const char *keyname) | |||
360 | return key; | 991 | return key; |
361 | } | 992 | } |
362 | EXPORT_SYMBOL(rxrpc_get_null_key); | 993 | EXPORT_SYMBOL(rxrpc_get_null_key); |
994 | |||
995 | /* | ||
996 | * read the contents of an rxrpc key | ||
997 | * - this returns the result in XDR form | ||
998 | */ | ||
999 | static long rxrpc_read(const struct key *key, | ||
1000 | char __user *buffer, size_t buflen) | ||
1001 | { | ||
1002 | const struct rxrpc_key_token *token; | ||
1003 | const struct krb5_principal *princ; | ||
1004 | size_t size; | ||
1005 | __be32 __user *xdr, *oldxdr; | ||
1006 | u32 cnlen, toksize, ntoks, tok, zero; | ||
1007 | u16 toksizes[AFSTOKEN_MAX]; | ||
1008 | int loop; | ||
1009 | |||
1010 | _enter(""); | ||
1011 | |||
1012 | /* we don't know what form we should return non-AFS keys in */ | ||
1013 | if (memcmp(key->description, "afs@", 4) != 0) | ||
1014 | return -EOPNOTSUPP; | ||
1015 | cnlen = strlen(key->description + 4); | ||
1016 | |||
1017 | #define RND(X) (((X) + 3) & ~3) | ||
1018 | |||
1019 | /* AFS keys we return in XDR form, so we need to work out the size of | ||
1020 | * the XDR */ | ||
1021 | size = 2 * 4; /* flags, cellname len */ | ||
1022 | size += RND(cnlen); /* cellname */ | ||
1023 | size += 1 * 4; /* token count */ | ||
1024 | |||
1025 | ntoks = 0; | ||
1026 | for (token = key->payload.data; token; token = token->next) { | ||
1027 | toksize = 4; /* sec index */ | ||
1028 | |||
1029 | switch (token->security_index) { | ||
1030 | case RXRPC_SECURITY_RXKAD: | ||
1031 | toksize += 8 * 4; /* viceid, kvno, key*2, begin, | ||
1032 | * end, primary, tktlen */ | ||
1033 | toksize += RND(token->kad->ticket_len); | ||
1034 | break; | ||
1035 | |||
1036 | case RXRPC_SECURITY_RXK5: | ||
1037 | princ = &token->k5->client; | ||
1038 | toksize += 4 + princ->n_name_parts * 4; | ||
1039 | for (loop = 0; loop < princ->n_name_parts; loop++) | ||
1040 | toksize += RND(strlen(princ->name_parts[loop])); | ||
1041 | toksize += 4 + RND(strlen(princ->realm)); | ||
1042 | |||
1043 | princ = &token->k5->server; | ||
1044 | toksize += 4 + princ->n_name_parts * 4; | ||
1045 | for (loop = 0; loop < princ->n_name_parts; loop++) | ||
1046 | toksize += RND(strlen(princ->name_parts[loop])); | ||
1047 | toksize += 4 + RND(strlen(princ->realm)); | ||
1048 | |||
1049 | toksize += 8 + RND(token->k5->session.data_len); | ||
1050 | |||
1051 | toksize += 4 * 8 + 2 * 4; | ||
1052 | |||
1053 | toksize += 4 + token->k5->n_addresses * 8; | ||
1054 | for (loop = 0; loop < token->k5->n_addresses; loop++) | ||
1055 | toksize += RND(token->k5->addresses[loop].data_len); | ||
1056 | |||
1057 | toksize += 4 + RND(token->k5->ticket_len); | ||
1058 | toksize += 4 + RND(token->k5->ticket2_len); | ||
1059 | |||
1060 | toksize += 4 + token->k5->n_authdata * 8; | ||
1061 | for (loop = 0; loop < token->k5->n_authdata; loop++) | ||
1062 | toksize += RND(token->k5->authdata[loop].data_len); | ||
1063 | break; | ||
1064 | |||
1065 | default: /* we have a ticket we can't encode */ | ||
1066 | BUG(); | ||
1067 | continue; | ||
1068 | } | ||
1069 | |||
1070 | _debug("token[%u]: toksize=%u", ntoks, toksize); | ||
1071 | ASSERTCMP(toksize, <=, AFSTOKEN_LENGTH_MAX); | ||
1072 | |||
1073 | toksizes[ntoks++] = toksize; | ||
1074 | size += toksize + 4; /* each token has a length word */ | ||
1075 | } | ||
1076 | |||
1077 | #undef RND | ||
1078 | |||
1079 | if (!buffer || buflen < size) | ||
1080 | return size; | ||
1081 | |||
1082 | xdr = (__be32 __user *) buffer; | ||
1083 | zero = 0; | ||
1084 | #define ENCODE(x) \ | ||
1085 | do { \ | ||
1086 | __be32 y = htonl(x); \ | ||
1087 | if (put_user(y, xdr++) < 0) \ | ||
1088 | goto fault; \ | ||
1089 | } while(0) | ||
1090 | #define ENCODE_DATA(l, s) \ | ||
1091 | do { \ | ||
1092 | u32 _l = (l); \ | ||
1093 | ENCODE(l); \ | ||
1094 | if (copy_to_user(xdr, (s), _l) != 0) \ | ||
1095 | goto fault; \ | ||
1096 | if (_l & 3 && \ | ||
1097 | copy_to_user((u8 *)xdr + _l, &zero, 4 - (_l & 3)) != 0) \ | ||
1098 | goto fault; \ | ||
1099 | xdr += (_l + 3) >> 2; \ | ||
1100 | } while(0) | ||
1101 | #define ENCODE64(x) \ | ||
1102 | do { \ | ||
1103 | __be64 y = cpu_to_be64(x); \ | ||
1104 | if (copy_to_user(xdr, &y, 8) != 0) \ | ||
1105 | goto fault; \ | ||
1106 | xdr += 8 >> 2; \ | ||
1107 | } while(0) | ||
1108 | #define ENCODE_STR(s) \ | ||
1109 | do { \ | ||
1110 | const char *_s = (s); \ | ||
1111 | ENCODE_DATA(strlen(_s), _s); \ | ||
1112 | } while(0) | ||
1113 | |||
1114 | ENCODE(0); /* flags */ | ||
1115 | ENCODE_DATA(cnlen, key->description + 4); /* cellname */ | ||
1116 | ENCODE(ntoks); | ||
1117 | |||
1118 | tok = 0; | ||
1119 | for (token = key->payload.data; token; token = token->next) { | ||
1120 | toksize = toksizes[tok++]; | ||
1121 | ENCODE(toksize); | ||
1122 | oldxdr = xdr; | ||
1123 | ENCODE(token->security_index); | ||
1124 | |||
1125 | switch (token->security_index) { | ||
1126 | case RXRPC_SECURITY_RXKAD: | ||
1127 | ENCODE(token->kad->vice_id); | ||
1128 | ENCODE(token->kad->kvno); | ||
1129 | ENCODE_DATA(8, token->kad->session_key); | ||
1130 | ENCODE(token->kad->start); | ||
1131 | ENCODE(token->kad->expiry); | ||
1132 | ENCODE(token->kad->primary_flag); | ||
1133 | ENCODE_DATA(token->kad->ticket_len, token->kad->ticket); | ||
1134 | break; | ||
1135 | |||
1136 | case RXRPC_SECURITY_RXK5: | ||
1137 | princ = &token->k5->client; | ||
1138 | ENCODE(princ->n_name_parts); | ||
1139 | for (loop = 0; loop < princ->n_name_parts; loop++) | ||
1140 | ENCODE_STR(princ->name_parts[loop]); | ||
1141 | ENCODE_STR(princ->realm); | ||
1142 | |||
1143 | princ = &token->k5->server; | ||
1144 | ENCODE(princ->n_name_parts); | ||
1145 | for (loop = 0; loop < princ->n_name_parts; loop++) | ||
1146 | ENCODE_STR(princ->name_parts[loop]); | ||
1147 | ENCODE_STR(princ->realm); | ||
1148 | |||
1149 | ENCODE(token->k5->session.tag); | ||
1150 | ENCODE_DATA(token->k5->session.data_len, | ||
1151 | token->k5->session.data); | ||
1152 | |||
1153 | ENCODE64(token->k5->authtime); | ||
1154 | ENCODE64(token->k5->starttime); | ||
1155 | ENCODE64(token->k5->endtime); | ||
1156 | ENCODE64(token->k5->renew_till); | ||
1157 | ENCODE(token->k5->is_skey); | ||
1158 | ENCODE(token->k5->flags); | ||
1159 | |||
1160 | ENCODE(token->k5->n_addresses); | ||
1161 | for (loop = 0; loop < token->k5->n_addresses; loop++) { | ||
1162 | ENCODE(token->k5->addresses[loop].tag); | ||
1163 | ENCODE_DATA(token->k5->addresses[loop].data_len, | ||
1164 | token->k5->addresses[loop].data); | ||
1165 | } | ||
1166 | |||
1167 | ENCODE_DATA(token->k5->ticket_len, token->k5->ticket); | ||
1168 | ENCODE_DATA(token->k5->ticket2_len, token->k5->ticket2); | ||
1169 | |||
1170 | ENCODE(token->k5->n_authdata); | ||
1171 | for (loop = 0; loop < token->k5->n_authdata; loop++) { | ||
1172 | ENCODE(token->k5->authdata[loop].tag); | ||
1173 | ENCODE_DATA(token->k5->authdata[loop].data_len, | ||
1174 | token->k5->authdata[loop].data); | ||
1175 | } | ||
1176 | break; | ||
1177 | |||
1178 | default: | ||
1179 | BUG(); | ||
1180 | break; | ||
1181 | } | ||
1182 | |||
1183 | ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, ==, | ||
1184 | toksize); | ||
1185 | } | ||
1186 | |||
1187 | #undef ENCODE_STR | ||
1188 | #undef ENCODE_DATA | ||
1189 | #undef ENCODE64 | ||
1190 | #undef ENCODE | ||
1191 | |||
1192 | ASSERTCMP(tok, ==, ntoks); | ||
1193 | ASSERTCMP((char __user *) xdr - buffer, ==, size); | ||
1194 | _leave(" = %zu", size); | ||
1195 | return size; | ||
1196 | |||
1197 | fault: | ||
1198 | _leave(" = -EFAULT"); | ||
1199 | return -EFAULT; | ||
1200 | } | ||
diff --git a/net/rxrpc/ar-security.c b/net/rxrpc/ar-security.c index dc62920ee19a..49b3cc31ee1f 100644 --- a/net/rxrpc/ar-security.c +++ b/net/rxrpc/ar-security.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/crypto.h> | 16 | #include <linux/crypto.h> |
17 | #include <net/sock.h> | 17 | #include <net/sock.h> |
18 | #include <net/af_rxrpc.h> | 18 | #include <net/af_rxrpc.h> |
19 | #include <keys/rxrpc-type.h> | ||
19 | #include "ar-internal.h" | 20 | #include "ar-internal.h" |
20 | 21 | ||
21 | static LIST_HEAD(rxrpc_security_methods); | 22 | static LIST_HEAD(rxrpc_security_methods); |
@@ -122,6 +123,7 @@ EXPORT_SYMBOL_GPL(rxrpc_unregister_security); | |||
122 | */ | 123 | */ |
123 | int rxrpc_init_client_conn_security(struct rxrpc_connection *conn) | 124 | int rxrpc_init_client_conn_security(struct rxrpc_connection *conn) |
124 | { | 125 | { |
126 | struct rxrpc_key_token *token; | ||
125 | struct rxrpc_security *sec; | 127 | struct rxrpc_security *sec; |
126 | struct key *key = conn->key; | 128 | struct key *key = conn->key; |
127 | int ret; | 129 | int ret; |
@@ -135,7 +137,11 @@ int rxrpc_init_client_conn_security(struct rxrpc_connection *conn) | |||
135 | if (ret < 0) | 137 | if (ret < 0) |
136 | return ret; | 138 | return ret; |
137 | 139 | ||
138 | sec = rxrpc_security_lookup(key->type_data.x[0]); | 140 | if (!key->payload.data) |
141 | return -EKEYREJECTED; | ||
142 | token = key->payload.data; | ||
143 | |||
144 | sec = rxrpc_security_lookup(token->security_index); | ||
139 | if (!sec) | 145 | if (!sec) |
140 | return -EKEYREJECTED; | 146 | return -EKEYREJECTED; |
141 | conn->security = sec; | 147 | conn->security = sec; |
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index ef8f91030a15..713ac593e2e9 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/ctype.h> | 18 | #include <linux/ctype.h> |
19 | #include <net/sock.h> | 19 | #include <net/sock.h> |
20 | #include <net/af_rxrpc.h> | 20 | #include <net/af_rxrpc.h> |
21 | #include <keys/rxrpc-type.h> | ||
21 | #define rxrpc_debug rxkad_debug | 22 | #define rxrpc_debug rxkad_debug |
22 | #include "ar-internal.h" | 23 | #include "ar-internal.h" |
23 | 24 | ||
@@ -42,7 +43,7 @@ struct rxkad_level2_hdr { | |||
42 | __be32 checksum; /* decrypted data checksum */ | 43 | __be32 checksum; /* decrypted data checksum */ |
43 | }; | 44 | }; |
44 | 45 | ||
45 | MODULE_DESCRIPTION("RxRPC network protocol type-2 security (Kerberos)"); | 46 | MODULE_DESCRIPTION("RxRPC network protocol type-2 security (Kerberos 4)"); |
46 | MODULE_AUTHOR("Red Hat, Inc."); | 47 | MODULE_AUTHOR("Red Hat, Inc."); |
47 | MODULE_LICENSE("GPL"); | 48 | MODULE_LICENSE("GPL"); |
48 | 49 | ||
@@ -59,14 +60,14 @@ static DEFINE_MUTEX(rxkad_ci_mutex); | |||
59 | */ | 60 | */ |
60 | static int rxkad_init_connection_security(struct rxrpc_connection *conn) | 61 | static int rxkad_init_connection_security(struct rxrpc_connection *conn) |
61 | { | 62 | { |
62 | struct rxrpc_key_payload *payload; | ||
63 | struct crypto_blkcipher *ci; | 63 | struct crypto_blkcipher *ci; |
64 | struct rxrpc_key_token *token; | ||
64 | int ret; | 65 | int ret; |
65 | 66 | ||
66 | _enter("{%d},{%x}", conn->debug_id, key_serial(conn->key)); | 67 | _enter("{%d},{%x}", conn->debug_id, key_serial(conn->key)); |
67 | 68 | ||
68 | payload = conn->key->payload.data; | 69 | token = conn->key->payload.data; |
69 | conn->security_ix = payload->k.security_index; | 70 | conn->security_ix = token->security_index; |
70 | 71 | ||
71 | ci = crypto_alloc_blkcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC); | 72 | ci = crypto_alloc_blkcipher("pcbc(fcrypt)", 0, CRYPTO_ALG_ASYNC); |
72 | if (IS_ERR(ci)) { | 73 | if (IS_ERR(ci)) { |
@@ -75,8 +76,8 @@ static int rxkad_init_connection_security(struct rxrpc_connection *conn) | |||
75 | goto error; | 76 | goto error; |
76 | } | 77 | } |
77 | 78 | ||
78 | if (crypto_blkcipher_setkey(ci, payload->k.session_key, | 79 | if (crypto_blkcipher_setkey(ci, token->kad->session_key, |
79 | sizeof(payload->k.session_key)) < 0) | 80 | sizeof(token->kad->session_key)) < 0) |
80 | BUG(); | 81 | BUG(); |
81 | 82 | ||
82 | switch (conn->security_level) { | 83 | switch (conn->security_level) { |
@@ -110,7 +111,7 @@ error: | |||
110 | */ | 111 | */ |
111 | static void rxkad_prime_packet_security(struct rxrpc_connection *conn) | 112 | static void rxkad_prime_packet_security(struct rxrpc_connection *conn) |
112 | { | 113 | { |
113 | struct rxrpc_key_payload *payload; | 114 | struct rxrpc_key_token *token; |
114 | struct blkcipher_desc desc; | 115 | struct blkcipher_desc desc; |
115 | struct scatterlist sg[2]; | 116 | struct scatterlist sg[2]; |
116 | struct rxrpc_crypt iv; | 117 | struct rxrpc_crypt iv; |
@@ -123,8 +124,8 @@ static void rxkad_prime_packet_security(struct rxrpc_connection *conn) | |||
123 | if (!conn->key) | 124 | if (!conn->key) |
124 | return; | 125 | return; |
125 | 126 | ||
126 | payload = conn->key->payload.data; | 127 | token = conn->key->payload.data; |
127 | memcpy(&iv, payload->k.session_key, sizeof(iv)); | 128 | memcpy(&iv, token->kad->session_key, sizeof(iv)); |
128 | 129 | ||
129 | desc.tfm = conn->cipher; | 130 | desc.tfm = conn->cipher; |
130 | desc.info = iv.x; | 131 | desc.info = iv.x; |
@@ -197,7 +198,7 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, | |||
197 | u32 data_size, | 198 | u32 data_size, |
198 | void *sechdr) | 199 | void *sechdr) |
199 | { | 200 | { |
200 | const struct rxrpc_key_payload *payload; | 201 | const struct rxrpc_key_token *token; |
201 | struct rxkad_level2_hdr rxkhdr | 202 | struct rxkad_level2_hdr rxkhdr |
202 | __attribute__((aligned(8))); /* must be all on one page */ | 203 | __attribute__((aligned(8))); /* must be all on one page */ |
203 | struct rxrpc_skb_priv *sp; | 204 | struct rxrpc_skb_priv *sp; |
@@ -219,8 +220,8 @@ static int rxkad_secure_packet_encrypt(const struct rxrpc_call *call, | |||
219 | rxkhdr.checksum = 0; | 220 | rxkhdr.checksum = 0; |
220 | 221 | ||
221 | /* encrypt from the session key */ | 222 | /* encrypt from the session key */ |
222 | payload = call->conn->key->payload.data; | 223 | token = call->conn->key->payload.data; |
223 | memcpy(&iv, payload->k.session_key, sizeof(iv)); | 224 | memcpy(&iv, token->kad->session_key, sizeof(iv)); |
224 | desc.tfm = call->conn->cipher; | 225 | desc.tfm = call->conn->cipher; |
225 | desc.info = iv.x; | 226 | desc.info = iv.x; |
226 | desc.flags = 0; | 227 | desc.flags = 0; |
@@ -400,7 +401,7 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call, | |||
400 | struct sk_buff *skb, | 401 | struct sk_buff *skb, |
401 | u32 *_abort_code) | 402 | u32 *_abort_code) |
402 | { | 403 | { |
403 | const struct rxrpc_key_payload *payload; | 404 | const struct rxrpc_key_token *token; |
404 | struct rxkad_level2_hdr sechdr; | 405 | struct rxkad_level2_hdr sechdr; |
405 | struct rxrpc_skb_priv *sp; | 406 | struct rxrpc_skb_priv *sp; |
406 | struct blkcipher_desc desc; | 407 | struct blkcipher_desc desc; |
@@ -431,8 +432,8 @@ static int rxkad_verify_packet_encrypt(const struct rxrpc_call *call, | |||
431 | skb_to_sgvec(skb, sg, 0, skb->len); | 432 | skb_to_sgvec(skb, sg, 0, skb->len); |
432 | 433 | ||
433 | /* decrypt from the session key */ | 434 | /* decrypt from the session key */ |
434 | payload = call->conn->key->payload.data; | 435 | token = call->conn->key->payload.data; |
435 | memcpy(&iv, payload->k.session_key, sizeof(iv)); | 436 | memcpy(&iv, token->kad->session_key, sizeof(iv)); |
436 | desc.tfm = call->conn->cipher; | 437 | desc.tfm = call->conn->cipher; |
437 | desc.info = iv.x; | 438 | desc.info = iv.x; |
438 | desc.flags = 0; | 439 | desc.flags = 0; |
@@ -506,7 +507,7 @@ static int rxkad_verify_packet(const struct rxrpc_call *call, | |||
506 | if (!call->conn->cipher) | 507 | if (!call->conn->cipher) |
507 | return 0; | 508 | return 0; |
508 | 509 | ||
509 | if (sp->hdr.securityIndex != 2) { | 510 | if (sp->hdr.securityIndex != RXRPC_SECURITY_RXKAD) { |
510 | *_abort_code = RXKADINCONSISTENCY; | 511 | *_abort_code = RXKADINCONSISTENCY; |
511 | _leave(" = -EPROTO [not rxkad]"); | 512 | _leave(" = -EPROTO [not rxkad]"); |
512 | return -EPROTO; | 513 | return -EPROTO; |
@@ -737,7 +738,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, | |||
737 | struct sk_buff *skb, | 738 | struct sk_buff *skb, |
738 | u32 *_abort_code) | 739 | u32 *_abort_code) |
739 | { | 740 | { |
740 | const struct rxrpc_key_payload *payload; | 741 | const struct rxrpc_key_token *token; |
741 | struct rxkad_challenge challenge; | 742 | struct rxkad_challenge challenge; |
742 | struct rxkad_response resp | 743 | struct rxkad_response resp |
743 | __attribute__((aligned(8))); /* must be aligned for crypto */ | 744 | __attribute__((aligned(8))); /* must be aligned for crypto */ |
@@ -778,7 +779,7 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, | |||
778 | if (conn->security_level < min_level) | 779 | if (conn->security_level < min_level) |
779 | goto protocol_error; | 780 | goto protocol_error; |
780 | 781 | ||
781 | payload = conn->key->payload.data; | 782 | token = conn->key->payload.data; |
782 | 783 | ||
783 | /* build the response packet */ | 784 | /* build the response packet */ |
784 | memset(&resp, 0, sizeof(resp)); | 785 | memset(&resp, 0, sizeof(resp)); |
@@ -797,13 +798,13 @@ static int rxkad_respond_to_challenge(struct rxrpc_connection *conn, | |||
797 | (conn->channels[3] ? conn->channels[3]->call_id : 0); | 798 | (conn->channels[3] ? conn->channels[3]->call_id : 0); |
798 | resp.encrypted.inc_nonce = htonl(nonce + 1); | 799 | resp.encrypted.inc_nonce = htonl(nonce + 1); |
799 | resp.encrypted.level = htonl(conn->security_level); | 800 | resp.encrypted.level = htonl(conn->security_level); |
800 | resp.kvno = htonl(payload->k.kvno); | 801 | resp.kvno = htonl(token->kad->kvno); |
801 | resp.ticket_len = htonl(payload->k.ticket_len); | 802 | resp.ticket_len = htonl(token->kad->ticket_len); |
802 | 803 | ||
803 | /* calculate the response checksum and then do the encryption */ | 804 | /* calculate the response checksum and then do the encryption */ |
804 | rxkad_calc_response_checksum(&resp); | 805 | rxkad_calc_response_checksum(&resp); |
805 | rxkad_encrypt_response(conn, &resp, &payload->k); | 806 | rxkad_encrypt_response(conn, &resp, token->kad); |
806 | return rxkad_send_response(conn, &sp->hdr, &resp, &payload->k); | 807 | return rxkad_send_response(conn, &sp->hdr, &resp, token->kad); |
807 | 808 | ||
808 | protocol_error: | 809 | protocol_error: |
809 | *_abort_code = abort_code; | 810 | *_abort_code = abort_code; |
@@ -1122,7 +1123,7 @@ static void rxkad_clear(struct rxrpc_connection *conn) | |||
1122 | static struct rxrpc_security rxkad = { | 1123 | static struct rxrpc_security rxkad = { |
1123 | .owner = THIS_MODULE, | 1124 | .owner = THIS_MODULE, |
1124 | .name = "rxkad", | 1125 | .name = "rxkad", |
1125 | .security_index = RXKAD_VERSION, | 1126 | .security_index = RXRPC_SECURITY_RXKAD, |
1126 | .init_connection_security = rxkad_init_connection_security, | 1127 | .init_connection_security = rxkad_init_connection_security, |
1127 | .prime_packet_security = rxkad_prime_packet_security, | 1128 | .prime_packet_security = rxkad_prime_packet_security, |
1128 | .secure_packet = rxkad_secure_packet, | 1129 | .secure_packet = rxkad_secure_packet, |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index 692d9a41cd23..903e4188b6ca 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -693,13 +693,18 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, | |||
693 | if (new && i > 0) | 693 | if (new && i > 0) |
694 | atomic_inc(&new->refcnt); | 694 | atomic_inc(&new->refcnt); |
695 | 695 | ||
696 | qdisc_destroy(old); | 696 | if (!ingress) |
697 | qdisc_destroy(old); | ||
697 | } | 698 | } |
698 | 699 | ||
699 | notify_and_destroy(skb, n, classid, dev->qdisc, new); | 700 | if (!ingress) { |
700 | if (new && !new->ops->attach) | 701 | notify_and_destroy(skb, n, classid, dev->qdisc, new); |
701 | atomic_inc(&new->refcnt); | 702 | if (new && !new->ops->attach) |
702 | dev->qdisc = new ? : &noop_qdisc; | 703 | atomic_inc(&new->refcnt); |
704 | dev->qdisc = new ? : &noop_qdisc; | ||
705 | } else { | ||
706 | notify_and_destroy(skb, n, classid, old, new); | ||
707 | } | ||
703 | 708 | ||
704 | if (dev->flags & IFF_UP) | 709 | if (dev->flags & IFF_UP) |
705 | dev_activate(dev); | 710 | dev_activate(dev); |
@@ -804,7 +809,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
804 | stab = qdisc_get_stab(tca[TCA_STAB]); | 809 | stab = qdisc_get_stab(tca[TCA_STAB]); |
805 | if (IS_ERR(stab)) { | 810 | if (IS_ERR(stab)) { |
806 | err = PTR_ERR(stab); | 811 | err = PTR_ERR(stab); |
807 | goto err_out3; | 812 | goto err_out4; |
808 | } | 813 | } |
809 | sch->stab = stab; | 814 | sch->stab = stab; |
810 | } | 815 | } |
@@ -833,7 +838,6 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
833 | return sch; | 838 | return sch; |
834 | } | 839 | } |
835 | err_out3: | 840 | err_out3: |
836 | qdisc_put_stab(sch->stab); | ||
837 | dev_put(dev); | 841 | dev_put(dev); |
838 | kfree((char *) sch - sch->padded); | 842 | kfree((char *) sch - sch->padded); |
839 | err_out2: | 843 | err_out2: |
@@ -847,6 +851,7 @@ err_out4: | |||
847 | * Any broken qdiscs that would require a ops->reset() here? | 851 | * Any broken qdiscs that would require a ops->reset() here? |
848 | * The qdisc was never in action so it shouldn't be necessary. | 852 | * The qdisc was never in action so it shouldn't be necessary. |
849 | */ | 853 | */ |
854 | qdisc_put_stab(sch->stab); | ||
850 | if (ops->destroy) | 855 | if (ops->destroy) |
851 | ops->destroy(sch); | 856 | ops->destroy(sch); |
852 | goto err_out3; | 857 | goto err_out3; |
@@ -1111,12 +1116,16 @@ create_n_graft: | |||
1111 | tcm->tcm_parent, tcm->tcm_parent, | 1116 | tcm->tcm_parent, tcm->tcm_parent, |
1112 | tca, &err); | 1117 | tca, &err); |
1113 | else { | 1118 | else { |
1114 | unsigned int ntx = 0; | 1119 | struct netdev_queue *dev_queue; |
1115 | 1120 | ||
1116 | if (p && p->ops->cl_ops && p->ops->cl_ops->select_queue) | 1121 | if (p && p->ops->cl_ops && p->ops->cl_ops->select_queue) |
1117 | ntx = p->ops->cl_ops->select_queue(p, tcm); | 1122 | dev_queue = p->ops->cl_ops->select_queue(p, tcm); |
1123 | else if (p) | ||
1124 | dev_queue = p->dev_queue; | ||
1125 | else | ||
1126 | dev_queue = netdev_get_tx_queue(dev, 0); | ||
1118 | 1127 | ||
1119 | q = qdisc_create(dev, netdev_get_tx_queue(dev, ntx), p, | 1128 | q = qdisc_create(dev, dev_queue, p, |
1120 | tcm->tcm_parent, tcm->tcm_handle, | 1129 | tcm->tcm_parent, tcm->tcm_handle, |
1121 | tca, &err); | 1130 | tca, &err); |
1122 | } | 1131 | } |
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c index 12b2fb04b29b..5a888af7e5da 100644 --- a/net/sched/sch_drr.c +++ b/net/sched/sch_drr.c | |||
@@ -274,8 +274,10 @@ static int drr_dump_class_stats(struct Qdisc *sch, unsigned long arg, | |||
274 | struct tc_drr_stats xstats; | 274 | struct tc_drr_stats xstats; |
275 | 275 | ||
276 | memset(&xstats, 0, sizeof(xstats)); | 276 | memset(&xstats, 0, sizeof(xstats)); |
277 | if (cl->qdisc->q.qlen) | 277 | if (cl->qdisc->q.qlen) { |
278 | xstats.deficit = cl->deficit; | 278 | xstats.deficit = cl->deficit; |
279 | cl->qdisc->qstats.qlen = cl->qdisc->q.qlen; | ||
280 | } | ||
279 | 281 | ||
280 | if (gnet_stats_copy_basic(d, &cl->bstats) < 0 || | 282 | if (gnet_stats_copy_basic(d, &cl->bstats) < 0 || |
281 | gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 || | 283 | gnet_stats_copy_rate_est(d, &cl->rate_est) < 0 || |
diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c index dd5ee022f1f7..d1dea3d5dc92 100644 --- a/net/sched/sch_mq.c +++ b/net/sched/sch_mq.c | |||
@@ -125,13 +125,18 @@ static struct netdev_queue *mq_queue_get(struct Qdisc *sch, unsigned long cl) | |||
125 | return netdev_get_tx_queue(dev, ntx); | 125 | return netdev_get_tx_queue(dev, ntx); |
126 | } | 126 | } |
127 | 127 | ||
128 | static unsigned int mq_select_queue(struct Qdisc *sch, struct tcmsg *tcm) | 128 | static struct netdev_queue *mq_select_queue(struct Qdisc *sch, |
129 | struct tcmsg *tcm) | ||
129 | { | 130 | { |
130 | unsigned int ntx = TC_H_MIN(tcm->tcm_parent); | 131 | unsigned int ntx = TC_H_MIN(tcm->tcm_parent); |
132 | struct netdev_queue *dev_queue = mq_queue_get(sch, ntx); | ||
131 | 133 | ||
132 | if (!mq_queue_get(sch, ntx)) | 134 | if (!dev_queue) { |
133 | return 0; | 135 | struct net_device *dev = qdisc_dev(sch); |
134 | return ntx - 1; | 136 | |
137 | return netdev_get_tx_queue(dev, 0); | ||
138 | } | ||
139 | return dev_queue; | ||
135 | } | 140 | } |
136 | 141 | ||
137 | static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, | 142 | static int mq_graft(struct Qdisc *sch, unsigned long cl, struct Qdisc *new, |
@@ -188,6 +193,7 @@ static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl, | |||
188 | struct netdev_queue *dev_queue = mq_queue_get(sch, cl); | 193 | struct netdev_queue *dev_queue = mq_queue_get(sch, cl); |
189 | 194 | ||
190 | sch = dev_queue->qdisc_sleeping; | 195 | sch = dev_queue->qdisc_sleeping; |
196 | sch->qstats.qlen = sch->q.qlen; | ||
191 | if (gnet_stats_copy_basic(d, &sch->bstats) < 0 || | 197 | if (gnet_stats_copy_basic(d, &sch->bstats) < 0 || |
192 | gnet_stats_copy_queue(d, &sch->qstats) < 0) | 198 | gnet_stats_copy_queue(d, &sch->qstats) < 0) |
193 | return -1; | 199 | return -1; |
diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c index 069f81c97277..7db2c88ce585 100644 --- a/net/sched/sch_multiq.c +++ b/net/sched/sch_multiq.c | |||
@@ -359,6 +359,7 @@ static int multiq_dump_class_stats(struct Qdisc *sch, unsigned long cl, | |||
359 | struct Qdisc *cl_q; | 359 | struct Qdisc *cl_q; |
360 | 360 | ||
361 | cl_q = q->queues[cl - 1]; | 361 | cl_q = q->queues[cl - 1]; |
362 | cl_q->qstats.qlen = cl_q->q.qlen; | ||
362 | if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || | 363 | if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || |
363 | gnet_stats_copy_queue(d, &cl_q->qstats) < 0) | 364 | gnet_stats_copy_queue(d, &cl_q->qstats) < 0) |
364 | return -1; | 365 | return -1; |
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index 0f73c412d04b..93285cecb246 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c | |||
@@ -322,6 +322,7 @@ static int prio_dump_class_stats(struct Qdisc *sch, unsigned long cl, | |||
322 | struct Qdisc *cl_q; | 322 | struct Qdisc *cl_q; |
323 | 323 | ||
324 | cl_q = q->queues[cl - 1]; | 324 | cl_q = q->queues[cl - 1]; |
325 | cl_q->qstats.qlen = cl_q->q.qlen; | ||
325 | if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || | 326 | if (gnet_stats_copy_basic(d, &cl_q->bstats) < 0 || |
326 | gnet_stats_copy_queue(d, &cl_q->qstats) < 0) | 327 | gnet_stats_copy_queue(d, &cl_q->qstats) < 0) |
327 | return -1; | 328 | return -1; |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 6a4b19094143..bb280e60e00a 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -949,7 +949,7 @@ static int sctp6_rcv(struct sk_buff *skb) | |||
949 | return sctp_rcv(skb) ? -1 : 0; | 949 | return sctp_rcv(skb) ? -1 : 0; |
950 | } | 950 | } |
951 | 951 | ||
952 | static struct inet6_protocol sctpv6_protocol = { | 952 | static const struct inet6_protocol sctpv6_protocol = { |
953 | .handler = sctp6_rcv, | 953 | .handler = sctp6_rcv, |
954 | .err_handler = sctp_v6_err, | 954 | .err_handler = sctp_v6_err, |
955 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, | 955 | .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL, |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 60093be8385d..c557f1fb1c66 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -924,7 +924,7 @@ static struct inet_protosw sctp_stream_protosw = { | |||
924 | }; | 924 | }; |
925 | 925 | ||
926 | /* Register with IP layer. */ | 926 | /* Register with IP layer. */ |
927 | static struct net_protocol sctp_protocol = { | 927 | static const struct net_protocol sctp_protocol = { |
928 | .handler = sctp_rcv, | 928 | .handler = sctp_rcv, |
929 | .err_handler = sctp_v4_err, | 929 | .err_handler = sctp_v4_err, |
930 | .no_policy = 1, | 930 | .no_policy = 1, |
diff --git a/net/socket.c b/net/socket.c index 6d4716559047..2a022c00d85c 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -489,6 +489,7 @@ static struct socket *sock_alloc(void) | |||
489 | 489 | ||
490 | sock = SOCKET_I(inode); | 490 | sock = SOCKET_I(inode); |
491 | 491 | ||
492 | kmemcheck_annotate_bitfield(sock, type); | ||
492 | inode->i_mode = S_IFSOCK | S_IRWXUGO; | 493 | inode->i_mode = S_IFSOCK | S_IRWXUGO; |
493 | inode->i_uid = current_fsuid(); | 494 | inode->i_uid = current_fsuid(); |
494 | inode->i_gid = current_fsgid(); | 495 | inode->i_gid = current_fsgid(); |