net: stmmac: Add ip version to dts bindings
[deliverable/linux.git] / drivers / net / usb / asix_common.c
CommitLineData
2e55cc72
DB
1/*
2 * ASIX AX8817X based USB 2.0 Ethernet Devices
933a27d3 3 * Copyright (C) 2003-2006 David Hollis <dhollis@davehollis.com>
2e55cc72 4 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
933a27d3 5 * Copyright (C) 2006 James Painter <jamie.painter@iname.com>
2e55cc72
DB
6 * Copyright (c) 2002-2003 TiVo Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
607740bc
CR
23#include "asix.h"
24
25int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
26 u16 size, void *data)
2e55cc72 27{
51bf2976
AV
28 void *buf;
29 int err = -ENOMEM;
30
60b86755
JP
31 netdev_dbg(dev->net, "asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
32 cmd, value, index, size);
51bf2976
AV
33
34 buf = kmalloc(size, GFP_KERNEL);
35 if (!buf)
36 goto out;
37
38 err = usb_control_msg(
2e55cc72
DB
39 dev->udev,
40 usb_rcvctrlpipe(dev->udev, 0),
41 cmd,
42 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
43 value,
44 index,
51bf2976 45 buf,
2e55cc72
DB
46 size,
47 USB_CTRL_GET_TIMEOUT);
94d43363 48 if (err == size)
51bf2976 49 memcpy(data, buf, size);
94d43363
RD
50 else if (err >= 0)
51 err = -EINVAL;
51bf2976
AV
52 kfree(buf);
53
54out:
55 return err;
2e55cc72
DB
56}
57
607740bc
CR
58int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
59 u16 size, void *data)
2e55cc72 60{
51bf2976
AV
61 void *buf = NULL;
62 int err = -ENOMEM;
63
60b86755
JP
64 netdev_dbg(dev->net, "asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
65 cmd, value, index, size);
51bf2976
AV
66
67 if (data) {
99bf2366 68 buf = kmemdup(data, size, GFP_KERNEL);
51bf2976
AV
69 if (!buf)
70 goto out;
51bf2976
AV
71 }
72
73 err = usb_control_msg(
2e55cc72
DB
74 dev->udev,
75 usb_sndctrlpipe(dev->udev, 0),
76 cmd,
77 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
78 value,
79 index,
51bf2976 80 buf,
2e55cc72
DB
81 size,
82 USB_CTRL_SET_TIMEOUT);
51bf2976
AV
83 kfree(buf);
84
85out:
86 return err;
2e55cc72
DB
87}
88
7d12e780 89static void asix_async_cmd_callback(struct urb *urb)
2e55cc72
DB
90{
91 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
c94cb314 92 int status = urb->status;
2e55cc72 93
c94cb314 94 if (status < 0)
48b1be6a 95 printk(KERN_DEBUG "asix_async_cmd_callback() failed with %d",
c94cb314 96 status);
2e55cc72
DB
97
98 kfree(req);
99 usb_free_urb(urb);
100}
101
607740bc
CR
102void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
103 u16 size, void *data)
933a27d3
DH
104{
105 struct usb_ctrlrequest *req;
106 int status;
107 struct urb *urb;
108
60b86755
JP
109 netdev_dbg(dev->net, "asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d\n",
110 cmd, value, index, size);
83e1b918
GG
111
112 urb = usb_alloc_urb(0, GFP_ATOMIC);
113 if (!urb) {
60b86755 114 netdev_err(dev->net, "Error allocating URB in write_cmd_async!\n");
933a27d3
DH
115 return;
116 }
117
83e1b918
GG
118 req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
119 if (!req) {
60b86755 120 netdev_err(dev->net, "Failed to allocate memory for control request\n");
933a27d3
DH
121 usb_free_urb(urb);
122 return;
123 }
124
125 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
126 req->bRequest = cmd;
9aa742ef
ON
127 req->wValue = cpu_to_le16(value);
128 req->wIndex = cpu_to_le16(index);
129 req->wLength = cpu_to_le16(size);
933a27d3
DH
130
131 usb_fill_control_urb(urb, dev->udev,
132 usb_sndctrlpipe(dev->udev, 0),
133 (void *)req, data, size,
134 asix_async_cmd_callback, req);
135
83e1b918
GG
136 status = usb_submit_urb(urb, GFP_ATOMIC);
137 if (status < 0) {
60b86755
JP
138 netdev_err(dev->net, "Error submitting the control message: status=%d\n",
139 status);
933a27d3
DH
140 kfree(req);
141 usb_free_urb(urb);
142 }
143}
144
607740bc 145int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
933a27d3 146{
a9e0aca4 147 int offset = 0;
933a27d3 148
a9e0aca4
ED
149 while (offset + sizeof(u32) < skb->len) {
150 struct sk_buff *ax_skb;
151 u16 size;
152 u32 header = get_unaligned_le32(skb->data + offset);
933a27d3 153
a9e0aca4 154 offset += sizeof(u32);
bc466e67 155
933a27d3 156 /* get the packet length */
a9e0aca4
ED
157 size = (u16) (header & 0x7ff);
158 if (size != ((~header >> 16) & 0x07ff)) {
159 netdev_err(dev->net, "asix_rx_fixup() Bad Header Length\n");
160 return 0;
3f78d1f2
NJ
161 }
162
9dae3100 163 if ((size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) ||
a9e0aca4 164 (size + offset > skb->len)) {
60b86755
JP
165 netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
166 size);
933a27d3
DH
167 return 0;
168 }
a9e0aca4
ED
169 ax_skb = netdev_alloc_skb_ip_align(dev->net, size);
170 if (!ax_skb)
933a27d3 171 return 0;
933a27d3 172
a9e0aca4
ED
173 skb_put(ax_skb, size);
174 memcpy(ax_skb->data, skb->data + offset, size);
175 usbnet_skb_return(dev, ax_skb);
933a27d3 176
a9e0aca4 177 offset += (size + 1) & 0xfffe;
933a27d3
DH
178 }
179
a9e0aca4 180 if (skb->len != offset) {
60b86755
JP
181 netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d\n",
182 skb->len);
933a27d3
DH
183 return 0;
184 }
185 return 1;
186}
187
607740bc
CR
188struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
189 gfp_t flags)
933a27d3
DH
190{
191 int padlen;
192 int headroom = skb_headroom(skb);
193 int tailroom = skb_tailroom(skb);
194 u32 packet_len;
195 u32 padbytes = 0xffff0000;
196
2a580949 197 padlen = ((skb->len + 4) & (dev->maxpacket - 1)) ? 0 : 4;
933a27d3 198
95162d65
ED
199 /* We need to push 4 bytes in front of frame (packet_len)
200 * and maybe add 4 bytes after the end (if padlen is 4)
201 *
202 * Avoid skb_copy_expand() expensive call, using following rules :
203 * - We are allowed to push 4 bytes in headroom if skb_header_cloned()
204 * is false (and if we have 4 bytes of headroom)
205 * - We are allowed to put 4 bytes at tail if skb_cloned()
206 * is false (and if we have 4 bytes of tailroom)
207 *
208 * TCP packets for example are cloned, but skb_header_release()
209 * was called in tcp stack, allowing us to use headroom for our needs.
210 */
211 if (!skb_header_cloned(skb) &&
212 !(padlen && skb_cloned(skb)) &&
213 headroom + tailroom >= 4 + padlen) {
214 /* following should not happen, but better be safe */
215 if (headroom < 4 ||
216 tailroom < padlen) {
933a27d3 217 skb->data = memmove(skb->head + 4, skb->data, skb->len);
27a884dc 218 skb_set_tail_pointer(skb, skb->len);
933a27d3
DH
219 }
220 } else {
221 struct sk_buff *skb2;
95162d65 222
933a27d3
DH
223 skb2 = skb_copy_expand(skb, 4, padlen, flags);
224 dev_kfree_skb_any(skb);
225 skb = skb2;
226 if (!skb)
227 return NULL;
228 }
229
95162d65 230 packet_len = ((skb->len ^ 0x0000ffff) << 16) + skb->len;
933a27d3 231 skb_push(skb, 4);
57e4f041 232 cpu_to_le32s(&packet_len);
27d7ff46 233 skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
933a27d3 234
2a580949 235 if (padlen) {
57e4f041 236 cpu_to_le32s(&padbytes);
27a884dc 237 memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
933a27d3
DH
238 skb_put(skb, sizeof(padbytes));
239 }
240 return skb;
241}
242
607740bc 243int asix_set_sw_mii(struct usbnet *dev)
48b1be6a
DH
244{
245 int ret;
246 ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
247 if (ret < 0)
60b86755 248 netdev_err(dev->net, "Failed to enable software MII access\n");
48b1be6a
DH
249 return ret;
250}
251
607740bc 252int asix_set_hw_mii(struct usbnet *dev)
48b1be6a
DH
253{
254 int ret;
255 ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
256 if (ret < 0)
60b86755 257 netdev_err(dev->net, "Failed to enable hardware MII access\n");
48b1be6a
DH
258 return ret;
259}
260
16626b0c 261int asix_read_phy_addr(struct usbnet *dev, int internal)
48b1be6a 262{
16626b0c 263 int offset = (internal ? 1 : 0);
51bf2976
AV
264 u8 buf[2];
265 int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
48b1be6a 266
60b86755 267 netdev_dbg(dev->net, "asix_get_phy_addr()\n");
933a27d3 268
51bf2976 269 if (ret < 0) {
60b86755 270 netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret);
51bf2976 271 goto out;
48b1be6a 272 }
60b86755
JP
273 netdev_dbg(dev->net, "asix_get_phy_addr() returning 0x%04x\n",
274 *((__le16 *)buf));
16626b0c 275 ret = buf[offset];
51bf2976
AV
276
277out:
48b1be6a
DH
278 return ret;
279}
280
16626b0c
CR
281int asix_get_phy_addr(struct usbnet *dev)
282{
283 /* return the address of the internal phy */
284 return asix_read_phy_addr(dev, 1);
285}
286
287
607740bc 288int asix_sw_reset(struct usbnet *dev, u8 flags)
48b1be6a
DH
289{
290 int ret;
291
292 ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL);
293 if (ret < 0)
60b86755 294 netdev_err(dev->net, "Failed to send software reset: %02x\n", ret);
933a27d3
DH
295
296 return ret;
297}
48b1be6a 298
607740bc 299u16 asix_read_rx_ctl(struct usbnet *dev)
933a27d3 300{
51bf2976
AV
301 __le16 v;
302 int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v);
933a27d3 303
51bf2976 304 if (ret < 0) {
60b86755 305 netdev_err(dev->net, "Error reading RX_CTL register: %02x\n", ret);
51bf2976 306 goto out;
933a27d3 307 }
51bf2976
AV
308 ret = le16_to_cpu(v);
309out:
48b1be6a
DH
310 return ret;
311}
312
607740bc 313int asix_write_rx_ctl(struct usbnet *dev, u16 mode)
48b1be6a
DH
314{
315 int ret;
316
60b86755 317 netdev_dbg(dev->net, "asix_write_rx_ctl() - mode = 0x%04x\n", mode);
48b1be6a
DH
318 ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
319 if (ret < 0)
60b86755
JP
320 netdev_err(dev->net, "Failed to write RX_CTL mode to 0x%04x: %02x\n",
321 mode, ret);
48b1be6a
DH
322
323 return ret;
324}
325
607740bc 326u16 asix_read_medium_status(struct usbnet *dev)
2e55cc72 327{
51bf2976
AV
328 __le16 v;
329 int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v);
2e55cc72 330
51bf2976 331 if (ret < 0) {
60b86755
JP
332 netdev_err(dev->net, "Error reading Medium Status register: %02x\n",
333 ret);
83e1b918 334 return ret; /* TODO: callers not checking for error ret */
2e55cc72 335 }
83e1b918
GG
336
337 return le16_to_cpu(v);
338
2e55cc72
DB
339}
340
607740bc 341int asix_write_medium_mode(struct usbnet *dev, u16 mode)
2e55cc72 342{
933a27d3 343 int ret;
2e55cc72 344
60b86755 345 netdev_dbg(dev->net, "asix_write_medium_mode() - mode = 0x%04x\n", mode);
933a27d3
DH
346 ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
347 if (ret < 0)
60b86755
JP
348 netdev_err(dev->net, "Failed to write Medium Mode mode to 0x%04x: %02x\n",
349 mode, ret);
2e55cc72 350
933a27d3
DH
351 return ret;
352}
2e55cc72 353
607740bc 354int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
933a27d3
DH
355{
356 int ret;
2e55cc72 357
60b86755 358 netdev_dbg(dev->net, "asix_write_gpio() - value = 0x%04x\n", value);
933a27d3
DH
359 ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL);
360 if (ret < 0)
60b86755
JP
361 netdev_err(dev->net, "Failed to write GPIO value 0x%04x: %02x\n",
362 value, ret);
2e55cc72 363
933a27d3
DH
364 if (sleep)
365 msleep(sleep);
366
367 return ret;
2e55cc72
DB
368}
369
933a27d3
DH
370/*
371 * AX88772 & AX88178 have a 16-bit RX_CTL value
372 */
607740bc 373void asix_set_multicast(struct net_device *net)
2e55cc72
DB
374{
375 struct usbnet *dev = netdev_priv(net);
48b1be6a 376 struct asix_data *data = (struct asix_data *)&dev->data;
933a27d3 377 u16 rx_ctl = AX_DEFAULT_RX_CTL;
2e55cc72
DB
378
379 if (net->flags & IFF_PROMISC) {
933a27d3 380 rx_ctl |= AX_RX_CTL_PRO;
8e95a202 381 } else if (net->flags & IFF_ALLMULTI ||
4cd24eaf 382 netdev_mc_count(net) > AX_MAX_MCAST) {
933a27d3 383 rx_ctl |= AX_RX_CTL_AMALL;
4cd24eaf 384 } else if (netdev_mc_empty(net)) {
2e55cc72
DB
385 /* just broadcast and directed */
386 } else {
387 /* We use the 20 byte dev->data
388 * for our 8 byte filter buffer
389 * to avoid allocating memory that
390 * is tricky to free later */
22bedad3 391 struct netdev_hw_addr *ha;
2e55cc72 392 u32 crc_bits;
2e55cc72
DB
393
394 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
395
396 /* Build the multicast hash filter. */
22bedad3
JP
397 netdev_for_each_mc_addr(ha, net) {
398 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
2e55cc72
DB
399 data->multi_filter[crc_bits >> 3] |=
400 1 << (crc_bits & 7);
2e55cc72
DB
401 }
402
48b1be6a 403 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
2e55cc72
DB
404 AX_MCAST_FILTER_SIZE, data->multi_filter);
405
933a27d3 406 rx_ctl |= AX_RX_CTL_AM;
2e55cc72
DB
407 }
408
48b1be6a 409 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
2e55cc72
DB
410}
411
607740bc 412int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
2e55cc72
DB
413{
414 struct usbnet *dev = netdev_priv(netdev);
51bf2976 415 __le16 res;
2e55cc72 416
a9fc6338 417 mutex_lock(&dev->phy_mutex);
48b1be6a
DH
418 asix_set_sw_mii(dev);
419 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id,
51bf2976 420 (__u16)loc, 2, &res);
48b1be6a 421 asix_set_hw_mii(dev);
a9fc6338 422 mutex_unlock(&dev->phy_mutex);
2e55cc72 423
60b86755
JP
424 netdev_dbg(dev->net, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n",
425 phy_id, loc, le16_to_cpu(res));
2e55cc72 426
51bf2976 427 return le16_to_cpu(res);
2e55cc72
DB
428}
429
607740bc 430void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
2e55cc72
DB
431{
432 struct usbnet *dev = netdev_priv(netdev);
51bf2976 433 __le16 res = cpu_to_le16(val);
2e55cc72 434
60b86755
JP
435 netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n",
436 phy_id, loc, val);
a9fc6338 437 mutex_lock(&dev->phy_mutex);
48b1be6a 438 asix_set_sw_mii(dev);
51bf2976 439 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
48b1be6a 440 asix_set_hw_mii(dev);
a9fc6338 441 mutex_unlock(&dev->phy_mutex);
2e55cc72
DB
442}
443
607740bc 444void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
2e55cc72
DB
445{
446 struct usbnet *dev = netdev_priv(net);
447 u8 opt;
448
48b1be6a 449 if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) {
2e55cc72
DB
450 wolinfo->supported = 0;
451 wolinfo->wolopts = 0;
452 return;
453 }
454 wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
455 wolinfo->wolopts = 0;
f87ce5b2 456 if (opt & AX_MONITOR_LINK)
457 wolinfo->wolopts |= WAKE_PHY;
458 if (opt & AX_MONITOR_MAGIC)
459 wolinfo->wolopts |= WAKE_MAGIC;
2e55cc72
DB
460}
461
607740bc 462int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
2e55cc72
DB
463{
464 struct usbnet *dev = netdev_priv(net);
465 u8 opt = 0;
2e55cc72
DB
466
467 if (wolinfo->wolopts & WAKE_PHY)
468 opt |= AX_MONITOR_LINK;
469 if (wolinfo->wolopts & WAKE_MAGIC)
470 opt |= AX_MONITOR_MAGIC;
2e55cc72 471
48b1be6a 472 if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE,
51bf2976 473 opt, 0, 0, NULL) < 0)
2e55cc72
DB
474 return -EINVAL;
475
476 return 0;
477}
478
607740bc 479int asix_get_eeprom_len(struct net_device *net)
2e55cc72 480{
933a27d3
DH
481 struct usbnet *dev = netdev_priv(net);
482 struct asix_data *data = (struct asix_data *)&dev->data;
483
484 return data->eeprom_len;
2e55cc72
DB
485}
486
607740bc
CR
487int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
488 u8 *data)
2e55cc72
DB
489{
490 struct usbnet *dev = netdev_priv(net);
51bf2976 491 __le16 *ebuf = (__le16 *)data;
2e55cc72
DB
492 int i;
493
494 /* Crude hack to ensure that we don't overwrite memory
495 * if an odd length is supplied
496 */
497 if (eeprom->len % 2)
498 return -EINVAL;
499
500 eeprom->magic = AX_EEPROM_MAGIC;
501
502 /* ax8817x returns 2 bytes from eeprom on read */
503 for (i=0; i < eeprom->len / 2; i++) {
48b1be6a 504 if (asix_read_cmd(dev, AX_CMD_READ_EEPROM,
2e55cc72
DB
505 eeprom->offset + i, 0, 2, &ebuf[i]) < 0)
506 return -EINVAL;
507 }
508 return 0;
509}
510
607740bc 511void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info)
2e55cc72 512{
933a27d3
DH
513 struct usbnet *dev = netdev_priv(net);
514 struct asix_data *data = (struct asix_data *)&dev->data;
515
2e55cc72
DB
516 /* Inherit standard device info */
517 usbnet_get_drvinfo(net, info);
83e1b918 518 strncpy (info->driver, DRIVER_NAME, sizeof info->driver);
933a27d3
DH
519 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
520 info->eedump_len = data->eeprom_len;
2e55cc72
DB
521}
522
607740bc 523int asix_set_mac_address(struct net_device *net, void *p)
7f29a3ba
JK
524{
525 struct usbnet *dev = netdev_priv(net);
526 struct asix_data *data = (struct asix_data *)&dev->data;
527 struct sockaddr *addr = p;
528
529 if (netif_running(net))
530 return -EBUSY;
531 if (!is_valid_ether_addr(addr->sa_data))
532 return -EADDRNOTAVAIL;
533
534 memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
535
536 /* We use the 20 byte dev->data
537 * for our 6 byte mac buffer
538 * to avoid allocating memory that
539 * is tricky to free later */
540 memcpy(data->mac_addr, addr->sa_data, ETH_ALEN);
541 asix_write_cmd_async(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
542 data->mac_addr);
543
544 return 0;
545}
This page took 0.851582 seconds and 5 git commands to generate.