net/ark: support arbitrary mbuf size
[dpdk.git] / drivers / net / ark / ark_ethdev_rx.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2015-2018 Atomic Rules LLC
3  */
4
5 #include <unistd.h>
6
7 #include "ark_ethdev_rx.h"
8 #include "ark_global.h"
9 #include "ark_logs.h"
10 #include "ark_mpu.h"
11 #include "ark_udm.h"
12
13 #define ARK_RX_META_SIZE 32
14 #define ARK_RX_META_OFFSET (RTE_PKTMBUF_HEADROOM - ARK_RX_META_SIZE)
15
16 /* Forward declarations */
17 struct ark_rx_queue;
18 struct ark_rx_meta;
19
20 static void dump_mbuf_data(struct rte_mbuf *mbuf, uint16_t lo, uint16_t hi);
21 static void ark_ethdev_rx_dump(const char *name, struct ark_rx_queue *queue);
22 static uint32_t eth_ark_rx_jumbo(struct ark_rx_queue *queue,
23                                  struct ark_rx_meta *meta,
24                                  struct rte_mbuf *mbuf0,
25                                  uint32_t cons_index);
26 static inline int eth_ark_rx_seed_mbufs(struct ark_rx_queue *queue);
27
28 /* ************************************************************************* */
29 struct ark_rx_queue {
30         /* array of mbufs to populate */
31         struct rte_mbuf **reserve_q;
32         /* array of physical addresses of the mbuf data pointer */
33         /* This point is a virtual address */
34         rte_iova_t *paddress_q;
35         struct rte_mempool *mb_pool;
36
37         struct ark_udm_t *udm;
38         struct ark_mpu_t *mpu;
39
40         rx_user_meta_hook_fn rx_user_meta_hook;
41         void *ext_user_data;
42
43         uint32_t dataroom;
44         uint32_t headroom;
45
46         uint32_t queue_size;
47         uint32_t queue_mask;
48
49         uint32_t seed_index;            /* step 1 set with empty mbuf */
50         uint32_t cons_index;            /* step 3 consumed by driver */
51
52         /* The queue Id is used to identify the HW Q */
53         uint16_t phys_qid;
54
55         /* The queue Index is used within the dpdk device structures */
56         uint16_t queue_index;
57
58         uint32_t unused;
59
60         /* next cache line - fields written by device */
61         RTE_MARKER cacheline1 __rte_cache_min_aligned;
62
63         volatile uint32_t prod_index;   /* step 2 filled by FPGA */
64 } __rte_cache_aligned;
65
66 /* ************************************************************************* */
67 static int
68 eth_ark_rx_hw_setup(struct rte_eth_dev *dev,
69                     struct ark_rx_queue *queue,
70                     uint16_t rx_queue_id __rte_unused, uint16_t rx_queue_idx)
71 {
72         rte_iova_t queue_base;
73         rte_iova_t phys_addr_q_base;
74         rte_iova_t phys_addr_prod_index;
75
76         queue_base = rte_malloc_virt2iova(queue);
77         phys_addr_prod_index = queue_base +
78                 offsetof(struct ark_rx_queue, prod_index);
79
80         phys_addr_q_base = rte_malloc_virt2iova(queue->paddress_q);
81
82         /* Verify HW */
83         if (ark_mpu_verify(queue->mpu, sizeof(rte_iova_t))) {
84                 ARK_PMD_LOG(ERR, "Illegal configuration rx queue\n");
85                 return -1;
86         }
87
88         /* Stop and Reset and configure MPU */
89         ark_mpu_configure(queue->mpu, phys_addr_q_base, queue->queue_size, 0);
90
91         ark_udm_write_addr(queue->udm, phys_addr_prod_index);
92
93         /* advance the valid pointer, but don't start until the queue starts */
94         ark_mpu_reset_stats(queue->mpu);
95
96         /* The seed is the producer index for the HW */
97         ark_mpu_set_producer(queue->mpu, queue->seed_index);
98         dev->data->rx_queue_state[rx_queue_idx] = RTE_ETH_QUEUE_STATE_STOPPED;
99
100         return 0;
101 }
102
103 static inline void
104 eth_ark_rx_update_cons_index(struct ark_rx_queue *queue, uint32_t cons_index)
105 {
106         queue->cons_index = cons_index;
107         if ((cons_index + queue->queue_size - queue->seed_index) >= 64U) {
108                 eth_ark_rx_seed_mbufs(queue);
109                 ark_mpu_set_producer(queue->mpu, queue->seed_index);
110         }
111 }
112
113 /* ************************************************************************* */
114 int
115 eth_ark_dev_rx_queue_setup(struct rte_eth_dev *dev,
116                            uint16_t queue_idx,
117                            uint16_t nb_desc,
118                            unsigned int socket_id,
119                            const struct rte_eth_rxconf *rx_conf,
120                            struct rte_mempool *mb_pool)
121 {
122         static int warning1;            /* = 0 */
123         struct ark_adapter *ark = dev->data->dev_private;
124
125         struct ark_rx_queue *queue;
126         uint32_t i;
127         int status;
128
129         int qidx = queue_idx;
130
131         /* We may already be setup, free memory prior to re-allocation */
132         if (dev->data->rx_queues[queue_idx] != NULL) {
133                 eth_ark_dev_rx_queue_release(dev->data->rx_queues[queue_idx]);
134                 dev->data->rx_queues[queue_idx] = NULL;
135         }
136
137         if (rx_conf != NULL && warning1 == 0) {
138                 warning1 = 1;
139                 ARK_PMD_LOG(NOTICE,
140                             "Arkville ignores rte_eth_rxconf argument.\n");
141         }
142
143         if (RTE_PKTMBUF_HEADROOM < ARK_RX_META_SIZE) {
144                 ARK_PMD_LOG(ERR,
145                             "Error: DPDK Arkville requires head room > %d bytes (%s)\n",
146                             ARK_RX_META_SIZE, __func__);
147                 return -1;              /* ERROR CODE */
148         }
149
150         if (!rte_is_power_of_2(nb_desc)) {
151                 ARK_PMD_LOG(ERR,
152                             "DPDK Arkville configuration queue size must be power of two %u (%s)\n",
153                             nb_desc, __func__);
154                 return -1;              /* ERROR CODE */
155         }
156
157         /* Allocate queue struct */
158         queue = rte_zmalloc_socket("Ark_rxqueue",
159                                    sizeof(struct ark_rx_queue),
160                                    64,
161                                    socket_id);
162         if (queue == 0) {
163                 ARK_PMD_LOG(ERR, "Failed to allocate memory in %s\n", __func__);
164                 return -ENOMEM;
165         }
166
167         /* NOTE zmalloc is used, no need to 0 indexes, etc. */
168         queue->mb_pool = mb_pool;
169         queue->dataroom = rte_pktmbuf_data_room_size(mb_pool) -
170                 RTE_PKTMBUF_HEADROOM;
171         queue->headroom = RTE_PKTMBUF_HEADROOM;
172         queue->phys_qid = qidx;
173         queue->queue_index = queue_idx;
174         queue->queue_size = nb_desc;
175         queue->queue_mask = nb_desc - 1;
176         queue->rx_user_meta_hook = ark->user_ext.rx_user_meta_hook;
177         queue->ext_user_data = ark->user_data[dev->data->port_id];
178
179         queue->reserve_q =
180                 rte_zmalloc_socket("Ark_rx_queue mbuf",
181                                    nb_desc * sizeof(struct rte_mbuf *),
182                                    64,
183                                    socket_id);
184         queue->paddress_q =
185                 rte_zmalloc_socket("Ark_rx_queue paddr",
186                                    nb_desc * sizeof(rte_iova_t),
187                                    64,
188                                    socket_id);
189
190         if (queue->reserve_q == 0 || queue->paddress_q == 0) {
191                 ARK_PMD_LOG(ERR,
192                             "Failed to allocate queue memory in %s\n",
193                             __func__);
194                 rte_free(queue->reserve_q);
195                 rte_free(queue->paddress_q);
196                 rte_free(queue);
197                 return -ENOMEM;
198         }
199
200         dev->data->rx_queues[queue_idx] = queue;
201         queue->udm = RTE_PTR_ADD(ark->udm.v, qidx * ARK_UDM_QOFFSET);
202         queue->mpu = RTE_PTR_ADD(ark->mpurx.v, qidx * ARK_MPU_QOFFSET);
203
204         /* Configure UDM per queue */
205         ark_udm_stop(queue->udm, 0);
206         ark_udm_configure(queue->udm,
207                           RTE_PKTMBUF_HEADROOM,
208                           queue->dataroom,
209                           ARK_RX_WRITE_TIME_NS);
210         ark_udm_stats_reset(queue->udm);
211         ark_udm_stop(queue->udm, 0);
212
213         /* populate mbuf reserve */
214         status = eth_ark_rx_seed_mbufs(queue);
215
216         if (queue->seed_index != nb_desc) {
217                 ARK_PMD_LOG(ERR, "Failed to allocate %u mbufs for RX queue %d\n",
218                             nb_desc, qidx);
219                 status = -1;
220         }
221         /* MPU Setup */
222         if (status == 0)
223                 status = eth_ark_rx_hw_setup(dev, queue, qidx, queue_idx);
224
225         if (unlikely(status != 0)) {
226                 struct rte_mbuf **mbuf;
227
228                 ARK_PMD_LOG(ERR, "Failed to initialize RX queue %d %s\n",
229                             qidx,
230                             __func__);
231                 /* Free the mbufs allocated */
232                 for (i = 0, mbuf = queue->reserve_q;
233                      i < queue->seed_index; ++i, mbuf++) {
234                         rte_pktmbuf_free(*mbuf);
235                 }
236                 rte_free(queue->reserve_q);
237                 rte_free(queue->paddress_q);
238                 rte_free(queue);
239                 return -1;              /* ERROR CODE */
240         }
241
242         return 0;
243 }
244
245 /* ************************************************************************* */
246 uint16_t
247 eth_ark_recv_pkts(void *rx_queue,
248                   struct rte_mbuf **rx_pkts,
249                   uint16_t nb_pkts)
250 {
251         struct ark_rx_queue *queue;
252         register uint32_t cons_index, prod_index;
253         uint16_t nb;
254         uint16_t i;
255         struct rte_mbuf *mbuf;
256         struct rte_mbuf **pmbuf;
257         struct ark_rx_meta *meta;
258         rx_user_meta_hook_fn rx_user_meta_hook;
259
260         queue = (struct ark_rx_queue *)rx_queue;
261         if (unlikely(queue == 0))
262                 return 0;
263         if (unlikely(nb_pkts == 0))
264                 return 0;
265         prod_index = queue->prod_index;
266         cons_index = queue->cons_index;
267         if (prod_index == cons_index)
268                 return 0;
269         nb = 0;
270
271         while (prod_index != cons_index) {
272                 mbuf = queue->reserve_q[cons_index & queue->queue_mask];
273                 /* prefetch mbuf */
274                 rte_mbuf_prefetch_part1(mbuf);
275                 rte_mbuf_prefetch_part2(mbuf);
276
277                 /* META DATA embedded in headroom */
278                 meta = RTE_PTR_ADD(mbuf->buf_addr, ARK_RX_META_OFFSET);
279
280                 mbuf->pkt_len = meta->pkt_len;
281                 mbuf->data_len = meta->pkt_len;
282
283                 if (ARK_DEBUG_CORE) {   /* debug sanity checks */
284
285                         if ((meta->pkt_len > (1024 * 16)) ||
286                             (meta->pkt_len == 0)) {
287                                 ARK_PMD_LOG(DEBUG, "RX: Bad Meta Q: %u"
288                                            " cons: %" PRIU32
289                                            " prod: %" PRIU32
290                                            " seed_index %" PRIU32
291                                            "\n",
292                                            queue->phys_qid,
293                                            cons_index,
294                                            queue->prod_index,
295                                            queue->seed_index);
296
297
298                                 ARK_PMD_LOG(DEBUG, "       :  UDM"
299                                            " prod: %" PRIU32
300                                            " len: %u\n",
301                                            queue->udm->rt_cfg.prod_idx,
302                                            meta->pkt_len);
303                                 ark_mpu_dump(queue->mpu,
304                                              "    ",
305                                              queue->phys_qid);
306                                 dump_mbuf_data(mbuf, 0, 256);
307                                 /* its FUBAR so fix it */
308                                 mbuf->pkt_len = 63;
309                                 meta->pkt_len = 63;
310                         }
311                 }
312
313                 if (unlikely(meta->pkt_len > queue->dataroom))
314                         cons_index = eth_ark_rx_jumbo
315                                 (queue, meta, mbuf, cons_index + 1);
316                 else
317                         cons_index += 1;
318
319                 rx_pkts[nb] = mbuf;
320                 nb++;
321                 if (nb >= nb_pkts)
322                         break;
323         }
324
325         rx_user_meta_hook = queue->rx_user_meta_hook;
326         for (pmbuf = rx_pkts, i = 0; rx_user_meta_hook && i < nb; i++) {
327                 mbuf = *pmbuf++;
328                 meta = RTE_PTR_ADD(mbuf->buf_addr, ARK_RX_META_OFFSET);
329                 rx_user_meta_hook(mbuf, meta->user_meta, queue->ext_user_data);
330         }
331
332         eth_ark_rx_update_cons_index(queue, cons_index);
333
334         return nb;
335 }
336
337 /* ************************************************************************* */
338 static uint32_t
339 eth_ark_rx_jumbo(struct ark_rx_queue *queue,
340                  struct ark_rx_meta *meta,
341                  struct rte_mbuf *mbuf0,
342                  uint32_t cons_index)
343 {
344         struct rte_mbuf *mbuf_prev;
345         struct rte_mbuf *mbuf;
346
347         uint16_t remaining;
348         uint16_t data_len;
349         uint16_t segments;
350
351         /* first buf populated by called */
352         mbuf_prev = mbuf0;
353         segments = 1;
354         data_len = RTE_MIN(meta->pkt_len, queue->dataroom);
355         remaining = meta->pkt_len - data_len;
356         mbuf0->data_len = data_len;
357
358         /* HW guarantees that the data does not exceed prod_index! */
359         while (remaining != 0) {
360                 data_len = RTE_MIN(remaining,
361                                    queue->dataroom);
362
363                 remaining -= data_len;
364                 segments += 1;
365
366                 mbuf = queue->reserve_q[cons_index & queue->queue_mask];
367                 mbuf_prev->next = mbuf;
368                 mbuf_prev = mbuf;
369                 mbuf->data_len = data_len;
370
371                 cons_index += 1;
372         }
373
374         mbuf0->nb_segs = segments;
375         return cons_index;
376 }
377
378 /* Drain the internal queue allowing hw to clear out. */
379 static void
380 eth_ark_rx_queue_drain(struct ark_rx_queue *queue)
381 {
382         register uint32_t cons_index;
383         struct rte_mbuf *mbuf;
384
385         cons_index = queue->cons_index;
386
387         /* NOT performance optimized, since this is a one-shot call */
388         while ((cons_index ^ queue->prod_index) & queue->queue_mask) {
389                 mbuf = queue->reserve_q[cons_index & queue->queue_mask];
390                 rte_pktmbuf_free(mbuf);
391                 cons_index++;
392                 eth_ark_rx_update_cons_index(queue, cons_index);
393         }
394 }
395
396 uint32_t
397 eth_ark_dev_rx_queue_count(void *rx_queue)
398 {
399         struct ark_rx_queue *queue;
400
401         queue = rx_queue;
402         return (queue->prod_index - queue->cons_index); /* mod arith */
403 }
404
405 /* ************************************************************************* */
406 int
407 eth_ark_rx_start_queue(struct rte_eth_dev *dev, uint16_t queue_id)
408 {
409         struct ark_rx_queue *queue;
410
411         queue = dev->data->rx_queues[queue_id];
412         if (queue == 0)
413                 return -1;
414
415         dev->data->rx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
416
417         ark_mpu_set_producer(queue->mpu, queue->seed_index);
418         ark_mpu_start(queue->mpu);
419
420         ark_udm_queue_enable(queue->udm, 1);
421
422         return 0;
423 }
424
425 /* ************************************************************************* */
426
427 /* Queue can be restarted.   data remains
428  */
429 int
430 eth_ark_rx_stop_queue(struct rte_eth_dev *dev, uint16_t queue_id)
431 {
432         struct ark_rx_queue *queue;
433
434         queue = dev->data->rx_queues[queue_id];
435         if (queue == 0)
436                 return -1;
437
438         ark_udm_queue_enable(queue->udm, 0);
439
440         dev->data->rx_queue_state[queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
441
442         return 0;
443 }
444
445 /* ************************************************************************* */
446 static inline int
447 eth_ark_rx_seed_mbufs(struct ark_rx_queue *queue)
448 {
449         uint32_t limit = queue->cons_index + queue->queue_size;
450         uint32_t seed_index = queue->seed_index;
451
452         uint32_t count = 0;
453         uint32_t seed_m = queue->seed_index & queue->queue_mask;
454
455         uint32_t nb = limit - seed_index;
456
457         /* Handle wrap around -- remainder is filled on the next call */
458         if (unlikely(seed_m + nb > queue->queue_size))
459                 nb = queue->queue_size - seed_m;
460
461         struct rte_mbuf **mbufs = &queue->reserve_q[seed_m];
462         int status = rte_pktmbuf_alloc_bulk(queue->mb_pool, mbufs, nb);
463
464         if (unlikely(status != 0)) {
465                 ARK_PMD_LOG(NOTICE,
466                             "Could not allocate %u mbufs from pool"
467                             " for RX queue %u;"
468                             " %u free buffers remaining in queue\n",
469                             nb, queue->queue_index,
470                             queue->seed_index - queue->cons_index);
471                 return -1;
472         }
473
474         if (ARK_DEBUG_CORE) {           /* DEBUG */
475                 while (count != nb) {
476                         struct rte_mbuf *mbuf_init =
477                                 queue->reserve_q[seed_m + count];
478
479                         memset(mbuf_init->buf_addr, -1, 512);
480                         *((uint32_t *)mbuf_init->buf_addr) =
481                                 seed_index + count;
482                         *(uint16_t *)RTE_PTR_ADD(mbuf_init->buf_addr, 4) =
483                                 queue->phys_qid;
484                         count++;
485                 }
486                 count = 0;
487         } /* DEBUG */
488         queue->seed_index += nb;
489
490         /* Duff's device https://en.wikipedia.org/wiki/Duff's_device */
491         switch (nb % 4) {
492         case 0:
493                 while (count != nb) {
494                         queue->paddress_q[seed_m++] =
495                                 (*mbufs++)->buf_iova;
496                         count++;
497                 /* FALLTHROUGH */
498         case 3:
499                 queue->paddress_q[seed_m++] =
500                         (*mbufs++)->buf_iova;
501                 count++;
502                 /* FALLTHROUGH */
503         case 2:
504                 queue->paddress_q[seed_m++] =
505                         (*mbufs++)->buf_iova;
506                 count++;
507                 /* FALLTHROUGH */
508         case 1:
509                 queue->paddress_q[seed_m++] =
510                         (*mbufs++)->buf_iova;
511                 count++;
512                 /* FALLTHROUGH */
513
514                 } /* while (count != nb) */
515         } /* switch */
516
517         return 0;
518 }
519
520 void
521 eth_ark_rx_dump_queue(struct rte_eth_dev *dev, uint16_t queue_id,
522                       const char *msg)
523 {
524         struct ark_rx_queue *queue;
525
526         queue = dev->data->rx_queues[queue_id];
527
528         ark_ethdev_rx_dump(msg, queue);
529 }
530
531 /* ************************************************************************* */
532 /* Call on device closed no user API, queue is stopped */
533 void
534 eth_ark_dev_rx_queue_release(void *vqueue)
535 {
536         struct ark_rx_queue *queue;
537         uint32_t i;
538
539         queue = (struct ark_rx_queue *)vqueue;
540         if (queue == 0)
541                 return;
542
543         ark_udm_queue_enable(queue->udm, 0);
544         /* Stop the MPU since pointer are going away */
545         ark_mpu_stop(queue->mpu);
546
547         /* Need to clear out mbufs here, dropping packets along the way */
548         eth_ark_rx_queue_drain(queue);
549
550         for (i = 0; i < queue->queue_size; ++i)
551                 rte_pktmbuf_free(queue->reserve_q[i]);
552
553         rte_free(queue->reserve_q);
554         rte_free(queue->paddress_q);
555         rte_free(queue);
556 }
557
558 void
559 eth_rx_queue_stats_get(void *vqueue, struct rte_eth_stats *stats)
560 {
561         struct ark_rx_queue *queue;
562         struct ark_udm_t *udm;
563
564         queue = vqueue;
565         if (queue == 0)
566                 return;
567         udm = queue->udm;
568
569         uint64_t ibytes = ark_udm_bytes(udm);
570         uint64_t ipackets = ark_udm_packets(udm);
571         uint64_t idropped = ark_udm_dropped(queue->udm);
572
573         stats->q_ipackets[queue->queue_index] = ipackets;
574         stats->q_ibytes[queue->queue_index] = ibytes;
575         stats->q_errors[queue->queue_index] = idropped;
576         stats->ipackets += ipackets;
577         stats->ibytes += ibytes;
578         stats->imissed += idropped;
579 }
580
581 void
582 eth_rx_queue_stats_reset(void *vqueue)
583 {
584         struct ark_rx_queue *queue;
585
586         queue = vqueue;
587         if (queue == 0)
588                 return;
589
590         ark_mpu_reset_stats(queue->mpu);
591         ark_udm_queue_stats_reset(queue->udm);
592 }
593
594 void
595 eth_ark_udm_force_close(struct rte_eth_dev *dev)
596 {
597         struct ark_adapter *ark = dev->data->dev_private;
598         struct ark_rx_queue *queue;
599         uint32_t index;
600         uint16_t i;
601
602         if (!ark_udm_is_flushed(ark->udm.v)) {
603                 /* restart the MPUs */
604                 ARK_PMD_LOG(NOTICE, "UDM not flushed -- forcing flush\n");
605                 for (i = 0; i < dev->data->nb_rx_queues; i++) {
606                         queue = (struct ark_rx_queue *)dev->data->rx_queues[i];
607                         if (queue == 0)
608                                 continue;
609
610                         ark_mpu_start(queue->mpu);
611                         /* Add some buffers */
612                         index = 100000 + queue->seed_index;
613                         ark_mpu_set_producer(queue->mpu, index);
614                 }
615                 /* Wait to allow data to pass */
616                 usleep(100);
617
618                 ARK_PMD_LOG(DEBUG, "UDM forced flush attempt, stopped = %d\n",
619                                 ark_udm_is_flushed(ark->udm.v));
620         }
621         ark_udm_reset(ark->udm.v);
622 }
623
624 static void
625 ark_ethdev_rx_dump(const char *name, struct ark_rx_queue *queue)
626 {
627         if (queue == NULL)
628                 return;
629         ARK_PMD_LOG(DEBUG, "RX QUEUE %d -- %s", queue->phys_qid, name);
630         ARK_PMD_LOG(DEBUG, ARK_SU32 ARK_SU32 ARK_SU32 ARK_SU32 "\n",
631                         "queue_size", queue->queue_size,
632                         "seed_index", queue->seed_index,
633                         "prod_index", queue->prod_index,
634                         "cons_index", queue->cons_index);
635
636         ark_mpu_dump(queue->mpu, name, queue->phys_qid);
637         ark_mpu_dump_setup(queue->mpu, queue->phys_qid);
638         ark_udm_dump(queue->udm, name);
639         ark_udm_dump_setup(queue->udm, queue->phys_qid);
640 }
641
642 /* Only used in debug.
643  * This function is a raw memory dump of a portion of an mbuf's memory
644  * region.  The usual function, rte_pktmbuf_dump() only shows data
645  * with respect to the data_off field.  This function show data
646  * anywhere in the mbuf's buffer.  This is useful for examining
647  * data in the headroom or tailroom portion of an mbuf.
648  */
649 static void
650 dump_mbuf_data(struct rte_mbuf *mbuf, uint16_t lo, uint16_t hi)
651 {
652         uint16_t i, j;
653
654         ARK_PMD_LOG(DEBUG, " MBUF: %p len %d, off: %d\n",
655                     mbuf, mbuf->pkt_len, mbuf->data_off);
656         for (i = lo; i < hi; i += 16) {
657                 uint8_t *dp = RTE_PTR_ADD(mbuf->buf_addr, i);
658
659                 ARK_PMD_LOG(DEBUG, "  %6d:  ", i);
660                 for (j = 0; j < 16; j++)
661                         ARK_PMD_LOG(DEBUG, " %02x", dp[j]);
662
663                 ARK_PMD_LOG(DEBUG, "\n");
664         }
665 }