xref: /freebsd/sys/dev/e1000/e1000_vf.c (revision 6966ac055c3b7a39266fb982493330df7a097997)
1 /******************************************************************************
2   SPDX-License-Identifier: BSD-3-Clause
3 
4   Copyright (c) 2001-2015, Intel Corporation
5   All rights reserved.
6 
7   Redistribution and use in source and binary forms, with or without
8   modification, are permitted provided that the following conditions are met:
9 
10    1. Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12 
13    2. Redistributions in binary form must reproduce the above copyright
14       notice, this list of conditions and the following disclaimer in the
15       documentation and/or other materials provided with the distribution.
16 
17    3. Neither the name of the Intel Corporation nor the names of its
18       contributors may be used to endorse or promote products derived from
19       this software without specific prior written permission.
20 
21   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31   POSSIBILITY OF SUCH DAMAGE.
32 
33 ******************************************************************************/
34 /*$FreeBSD$*/
35 
36 
37 #include "e1000_api.h"
38 
39 
40 static s32 e1000_init_phy_params_vf(struct e1000_hw *hw);
41 static s32 e1000_init_nvm_params_vf(struct e1000_hw *hw);
42 static void e1000_release_vf(struct e1000_hw *hw);
43 static s32 e1000_acquire_vf(struct e1000_hw *hw);
44 static s32 e1000_setup_link_vf(struct e1000_hw *hw);
45 static s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
46 static s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
47 static s32 e1000_check_for_link_vf(struct e1000_hw *hw);
48 static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
49 				     u16 *duplex);
50 static s32 e1000_init_hw_vf(struct e1000_hw *hw);
51 static s32 e1000_reset_hw_vf(struct e1000_hw *hw);
52 static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *, u32);
53 static int  e1000_rar_set_vf(struct e1000_hw *, u8 *, u32);
54 static s32 e1000_read_mac_addr_vf(struct e1000_hw *);
55 
56 /**
57  *  e1000_init_phy_params_vf - Inits PHY params
58  *  @hw: pointer to the HW structure
59  *
60  *  Doesn't do much - there's no PHY available to the VF.
61  **/
62 static s32 e1000_init_phy_params_vf(struct e1000_hw *hw)
63 {
64 	DEBUGFUNC("e1000_init_phy_params_vf");
65 	hw->phy.type = e1000_phy_vf;
66 	hw->phy.ops.acquire = e1000_acquire_vf;
67 	hw->phy.ops.release = e1000_release_vf;
68 
69 	return E1000_SUCCESS;
70 }
71 
72 /**
73  *  e1000_init_nvm_params_vf - Inits NVM params
74  *  @hw: pointer to the HW structure
75  *
76  *  Doesn't do much - there's no NVM available to the VF.
77  **/
78 static s32 e1000_init_nvm_params_vf(struct e1000_hw *hw)
79 {
80 	DEBUGFUNC("e1000_init_nvm_params_vf");
81 	hw->nvm.type = e1000_nvm_none;
82 	hw->nvm.ops.acquire = e1000_acquire_vf;
83 	hw->nvm.ops.release = e1000_release_vf;
84 
85 	return E1000_SUCCESS;
86 }
87 
88 /**
89  *  e1000_init_mac_params_vf - Inits MAC params
90  *  @hw: pointer to the HW structure
91  **/
92 static s32 e1000_init_mac_params_vf(struct e1000_hw *hw)
93 {
94 	struct e1000_mac_info *mac = &hw->mac;
95 
96 	DEBUGFUNC("e1000_init_mac_params_vf");
97 
98 	/* Set media type */
99 	/*
100 	 * Virtual functions don't care what they're media type is as they
101 	 * have no direct access to the PHY, or the media.  That is handled
102 	 * by the physical function driver.
103 	 */
104 	hw->phy.media_type = e1000_media_type_unknown;
105 
106 	/* No ASF features for the VF driver */
107 	mac->asf_firmware_present = FALSE;
108 	/* ARC subsystem not supported */
109 	mac->arc_subsystem_valid = FALSE;
110 	/* Disable adaptive IFS mode so the generic funcs don't do anything */
111 	mac->adaptive_ifs = FALSE;
112 	/* VF's have no MTA Registers - PF feature only */
113 	mac->mta_reg_count = 128;
114 	/* VF's have no access to RAR entries  */
115 	mac->rar_entry_count = 1;
116 
117 	/* Function pointers */
118 	/* link setup */
119 	mac->ops.setup_link = e1000_setup_link_vf;
120 	/* bus type/speed/width */
121 	mac->ops.get_bus_info = e1000_get_bus_info_pcie_vf;
122 	/* reset */
123 	mac->ops.reset_hw = e1000_reset_hw_vf;
124 	/* hw initialization */
125 	mac->ops.init_hw = e1000_init_hw_vf;
126 	/* check for link */
127 	mac->ops.check_for_link = e1000_check_for_link_vf;
128 	/* link info */
129 	mac->ops.get_link_up_info = e1000_get_link_up_info_vf;
130 	/* multicast address update */
131 	mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_vf;
132 	/* set mac address */
133 	mac->ops.rar_set = e1000_rar_set_vf;
134 	/* read mac address */
135 	mac->ops.read_mac_addr = e1000_read_mac_addr_vf;
136 
137 
138 	return E1000_SUCCESS;
139 }
140 
141 /**
142  *  e1000_init_function_pointers_vf - Inits function pointers
143  *  @hw: pointer to the HW structure
144  **/
145 void e1000_init_function_pointers_vf(struct e1000_hw *hw)
146 {
147 	DEBUGFUNC("e1000_init_function_pointers_vf");
148 
149 	hw->mac.ops.init_params = e1000_init_mac_params_vf;
150 	hw->nvm.ops.init_params = e1000_init_nvm_params_vf;
151 	hw->phy.ops.init_params = e1000_init_phy_params_vf;
152 	hw->mbx.ops.init_params = e1000_init_mbx_params_vf;
153 }
154 
155 /**
156  *  e1000_acquire_vf - Acquire rights to access PHY or NVM.
157  *  @hw: pointer to the HW structure
158  *
159  *  There is no PHY or NVM so we want all attempts to acquire these to fail.
160  *  In addition, the MAC registers to access PHY/NVM don't exist so we don't
161  *  even want any SW to attempt to use them.
162  **/
163 static s32 e1000_acquire_vf(struct e1000_hw E1000_UNUSEDARG *hw)
164 {
165 	return -E1000_ERR_PHY;
166 }
167 
168 /**
169  *  e1000_release_vf - Release PHY or NVM
170  *  @hw: pointer to the HW structure
171  *
172  *  There is no PHY or NVM so we want all attempts to acquire these to fail.
173  *  In addition, the MAC registers to access PHY/NVM don't exist so we don't
174  *  even want any SW to attempt to use them.
175  **/
176 static void e1000_release_vf(struct e1000_hw E1000_UNUSEDARG *hw)
177 {
178 	return;
179 }
180 
181 /**
182  *  e1000_setup_link_vf - Sets up link.
183  *  @hw: pointer to the HW structure
184  *
185  *  Virtual functions cannot change link.
186  **/
187 static s32 e1000_setup_link_vf(struct e1000_hw E1000_UNUSEDARG *hw)
188 {
189 	DEBUGFUNC("e1000_setup_link_vf");
190 
191 	return E1000_SUCCESS;
192 }
193 
194 /**
195  *  e1000_get_bus_info_pcie_vf - Gets the bus info.
196  *  @hw: pointer to the HW structure
197  *
198  *  Virtual functions are not really on their own bus.
199  **/
200 static s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw)
201 {
202 	struct e1000_bus_info *bus = &hw->bus;
203 
204 	DEBUGFUNC("e1000_get_bus_info_pcie_vf");
205 
206 	/* Do not set type PCI-E because we don't want disable master to run */
207 	bus->type = e1000_bus_type_reserved;
208 	bus->speed = e1000_bus_speed_2500;
209 
210 	return 0;
211 }
212 
213 /**
214  *  e1000_get_link_up_info_vf - Gets link info.
215  *  @hw: pointer to the HW structure
216  *  @speed: pointer to 16 bit value to store link speed.
217  *  @duplex: pointer to 16 bit value to store duplex.
218  *
219  *  Since we cannot read the PHY and get accurate link info, we must rely upon
220  *  the status register's data which is often stale and inaccurate.
221  **/
222 static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
223 				     u16 *duplex)
224 {
225 	s32 status;
226 
227 	DEBUGFUNC("e1000_get_link_up_info_vf");
228 
229 	status = E1000_READ_REG(hw, E1000_STATUS);
230 	if (status & E1000_STATUS_SPEED_1000) {
231 		*speed = SPEED_1000;
232 		DEBUGOUT("1000 Mbs, ");
233 	} else if (status & E1000_STATUS_SPEED_100) {
234 		*speed = SPEED_100;
235 		DEBUGOUT("100 Mbs, ");
236 	} else {
237 		*speed = SPEED_10;
238 		DEBUGOUT("10 Mbs, ");
239 	}
240 
241 	if (status & E1000_STATUS_FD) {
242 		*duplex = FULL_DUPLEX;
243 		DEBUGOUT("Full Duplex\n");
244 	} else {
245 		*duplex = HALF_DUPLEX;
246 		DEBUGOUT("Half Duplex\n");
247 	}
248 
249 	return E1000_SUCCESS;
250 }
251 
252 /**
253  *  e1000_reset_hw_vf - Resets the HW
254  *  @hw: pointer to the HW structure
255  *
256  *  VF's provide a function level reset. This is done using bit 26 of ctrl_reg.
257  *  This is all the reset we can perform on a VF.
258  **/
259 static s32 e1000_reset_hw_vf(struct e1000_hw *hw)
260 {
261 	struct e1000_mbx_info *mbx = &hw->mbx;
262 	u32 timeout = E1000_VF_INIT_TIMEOUT;
263 	s32 ret_val = -E1000_ERR_MAC_INIT;
264 	u32 ctrl, msgbuf[3];
265 	u8 *addr = (u8 *)(&msgbuf[1]);
266 
267 	DEBUGFUNC("e1000_reset_hw_vf");
268 
269 	DEBUGOUT("Issuing a function level reset to MAC\n");
270 	ctrl = E1000_READ_REG(hw, E1000_CTRL);
271 	E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
272 
273 	/* we cannot reset while the RSTI / RSTD bits are asserted */
274 	while (!mbx->ops.check_for_rst(hw, 0) && timeout) {
275 		timeout--;
276 		usec_delay(5);
277 	}
278 
279 	if (timeout) {
280 		/* mailbox timeout can now become active */
281 		mbx->timeout = E1000_VF_MBX_INIT_TIMEOUT;
282 
283 		msgbuf[0] = E1000_VF_RESET;
284 		mbx->ops.write_posted(hw, msgbuf, 1, 0);
285 
286 		msec_delay(10);
287 
288 		/* set our "perm_addr" based on info provided by PF */
289 		ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
290 		if (!ret_val) {
291 			if (msgbuf[0] == (E1000_VF_RESET |
292 			    E1000_VT_MSGTYPE_ACK))
293 				memcpy(hw->mac.perm_addr, addr, 6);
294 			else
295 				ret_val = -E1000_ERR_MAC_INIT;
296 		}
297 	}
298 
299 	return ret_val;
300 }
301 
302 /**
303  *  e1000_init_hw_vf - Inits the HW
304  *  @hw: pointer to the HW structure
305  *
306  *  Not much to do here except clear the PF Reset indication if there is one.
307  **/
308 static s32 e1000_init_hw_vf(struct e1000_hw *hw)
309 {
310 	DEBUGFUNC("e1000_init_hw_vf");
311 
312 	/* attempt to set and restore our mac address */
313 	e1000_rar_set_vf(hw, hw->mac.addr, 0);
314 
315 	return E1000_SUCCESS;
316 }
317 
318 /**
319  *  e1000_rar_set_vf - set device MAC address
320  *  @hw: pointer to the HW structure
321  *  @addr: pointer to the receive address
322  *  @index receive address array register
323  **/
324 static int e1000_rar_set_vf(struct e1000_hw *hw, u8 *addr,
325 			     u32 E1000_UNUSEDARG index)
326 {
327 	struct e1000_mbx_info *mbx = &hw->mbx;
328 	u32 msgbuf[3];
329 	u8 *msg_addr = (u8 *)(&msgbuf[1]);
330 	s32 ret_val;
331 
332 	memset(msgbuf, 0, 12);
333 	msgbuf[0] = E1000_VF_SET_MAC_ADDR;
334 	memcpy(msg_addr, addr, 6);
335 	ret_val = mbx->ops.write_posted(hw, msgbuf, 3, 0);
336 
337 	if (!ret_val)
338 		ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
339 
340 	msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
341 
342 	/* if nacked the address was rejected, use "perm_addr" */
343 	if (!ret_val &&
344 	    (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK)))
345 		e1000_read_mac_addr_vf(hw);
346 
347 	return E1000_SUCCESS;
348 }
349 
350 /**
351  *  e1000_hash_mc_addr_vf - Generate a multicast hash value
352  *  @hw: pointer to the HW structure
353  *  @mc_addr: pointer to a multicast address
354  *
355  *  Generates a multicast address hash value which is used to determine
356  *  the multicast filter table array address and new table value.
357  **/
358 static u32 e1000_hash_mc_addr_vf(struct e1000_hw *hw, u8 *mc_addr)
359 {
360 	u32 hash_value, hash_mask;
361 	u8 bit_shift = 0;
362 
363 	DEBUGFUNC("e1000_hash_mc_addr_generic");
364 
365 	/* Register count multiplied by bits per register */
366 	hash_mask = (hw->mac.mta_reg_count * 32) - 1;
367 
368 	/*
369 	 * The bit_shift is the number of left-shifts
370 	 * where 0xFF would still fall within the hash mask.
371 	 */
372 	while (hash_mask >> bit_shift != 0xFF)
373 		bit_shift++;
374 
375 	hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
376 				  (((u16) mc_addr[5]) << bit_shift)));
377 
378 	return hash_value;
379 }
380 
381 static void e1000_write_msg_read_ack(struct e1000_hw *hw,
382 				     u32 *msg, u16 size)
383 {
384 	struct e1000_mbx_info *mbx = &hw->mbx;
385 	u32 retmsg[E1000_VFMAILBOX_SIZE];
386 	s32 retval = mbx->ops.write_posted(hw, msg, size, 0);
387 
388 	if (!retval)
389 		mbx->ops.read_posted(hw, retmsg, E1000_VFMAILBOX_SIZE, 0);
390 }
391 
392 /**
393  *  e1000_update_mc_addr_list_vf - Update Multicast addresses
394  *  @hw: pointer to the HW structure
395  *  @mc_addr_list: array of multicast addresses to program
396  *  @mc_addr_count: number of multicast addresses to program
397  *
398  *  Updates the Multicast Table Array.
399  *  The caller must have a packed mc_addr_list of multicast addresses.
400  **/
401 void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
402 				  u8 *mc_addr_list, u32 mc_addr_count)
403 {
404 	u32 msgbuf[E1000_VFMAILBOX_SIZE];
405 	u16 *hash_list = (u16 *)&msgbuf[1];
406 	u32 hash_value;
407 	u32 i;
408 
409 	DEBUGFUNC("e1000_update_mc_addr_list_vf");
410 
411 	/* Each entry in the list uses 1 16 bit word.  We have 30
412 	 * 16 bit words available in our HW msg buffer (minus 1 for the
413 	 * msg type).  That's 30 hash values if we pack 'em right.  If
414 	 * there are more than 30 MC addresses to add then punt the
415 	 * extras for now and then add code to handle more than 30 later.
416 	 * It would be unusual for a server to request that many multi-cast
417 	 * addresses except for in large enterprise network environments.
418 	 */
419 
420 	DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
421 
422 	if (mc_addr_count > 30) {
423 		msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW;
424 		mc_addr_count = 30;
425 	}
426 
427 	msgbuf[0] = E1000_VF_SET_MULTICAST;
428 	msgbuf[0] |= mc_addr_count << E1000_VT_MSGINFO_SHIFT;
429 
430 	for (i = 0; i < mc_addr_count; i++) {
431 		hash_value = e1000_hash_mc_addr_vf(hw, mc_addr_list);
432 		DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
433 		hash_list[i] = hash_value & 0x0FFF;
434 		mc_addr_list += ETHER_ADDR_LEN;
435 	}
436 
437 	e1000_write_msg_read_ack(hw, msgbuf, E1000_VFMAILBOX_SIZE);
438 }
439 
440 /**
441  *  e1000_vfta_set_vf - Set/Unset vlan filter table address
442  *  @hw: pointer to the HW structure
443  *  @vid: determines the vfta register and bit to set/unset
444  *  @set: if TRUE then set bit, else clear bit
445  **/
446 void e1000_vfta_set_vf(struct e1000_hw *hw, u16 vid, bool set)
447 {
448 	u32 msgbuf[2];
449 
450 	msgbuf[0] = E1000_VF_SET_VLAN;
451 	msgbuf[1] = vid;
452 	/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
453 	if (set)
454 		msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
455 
456 	e1000_write_msg_read_ack(hw, msgbuf, 2);
457 }
458 
459 /** e1000_rlpml_set_vf - Set the maximum receive packet length
460  *  @hw: pointer to the HW structure
461  *  @max_size: value to assign to max frame size
462  **/
463 void e1000_rlpml_set_vf(struct e1000_hw *hw, u16 max_size)
464 {
465 	u32 msgbuf[2];
466 
467 	msgbuf[0] = E1000_VF_SET_LPE;
468 	msgbuf[1] = max_size;
469 
470 	e1000_write_msg_read_ack(hw, msgbuf, 2);
471 }
472 
473 /**
474  *  e1000_promisc_set_vf - Set flags for Unicast or Multicast promisc
475  *  @hw: pointer to the HW structure
476  *  @uni: boolean indicating unicast promisc status
477  *  @multi: boolean indicating multicast promisc status
478  **/
479 s32 e1000_promisc_set_vf(struct e1000_hw *hw, enum e1000_promisc_type type)
480 {
481 	struct e1000_mbx_info *mbx = &hw->mbx;
482 	u32 msgbuf = E1000_VF_SET_PROMISC;
483 	s32 ret_val;
484 
485 	switch (type) {
486 	case e1000_promisc_multicast:
487 		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
488 		break;
489 	case e1000_promisc_enabled:
490 		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
491 		/* FALLTHROUGH */
492 	case e1000_promisc_unicast:
493 		msgbuf |= E1000_VF_SET_PROMISC_UNICAST;
494 		/* FALLTHROUGH */
495 	case e1000_promisc_disabled:
496 		break;
497 	default:
498 		return -E1000_ERR_MAC_INIT;
499 	}
500 
501 	 ret_val = mbx->ops.write_posted(hw, &msgbuf, 1, 0);
502 
503 	if (!ret_val)
504 		ret_val = mbx->ops.read_posted(hw, &msgbuf, 1, 0);
505 
506 	if (!ret_val && !(msgbuf & E1000_VT_MSGTYPE_ACK))
507 		ret_val = -E1000_ERR_MAC_INIT;
508 
509 	return ret_val;
510 }
511 
512 /**
513  *  e1000_read_mac_addr_vf - Read device MAC address
514  *  @hw: pointer to the HW structure
515  **/
516 static s32 e1000_read_mac_addr_vf(struct e1000_hw *hw)
517 {
518 	int i;
519 
520 	for (i = 0; i < ETHER_ADDR_LEN; i++)
521 		hw->mac.addr[i] = hw->mac.perm_addr[i];
522 
523 	return E1000_SUCCESS;
524 }
525 
526 /**
527  *  e1000_check_for_link_vf - Check for link for a virtual interface
528  *  @hw: pointer to the HW structure
529  *
530  *  Checks to see if the underlying PF is still talking to the VF and
531  *  if it is then it reports the link state to the hardware, otherwise
532  *  it reports link down and returns an error.
533  **/
534 static s32 e1000_check_for_link_vf(struct e1000_hw *hw)
535 {
536 	struct e1000_mbx_info *mbx = &hw->mbx;
537 	struct e1000_mac_info *mac = &hw->mac;
538 	s32 ret_val = E1000_SUCCESS;
539 	u32 in_msg = 0;
540 
541 	DEBUGFUNC("e1000_check_for_link_vf");
542 
543 	/*
544 	 * We only want to run this if there has been a rst asserted.
545 	 * in this case that could mean a link change, device reset,
546 	 * or a virtual function reset
547 	 */
548 
549 	/* If we were hit with a reset or timeout drop the link */
550 	if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
551 		mac->get_link_status = TRUE;
552 
553 	if (!mac->get_link_status)
554 		goto out;
555 
556 	/* if link status is down no point in checking to see if pf is up */
557 	if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU))
558 		goto out;
559 
560 	/* if the read failed it could just be a mailbox collision, best wait
561 	 * until we are called again and don't report an error */
562 	if (mbx->ops.read(hw, &in_msg, 1, 0))
563 		goto out;
564 
565 	/* if incoming message isn't clear to send we are waiting on response */
566 	if (!(in_msg & E1000_VT_MSGTYPE_CTS)) {
567 		/* message is not CTS and is NACK we have lost CTS status */
568 		if (in_msg & E1000_VT_MSGTYPE_NACK)
569 			ret_val = -E1000_ERR_MAC_INIT;
570 		goto out;
571 	}
572 
573 	/* at this point we know the PF is talking to us, check and see if
574 	 * we are still accepting timeout or if we had a timeout failure.
575 	 * if we failed then we will need to reinit */
576 	if (!mbx->timeout) {
577 		ret_val = -E1000_ERR_MAC_INIT;
578 		goto out;
579 	}
580 
581 	/* if we passed all the tests above then the link is up and we no
582 	 * longer need to check for link */
583 	mac->get_link_status = FALSE;
584 
585 out:
586 	return ret_val;
587 }
588 
589